How to create a zero-balance coin on frontend?

,

(Thanks to @stefanospleros from Sui Discord.)

If a function needs only a zero coin, I would suggest removing that argument and creating the zero coin internally like I mentioned above.
however if you still need to pass it from a PTB you can still use the same method in your PTB and pass that argument in your function. Here is some sample code:

let txn = new Transaction();
const zeroCoin = txn.moveCall({
  target: `${SUI_FRAMEWORK_ADDRESS}::coin::zero`,
  arguments: [],
  typeArguments: ["Package::module::COIN_TYPE"],

});

txn.moveCall({
  target: "YourPackage::YourModule::YourFunction",
  arguments: [zeroCoin,...],
  typeArguments: [...]
})
1 Like