Hi everyone,
I’m facing an issue while working with a smart contract interface and attempting to create transaction data using the unsafe_moveCall
Sui method. I suspect there might be an issue with my syntax.
Smart contract is:
mainnet Sui
id: 0xba153169476e8c3114962261d1edc70de5ad9781b83cc617ecc8c1923191cae0
module: router
function: swap_exact_x_to_y_direct
The smart contract method I’m trying to use is as follows:
public swap_exact_x_to_y_direct<Ty0, Ty1>(
Arg0: &mut PairMetadata<Ty0, Ty1>,
Arg1: Coin<Ty0>,
Arg2: &mut TxContext): Coin<Ty1>
{
...
}
As an example, the PairMetadata<Ty0, Ty1>
struct associated with this method is defined as:
struct PairMetadata<phantom Ty0, phantom Ty1> has store, key {
id: UID,
reserve_x: Coin<Ty0>,
reserve_y: Coin<Ty1>,
k_last: u128,
lp_supply: Supply<LP<Ty0, Ty1>>,
fee_rate: u64
}
I’m struggling to pass a struct to one of the arguments of the swap_method
. Could someone please assist me with the correct syntax and provide an example of how to pass a struct to some smart contract method?
I use something data as follows and got “{“code”:-32000,“message”:“ObjectID hex string must start with 0x.”}”
"id": "0x0873c37a0d62911e26bb57f2d8a574f11d1385c89509a55e4c866500b2c54bae",
"reserve_x": {
"id": "0x0000000000000000000000000000000000000000000000000000000000000002::suiSUI",
"balance": 12345
},
"reserve_y": {
"id":"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
"balance": 1234
},
"k_last": 123456,
"lp_supply": {
"type": "0x2::balance::Supply<0xba153169476e8c3114962261d1edc70de5ad9781b83cc617ecc8c1923191cae0::pair::LP<0x2::sui::SUI, 0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN>>",
"fields": {
"value": "69586987607386"
}
},
"fee_rate": 30
Thank you in advance for your help!