zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    css3回顾 checkbox
    mysql在linux下的安装
    LNMP(linux+nginx+mysql+php)服务器环境配置
    linux下如何查看某软件是否已安装
    Linux查看系统信息的一些命令及查看已安装软件包的命令
    正确配置nginx和php
    服务器搭建:手把手教你配置web服务之nginx1
    搭配环境一(手动搭建,重要!!)
    安装配置nginx
    nginx配置参数中文详解
  • 原文地址:https://www.cnblogs.com/xiaoxuebiye/p/12768655.html
Copyright © 2011-2022 走看看