智能合约WASM相关API
submitsetcodetx
用于部署智能合约
Parameters
submitsetcodetx "sender" "wasm_file" "abi_file" ["contract"] [symbol:fee:unit]
deploy code and abi to an account as contract
Arguments:
sender
(string, required), 在这个钱包中发起合约的regid
code_file
: (string, required), 合约的文件目录,要写绝对路径
abi_file
: (string, required), abi合约的绝对路径
contract
: (string, optional), 如果输入合同号,则省略部署
symbol:fee:unit
: (string:numeric:string, optional) 支付给矿工的费用,默认为 WICC:100000:sawi
Result
txhash
(string) 发布合约交易的哈希
Examples
// Request
root@0e7612ac5bc5:/tmp/wasm# coind submitsetcodetx 0-2 /tmp/wasm/hello/hello.wasm /tmp/wasm/hello/hello.abi
// Response
{
"txid" : "3e5f9f31cdcf32ff93f4f8741b1fc467721b93a0282e7f5bea758096ffb49068"
}
// json
curl --user myusername -d '{"jsonrpc": "1.0", "id":"curltest", "method":"submitsetcodetx", "params":["0-2", "/tmp/wasm/hello/hello.wasm", "/tmp/wasm/hello/hello.abi"]}' -H 'Content-Type: application/json;' http://127.0.0.1:8332
getcontractregid
获取智能合约的regid
Parameters
txhash
发布合约时的交易哈希
Returns
regid
该智能合约的regid
regid_hex
智能合约的regid转成hex
Example
//Request
root@0e7612ac5bc5:/tmp/wasm# coind getcontractregid "3e5f9f31cdcf32ff93f4f8741b1fc467721b93a0282e7f5bea758096ffb49068"
// Response
{
"regid" : "9925-2",
"regid_hex" : "c52600000200"
}
submittx
调用合约
Parameters
submittx "sender" "contract" "action" "data" "fee"
sender
(string, required) 合约调用者地址/regid
contract
(string, required) 智能合约的regid
action
(string, required) 调用合约的函数名
data
(json string, required) 调用合约的函数参数
symbol:fee:unit
(numeric, optional) 矿工费
Result
txid
(string) 调用合约的交易哈希
Examples
// Request
root@0e7612ac5bc5:/tmp/wasm# coind submittx 0-2 9925-2 hi '["kj"]'
// Response
{
"txid" : "29a779176018e4f1bb8aaf58d89aa92d73bc0e73e62c88470c6c7db6664cc8e4",
"tx_trace" : {
"trx_id" : "29a779176018e4f1bb8aaf58d89aa92d73bc0e73e62c88470c6c7db6664cc8e4",
"elapsed" : 262,
"minimum_fee" : 100000,
"traces" : [
{
"trx_id" : "29a779176018e4f1bb8aaf58d89aa92d73bc0e73e62c88470c6c7db6664cc8e4",
"receiver" : "9925-2",
"trx" : {
"contract" : "9925-2",
"action" : "hi",
"authorization" : [
{
"account" : "0-2",
"permission" : "wasmio_owner"
}
],
"data" : {
"nm" : "kj"
}
}
}
]
}
}