• EOS abi 解析


    本文为了 说明 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

  • 相关阅读:
    jvm原理----------4.Java虚拟机何谓垃圾及垃圾回收算法
    jvm原理----------5.垃圾收集器及内存分配策略
    jvm原理----------6.创建对象及对象的访问定位
    mysql的sql语句的常用的优化方式
    jvm内存原理及调优(完全总结)
    dubbo的负载均衡与重试机制
    File类
    异常的真实应用
    字符串转换功能
    Object类介绍
  • 原文地址:https://www.cnblogs.com/xiaoxuebiye/p/12768655.html
Copyright © 2020-2023  润新知