Send SUI when calling smart contract function

How can I send Sui when calling an entry smart contract function using SUI SDK not as gas amount (ofc I am assuming I would send gas separately)? What would the entry smart contract would look like, that expect SUI?

2 Likes

The function in your package/module (smart contract) would have argument like in_coin:Coin<SUI>

Assuming TS-SDK it would be tx.object("0x.....") where ‘0x…’ is replaced with the coin ID

2 Likes

If I split a coin like this:

const txb = new TransactionBlock();
const [coin] = txb.splitCoins(txb.gas, [txb.pure(100000)]);

Should I pass only the coin variable

1 Like

Yes, the result(s) of a splitCoins can be used in any subsequent command that takes either a coin or object.

2 Likes

Should I need to set the gas amount before splitting the coin?

1 Like