How to execute swap x coin to y coin with vector<Coin<X> via cli or explorer?

network: testnet
package id: 0xde6d331b7e97f33542d9edc035c67b1bdacd8368bb044999d54cd04ad0b8cb7f

purpose:
i want to execute the function swap_x_to_y

my cli:
sui client call --package 0xde6d331b7e97f33542d9edc035c67b1bdacd8368bb044999d54cd04ad0b8cb7f --module liquidity --function swap_x_to_y --gas-budget 1000000000 --type-args 0xa5c174f361589a5300cfa82e255fa641174f36050c38d7501853ecc433b44a01::ucoin::UCOIN 0x5fd6c233a9876649cde33f240d2b42581ad479270a10ef1dc6689fd3ed5a4764::faucetucoin::FAUCETUCOIN --args 0xd254bb1f9c64f852b1a42e346350279d5f5399f48970b5d3dce178c88c72cd64 ‘[“0x56bd79ffbc0ed590e17e1fa3ee9fa61ea334735c6cdf5d165732a19d64725fa7”]’ 26

Error msg on terminal:
Error executing transaction: Failure {
error: “CommandArgumentError { arg_idx: 0, kind: TypeMismatch } in command 1”,
}

Error msg on explorer:
Expect ‘[“0x56bd79ffbc0ed590e17e1fa3ee9fa61ea334735c6cdf5d165732a19d64725fa7”]’ to be a array, received string

1 Like

You could try this with the CLI PTB.

sui client ptb --move-call 0xde6d331b7e97f33542d9edc035c67b1bdacd8368bb044999d54cd04ad0b8cb7f::liquidity::swap_x_to_y "<0xa5c174f361589a5300cfa82e255fa641174f36050c38d7501853ecc433b44a01::ucoin::UCOIN,0x5fd6c233a9876649cde33f240d2b42581ad479270a10ef1dc6689fd3ed5a4764::faucetucoin::FAUCETUCOIN>" your function args here

If you need to pass an array, you can do "[value,value2]". 

your command is wrong, is not worked. by the way, thanks for your reply

So which command did work in the end @martinyeung?

i mean i have tried your solution, but it is not worked. I still don’t have any solution.

Sorry to hear that. This is what I just tried and worked for me (except it failed because the TX was not signed by the correct sender, which is obvsiously expected).

sui client ptb --move-call 0xde6d331b7e97f33542d9edc035c67b1bdacd8368bb044999d54cd04ad0b8cb7f::liquidity::swap_x_to_y "<0xa5c174f361589a5300cfa82e255fa641174f36050c38d7501853ecc433b44a01::ucoin::UCOIN,0x5fd6c233a9876649cde33f240d2b42581ad479270a10ef1dc6689fd3ed5a4764::faucetucoin::FAUCETUCOIN>" @0xd254bb1f9c64f852b1a42e346350279d5f5399f48970b5d3dce178c88c72cd64 @0x56bd79ffbc0ed590e17e1fa3ee9fa61ea334735c6cdf5d165732a19d64725fa7 26 --gas-budget 50000000

i got other error:

thread ‘2024-05-21T01:35:40.540918Z ERROR telemetry_subscribers: panicked at crates\sui-protocol-config\src\lib.rs:1252:9:
Network protocol version is ProtocolVersion(45), but the maximum supported version by the binary is 43. Please upgrade the binary. panic.file=“crates\sui-protocol-config\src\lib.rs” panic.line=1252 panic.column=9
main’ panicked at crates\sui-protocol-config\src\lib.rs:1252:9:
Network protocol version is ProtocolVersion(45), but the maximum supported version by the binary is 43. Please upgrade the binary.
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

not yet, but i don’t have money for your service, thanks

For the error, you will have to update your Sui CLI binary. See here more details: Install Sui | Sui Documentation