EOS小白学习(五)EOS的HTTP API

欢迎来到EOS小白学习系列,本系列会记录EOS学习过程中的一些操作和细节,大饼果子非C++出身,如有错误,欢迎指出

接上一篇:

本篇将会列出EOS支持的HTTP API(chain和history),没有过多的讲解,只是方便大家调用

1. chain/get_info(请求链的信息)

POST:

http://127.0.0.1:8888/v1/chain/get_info

BODY: 什么都不需要填

{}

RESPONSE:

{
    "server_version": "75635168",
    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
    "head_block_num": 43060,
    "last_irreversible_block_num": 43059,
    "last_irreversible_block_id": "0000a833ade6bcfaa05490c14b9e2dec3b59271001314048405a0b2b8fb35f7e",
    "head_block_id": "0000a834303d5901171d86c699f0a00a309dcf86ad28252f1b05191b3f3f509e",
    "head_block_time": "2018-07-24T06:56:29.500",
    "head_block_producer": "eosio",
    "virtual_block_cpu_limit": 200000000,
    "virtual_block_net_limit": 1048576000,
    "block_cpu_limit": 199900,
    "block_net_limit": 1048576
}

2. chain/get_block(请求block的信息)

POST:

http://127.0.0.1:8888/v1/chain/get_block

BODY: 需要填写block的number

{
  "block_num_or_id": 19238
}

RESPONSE:

{
    "timestamp": "2018-07-22T02:55:41.000",
    "producer": "eosio",
    "confirmed": 0,
    "previous": "00004b25b6213b5de760937e2315611de3a65cdacfea4bdf757ba46730d79d06",
    "transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000",
    "action_mroot": "1738e6b70e77ce96a56982dc3eda3cc2191801e1e15854935508c91891c10385",
    "schedule_version": 0,
    "new_producers": null,
    "header_extensions": [],
    "producer_signature": "SIG_K1_Jwy7AtXzLMX6wy4DfYQhQ2vKSaA77k4RH7fCBh9cq6FMA8hzdwY5nHSSJzUbgTL8tnzRoerAzgrY3aqNPuvCMgWcreN7rz",
    "transactions": [],
    "block_extensions": [],
    "id": "00004b269841c0b8899b8c5218eaf1d5beb1881ece8f1303954cc65d944a8365",
    "block_num": 19238,
    "ref_block_prefix": 1384946569
}

3. chain/get_account(请求account的信息)

POST:

http://127.0.0.1:8888/v1/chain/get_account

BODY: 需要填写account的名字

{
  "account_name":"dabingguozi"
}

RESPONSE:

{
    "account_name": "dabingguozi",
    "head_block_num": 44279,
    "head_block_time": "2018-07-24T07:06:39.000",
    "privileged": false,
    "last_code_update": "1970-01-01T00:00:00.000",
    "created": "2018-07-21T08:04:17.000",
    "core_liquid_balance": "554.0000 SYS",
    "ram_quota": 8150,
    "net_weight": 10000000,
    "cpu_weight": 10000000,
    "net_limit": {
        "used": 0,
        "available": "347781061036",
        "max": "347781061036"
    },
    "cpu_limit": {
        "used": 0,
        "available": "66333973128",
        "max": "66333973128"
    },
    "ram_usage": 2996,
    "permissions": [
        {
            "perm_name": "active",
            "parent": "owner",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        },
        {
            "perm_name": "owner",
            "parent": "",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        }
    ],
    "total_resources": {
        "owner": "dabingguozi",
        "net_weight": "1000.0000 SYS",
        "cpu_weight": "1000.0000 SYS",
        "ram_bytes": 8150
    },
    "self_delegated_bandwidth": null,
    "refund_request": null,
    "voter_info": null
}


4. chain/get_abi(请求合约的信息)

POST:

http://127.0.0.1:8888/v1/chain/get_abi

BODY: 需要填写合约用户名字

{
  "account_name":"eosio.token"
}

RESPONSE:

