本文为了 说明 eos 智能合约的 ABI 的 json
查询智能合约的 ABI
查合约接口信息
cleos get abi deposit.tx
{ "version": "eosio::abi/1.1", "types": [], "structs": [{ "name": "confirm", "base": "", "fields": [{ "name": "validator", "type": "name" },{ "name": "from", "type": "string" },{ "name": "to", "type": "string" },{ "name": "quantity", "type": "asset" },{ "name": "txhash", "type": "string" } ] },{ "name": "confpending", "base": "", "fields": [{ "name": "validator", "type": "name" },{ "name": "from", "type": "string" },{ "name": "to", "type": "string" },{ "name": "quantity", "type": "asset" },{ "name": "txhash", "type": "string" },{ "name": "numConfirmed", "type": "uint64" },{ "name": "thresoldConfirmed", "type": "uint64" } ] },{ "name": "tx_rec", "base": "", "fields": [{ "name": "id", "type": "uint64" },{ "name": "quantity", "type": "asset" },{ "name": "user", "type": "name" },{ "name": "from", "type": "string" },{ "name": "txhash", "type": "string" },{ "name": "timestamp", "type": "uint64" },{ "name": "is_valid", "type": "bool" },{ "name": "validators", "type": "name[]" } ] } ], "actions": [{ "name": "confirm", "type": "confirm", "ricardian_contract": "" },{ "name": "confpending", "type": "confpending", "ricardian_contract": "" } ], "tables": [{ "name": "transactions", "index_type": "i64", "key_names": [], "key_types": [], "type": "tx_rec" } ], "ricardian_clauses": [], "error_messages": [], "abi_extensions": [], "variants": [] }
解析:
structs 定义函数 没个数组行,代表一个函数,函数名 name 函数参数 fields
actions 定义输出接口(输出哪几个函数)
比如上例子的 confirm 函数, 函数参数从structs 里找
实际调用命令 cleos push action deposit.tx confirm '["p1","p2","p3","p4","p5"]' -p eosuserxxx
["p1","p2","p3","p4","p5"] 对应 fields: validator from to quantity txhash
tables 定义表 , 表名 name, scope 从 get scope deposit.tx 找
如果 scope 不存在,返回空行
比如 :
cleos get table deposit.tx xxxx transactions
cleos get table deposit.tx ......2cel2kc transactions
cleos get scope deposit.tx
查表数据
cleos get table deposit.tx USDT transactions