fuels-abi-cli
sway-abi-cli 0.1.0
FuelVM ABI coder
USAGE:
sway-abi-cli <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
codegen Output Rust types file
decode Decode ABI call result
encode Encode ABI call
help Prints this message or the help of the given subcommand(s)
$ cargo run -- encode params -v bool true
0000000000000001
$ cargo run -- encode params -v bool true -v u32 42 -v u32 100
0000000000000001000000000000002a0000000000000064
-v
flag followed by the type, and then the value: -v <type_1> <value_1> -v <type_2> <value_2> -v <type_n> <value_n>
example/simple.json
: [
{
"type":"function",
"inputs":[
{
"name":"arg",
"type":"u32"
}
],
"name":"takes_u32_returns_bool",
"outputs":[
{
"name":"",
"type":"bool"
}
]
}
]
$ cargo run -- encode function examples/simple.json takes_u32_returns_bool -p 4
000000006355e6ee0000000000000004
example/array.json
[
{
"type":"function",
"inputs":[
{
"name":"arg",
"type":"u16[3]"
}
],
"name":"takes_array",
"outputs":[
{
"name":"",
"type":"u16[2]"
}
]
}
]
$ cargo run -- encode function examples/array.json takes_array -p '[1,2]'
00000000f0b8786400000000000000010000000000000002
[
{
"type":"contract",
"inputs":[
{
"name":"MyNestedStruct",
"type":"struct",
"components":[
{
"name":"x",
"type":"u16"
},
{
"name":"y",
"type":"struct",
"components":[
{
"name":"a",
"type":"bool"
},
{
"name":"b",
"type":"u8[2]"
}
]
}
]
}
],
"name":"takes_nested_struct",
"outputs":[
]
}
]
$ cargo run -- encode function examples/nested_struct.json takes_nested_struct -p '(10, (true, [1,2]))'
00000000e8a04d9c000000000000000a000000000000000100000000000000010000000000000002
$ cargo run -- decode params -t bool -t u32 -t u32 0000000000000001000000000000002a0000000000000064
Bool(true)
U32(42)
U32(100)
$ cargo run -- decode function examples/simple.json takes_u32_returns_bool 0000000000000001
Bool(true)