{
    "account_name": "eosio.token",
    "abi": {
        "version": "eosio::abi/1.0",
        "types": [
            {
                "new_type_name": "account_name",
                "type": "name"
            }
        ],
        "structs": [
            {
                "name": "transfer",
                "base": "",
                "fields": [
                    {
                        "name": "from",
                        "type": "account_name"
                    },
                    {
                        "name": "to",
                        "type": "account_name"
                    },
                    {
                        "name": "quantity",
                        "type": "asset"
                    },
                    {
                        "name": "memo",
                        "type": "string"
                    }
                ]
            },
            {
                "name": "create",
                "base": "",
                "fields": [
                    {
                        "name": "issuer",
                        "type": "account_name"
                    },
                    {
                        "name": "maximum_supply",
                        "type": "asset"
                    }
                ]
            },
            {
                "name": "issue",
                "base": "",
                "fields": [
                    {
                        "name": "to",
                        "type": "account_name"
                    },
                    {
                        "name": "quantity",
                        "type": "asset"
                    },
                    {
                        "name": "memo",
                        "type": "string"
                    }
                ]
            },
            {
                "name": "account",
                "base": "",
                "fields": [
                    {
                        "name": "balance",
                        "type": "asset"
                    }
                ]
            },
            {
                "name": "currency_stats",
                "base": "",
                "fields": [
                    {
                        "name": "supply",
                        "type": "asset"
                    },
                    {
                        "name": "max_supply",
                        "type": "asset"
                    },
                    {
                        "name": "issuer",
                        "type": "account_name"
                    }
                ]
            }
        ],
        "actions": [
            {
                "name": "transfer",
                "type": "transfer",
                "ricardian_contract": ""
            },
            {
                "name": "issue",
                "type": "issue",
                "ricardian_contract": ""
            },
            {
                "name": "create",
                "type": "create",
                "ricardian_contract": ""
            }
        ],
        "tables": [
            {
                "name": "accounts",
                "index_type": "i64",
                "key_names": [
                    "currency"
                ],
                "key_types": [
                    "uint64"
                ],
                "type": "account"
            },
            {
                "name": "stat",
                "index_type": "i64",
                "key_names": [
                    "currency"
                ],
                "key_types": [
                    "uint64"
                ],
                "type": "currency_stats"
            }
        ],
        "ricardian_clauses": [],
        "error_messages": [],
        "abi_extensions": []
    }
}

5. chain/get_table_rows(请求表的信息)

POST:

http://127.0.0.1:8888/v1/chain/get_table_rows

BODY: 其中code是合约账户,scope是合约中设定的(相当于mysql的database),table也是合约中设定的(相当于mysql的table)

{
  "code":"eosio.token",
  "scope": "dabingguozi",
  "table": "accounts",
  "json": true
}

RESPONSE:

{
    "rows": [
        {
            "balance": "554.0000 SYS"
        }
    ],
    "more": false
}

6. chain/get_currency_balance(请求余额的信息)

POST:

http://127.0.0.1:8888/v1/chain/get_currency_balance

BODY: 其中code是合约账户,account是用户account

{
  "code":"eosio.token",
  "account": "dabingguozi"
}

RESPONSE:

[
    "554.0000 SYS"
]

7. history/get_transactions(请求transaction的信息)

POST:

http://127.0.0.1:8888/v1/history/get_transaction

BODY: 需要填写transaction的id

{
  "id":"b09395d938e594b838277453cea832ddc5d57ab5e92d8763ea011df9e35d7b34"
}

RESPONSE:

{
    "id": "b09395d938e594b838277453cea832ddc5d57ab5e92d8763ea011df9e35d7b34",
    "trx": {
        "receipt": {
            "status": "executed",
            "cpu_usage_us": 2751,
            "net_usage_words": 16,
            "trx": [
                1,
                {
                    "signatures": [
                        "SIG_K1_KfYZbh4ed1qamontvHfnV5AVUFkMd5NzGxTAXqGmN96xmtUHw5YqJMkFwejRs8JbngUgdD44y8zrRszNwTKVjzZ9tJkEJW"
                    ],
                    "compression": "none",
                    "packed_context_free_data": "",
                    "packed_trx": "4bf2535b264b899b8c52000000000100a6823403ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232210000000000ea305500dca79ab1e98e49a08601000000000004535953000000000000"
                }
            ]
        },
        "trx": {
            "expiration": "2018-07-22T02:56:11",
            "ref_block_num": 19238,
            "ref_block_prefix": 1384946569,
            "max_net_usage_words": 0,
            "max_cpu_usage_ms": 0,
            "delay_sec": 0,
            "context_free_actions": [],
            "actions": [
                {
                    "account": "eosio.token",
                    "name": "transfer",
                    "authorization": [
                        {
                            "actor": "eosio",
                            "permission": "active"
                        }
                    ],
                    "data": {
                        "from": "eosio",
                        "to": "dabingguozi",
                        "quantity": "10.0000 SYS",
                        "memo": ""
                    },
                    "hex_data": "0000000000ea305500dca79ab1e98e49a086010000000000045359530000000000"
                }
            ],
            "transaction_extensions": [],
            "signatures": [
                "SIG_K1_KfYZbh4ed1qamontvHfnV5AVUFkMd5NzGxTAXqGmN96xmtUHw5YqJMkFwejRs8JbngUgdD44y8zrRszNwTKVjzZ9tJkEJW"
            ],
            "context_free_data": []
        }
    },
    "block_time": "2018-07-22T02:55:42.000",
    "block_num": 19240,
    "last_irreversible_block": 63969,
    "traces": [
        {
            "receipt": {
                "receiver": "dabingguozi",
                "act_digest": "f8ce7062290be813e6484e50c7c0e3c22a9898e3240bab76f7e11b99c07abe52",
                "global_sequence": 19298,
                "recv_sequence": 5,
                "auth_sequence": [
                    [
                        "eosio",
                        19293
                    ]
                ],
                "code_sequence": 1,
                "abi_sequence": 1
            },
            "act": {
                "account": "eosio.token",
                "name": "transfer",
                "authorization": [
                    {
                        "actor": "eosio",
                        "permission": "active"
                    }
                ],
                "data": {
                    "from": "eosio",
                    "to": "dabingguozi",
                    "quantity": "10.0000 SYS",
                    "memo": ""
                },
                "hex_data": "0000000000ea305500dca79ab1e98e49a086010000000000045359530000000000"
            },
            "elapsed": 6,
            "cpu_usage": 0,
            "console": "",
            "total_cpu_usage": 0,
            "trx_id": "b09395d938e594b838277453cea832ddc5d57ab5e92d8763ea011df9e35d7b34",
            "inline_traces": []
        }
    ]
}

8. history/get_actions(请求actions的信息)

POST:

http://127.0.0.1:8888/v1/history/get_actions

BODY: 其中account_name如果没有在config中filter设置过,response就什么都拿不到

{
  "pos":0,
  "offset":1000,
  "account_name": "dabingguozi"
}

RESPONSE:

{
    "actions": [
        {
            "global_action_seq": 19298,
            "account_action_seq": 0,
            "block_num": 19240,
            "block_time": "2018-07-22T02:55:42.000",
            "action_trace": {
                "receipt": {
                    "receiver": "dabingguozi",
                    "act_digest": "f8ce7062290be813e6484e50c7c0e3c22a9898e3240bab76f7e11b99c07abe52",
                    "global_sequence": 19298,
                    "recv_sequence": 5,
                    "auth_sequence": [
                        [
                            "eosio",
                            19293
                        ]
                    ],
                    "code_sequence": 1,
                    "abi_sequence": 1
                },
                "act": {
                    "account": "eosio.token",
                    "name": "transfer",
                    "authorization": [
                        {
                            "actor": "eosio",
                            "permission": "active"
                        }
                    ],
                    "data": {
                        "from": "eosio",
                        "to": "dabingguozi",
                        "quantity": "10.0000 SYS",
                        "memo": ""
                    },
                    "hex_data": "0000000000ea305500dca79ab1e98e49a086010000000000045359530000000000"
                },
                "elapsed": 6,
                "cpu_usage": 0,
                "console": "",
                "total_cpu_usage": 0,
                "trx_id": "b09395d938e594b838277453cea832ddc5d57ab5e92d8763ea011df9e35d7b34",
                "inline_traces": []
            }
        },
        {
            "global_action_seq": 21095,
            "account_action_seq": 1,
            "block_num": 21034,
            "block_time": "2018-07-22T03:10:39.000",
            "action_trace": {
                "receipt": {
                    "receiver": "dabingguozi",
                    "act_digest": "72ae6a2af84b85d4b4e20190a56904f53afa2a79ab4c47ca2f15874c4c309205",
                    "global_sequence": 21095,
                    "recv_sequence": 6,
                    "auth_sequence": [
                        [
                            "eosio",
                            21090
                        ]
                    ],
                    "code_sequence": 1,
                    "abi_sequence": 1
                },
                "act": {
                    "account": "eosio.token",
                    "name": "transfer",
                    "authorization": [
                        {
                            "actor": "eosio",
                            "permission": "active"
                        }
                    ],
                    "data": {
                        "from": "eosio",
                        "to": "dabingguozi",
                        "quantity": "2.0000 SYS",
                        "memo": ""
                    },
                    "hex_data": "0000000000ea305500dca79ab1e98e49204e000000000000045359530000000000"
                },
                "elapsed": 6,
                "cpu_usage": 0,
                "console": "",
                "total_cpu_usage": 0,
                "trx_id": "e1cafa2561470a0b489a4e2032375a5c88665f75e5172bac7b574cd051079d42",
                "inline_traces": []
            }
        }
    ],
    "last_irreversible_block": 64270
}

致此,一些目前常用的HTTP API,就列在这里了,之后会有进阶版举例其他API

下一篇是时候总结和讨论一下eos的结构了,接连接:

(在编辑。。。)

ps. 因为我没有在插件中设置wallet-api,所以wallet相关的HTTP API就不可用

原文地址:https://www.cnblogs.com/dabingguozi/p/9349262.html

时间: 2024-09-28 15:33:48

EOS小白学习(五)EOS的HTTP API的相关文章

分布式管中窥豹之zookeeper小白学习(五)启动zookeeper仲裁模式

欢迎来到分布式管中窥豹之zookeeper小白学习系列,本系列会记录zookeeper以及分布式系统学习过程中的一些操作和细节,大饼果子非科班出身,如有错误,欢迎指出 本篇将启动zookeeper服务的仲裁模式,三个节点将以不同的端口号在本地被启动 1. 首先我们需要修改一下配置文件 节点1的配置文件z1.cfg tickTime=2000 initLimit=10 syncLimit=5 dataDir=/Users/dabingguozi/Documents/zookeeper/data/z

javascript小白学习指南0---1

引言: 做为一名程序员,都是真心的想把自己的东西分享出来,供大家一起学习探讨,一起提高技能,一起涨工资,呵 这一系列的文章都是关于Javascript 基础的 当然文章当中穿插了些我自己的理解,希望可以帮助一些刚开始的童鞋! 废话不多说我们开始吧! 第一章:Javascript 基本概念 主要内容 数据类型 控制语句 函数 我们先从最简单的数据类型开始吧! 首先请记住javascript 有5种基本数据类型和1种复杂数据类型,至于为什么只有这六种,大家可以去翻翻W3C的资料哈! 五种基本数据类型

【系列】 EOS开发6 创建EOS账户

安装docker 使用命令行创建EOS账户需要有一套EOS开发环境,这里我们使用一个已经安装了EOS套件的docker环境,本文使用Mac系统,关于docker软件的安装可查看Mac docker install 创建EOS账户 启动docker docker run --rm -it eosio/eos:latest /bin/bash 确认eos主网信息 root@7dd4e87a4ac7:/opt/eosio# ./bin/cleos -u http://mainnet.eoswz.com

电脑小白学习软件开发-C#语言基础之循环重点讲解,习题

写代码也要读书,爱全栈,更爱生活.每日更新原创IT编程技术及日常实用视频. 我们的目标是:玩得转服务器Web开发,搞得懂移动端,电脑客户端更是不在话下. 本教程是基础教程,适合任何有志于学习软件开发的人.当然因为技术的连贯性,推荐按照顺序查看. 上次课程:电脑小白自学软件编程-.Net语法基础之循环语句,纯技巧干货 近期,致力于进行C#语言教程的写作.写一系列可以供电脑小白学习软件开发的文章,帮助更多初学者入门学习IT编程. 课程总目录:因头条无法自定义目录,大家关注:“做全栈攻城狮”微信公众号

Beaglebone Back学习五(PWM测试)

PWM测试 参考链接 1 Enable PWM on BeagleBone with Device Tree overlays 2Using PWM on the Beaglebone Black 3 Beaglebone Coding 101: Buttons and PWM 4 Using PWM outputs 5 beaglebone-black-cpp-PWM 6 Enabling PWM Support in the kernel 7 Beaglebone Back学习五(PWM测试

小白学习日记更新:tp5.0

小白学习日记更新 1.首先看开发手册很重要ThinkPHP5.0完全开发手册 2.use think\Db;即可Db::table('')->等一系列操作 3.Db::table('')->find()是找一条记录 Db::table('')->select()是找多条 Db::table('')->limit(3,2)是找第4条,取两条数据 Db::table('')->getLastSql();是输出最后一次语句 4.tp5的严格性,必须判断是否有或者存在

TweenMax动画库学习(五)

目录            TweenMax动画库学习(一)            TweenMax动画库学习(二)            TweenMax动画库学习(三)            TweenMax动画库学习(四)            TweenMax动画库学习(五)  

NodeJS学习五 之网页显示

我们新建一个Server.js. 然后运行cmd 找到server.js 路径.  node server.js 浏览器中输入http://localhost:8888/ 你会发现,网页上出现了 Hello World NodeJS学习五 之网页显示,布布扣,bubuko.com

PHP的学习--使用PhpDocumentor 2生成API文档

官网地址:http://www.phpdoc.org/ 项目地址:https://github.com/phpDocumentor/phpDocumentor2 phpDocumentor 2是一个可以 分析php源代码和注释块并生成文档的程序. 基于phpdocumentor 1和javadoc启发而来,它持续创新的使用了一些新技术和支持php的新特性. phpDocumentor 2的特点: 兼容php5.3,全面支持命名空间和闭包等. 识别支持任何tag,以及一些追加的 (比如 @link