一些EOS的RPC API接口示例

一些EOS的RPC API的示例,大家可以参考一下。

1. GET /v1/chain/get_info

响应:

{
    "server_version": "cd979827",
    "head_block_num": 110572,
    "last_irreversible_block_num": 110571,
    "last_irreversible_block_id": "0001afeb67d2503b93e64f2e34631691989bad886dcc85777995df4aece774fc",
    "head_block_id": "0001afec64eec39550853d2e032633b1c4f987ad22f343e76cafbf8f9e6e36b4",
    "head_block_time": "2018-05-25T13:44:42",
    "head_block_producer": "eosio",
    "virtual_block_cpu_limit": "104857600000",
    "virtual_block_net_limit": 1048576000,
    "block_cpu_limit": 104857500,
    "block_net_limit": 1048576
}

2. POST /v1/chain/abi_json_to_bin

请求:

{  
   "code":"eosio.token",
   "action":"transfer",
   "authorization":[  
      {  
         "actor":"tester",
         "permission":"active"
      }
   ],
   "args":{  
      "from":"tester",
      "to":"user",
      "quantity":"1.0000 EOS",
      "memo":"transfer"
   }
}

响应:

{
    "binargs": "000000005c95b1ca00000000007015d6102700000000000004454f5300000000087472616e73666572"
}

3. POST /v1/chain/get_block

请求:

{"block_num_or_id":100}

响应:

{  
   "timestamp":"2018-05-24T09:12:56.000",
   "producer":"eosio",
   "confirmed":0,
   "previous":"0000006328fadd5333bfb80ecd21646448d3858b40c0816b01b986318455943f",
   "transaction_mroot":"0000000000000000000000000000000000000000000000000000000000000000",
   "action_mroot":"4a60d816edd825751b3e364fe56e6d578f9f30852c00546117167eb5f954d540",
   "schedule_version":0,
   "new_producers":null,
   "header_extensions":[  

   ],
   "producer_signature":"SIG_K1_KiC8vBhqSArKqMS82RByKsepYagHEoa4wAi6AdMSntCaFqhZhg96Q3FCfgp9AGVhqCxnzi1LA4tA4KXrEPZx9ToWEpAZW9",
   "transactions":[  

   ],
   "block_extensions":[  

   ],
   "id":"00000064c400d036822f7d2e2fee71c47b645a07fbcb6c0491cd69d3d25dc4f8",
   "block_num":100,
   "ref_block_prefix":779956098
}

4. POST /v1/chain/get_account

请求:

{"account_name":tester}

响应:

{  
   "account_name":"tester",
   "privileged":false,
   "last_code_update":"1970-01-01T00:00:00.000",
   "created":"2018-05-24T09:14:09.000",
   "ram_quota":-1,
   "net_weight":-1,
   "cpu_weight":-1,
   "net_limit":{  
      "used":-1,
      "available":-1,
      "max":-1
   },
   "cpu_limit":{  
      "used":-1,
      "available":-1,
      "max":-1
   },
   "ram_usage":2852,
   "permissions":[  
      {  
         "perm_name":"active",
         "parent":"owner",
         "required_auth":{  
            "threshold":1,
            "keys":[  
               {  
                  "key":"EOS5T6V7jXaxweNW5eEA8EmHx6dBVEhrKesPRQWxKdqCazmphJJNK",
                  "weight":1
               }
            ],
            "accounts":[  

            ],
            "waits":[  

            ]
         }
      },
      {  
         "perm_name":"owner",
         "parent":"",
         "required_auth":{  
            "threshold":1,
            "keys":[  
               {  
                  "key":"EOS5T6V7jXaxweNW5eEA8EmHx6dBVEhrKesPRQWxKdqCazmphJJNK",
                  "weight":1
               }
            ],
            "accounts":[  

            ],
            "waits":[  

            ]
         }
      }
   ],
   "total_resources":null,
   "delegated_bandwidth":null,
   "voter_info":null
}

5. POST /v1/chain/get_currency_balance

请求:

{  
   "account":"tester",
   "code":"eosio.token",
   "symbol":"EOS"
}

响应:

[
    "10017.6146 EOS"
]

6. POST /v1/chain/abi_bin_to_json

请求:

{  
   "code":"eosio.token",
   "action":"transfer",
   "binargs":"000000005c95b1ca00000000007015d6102700000000000004454f5300000000087472616e73666572"
}

响应:

{  
   "args":{  
      "from":"tester",
      "to":"user",
      "quantity":"1.0000 EOS",
      "memo":"transfer"
   },
   "required_scope":[  

   ],
   "required_auth":[  

   ]
}

7. POST /v1/chain/get_table_rows

请求:

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

响应:

{
    "rows": [
        {
            "balance": "10017.6146 EOS"
        }
    ],
    "more": false
}

8. POST /v1/history/get_actions

请求:

{  
   "account_name":"tester",
   "pos":1,
   "offset":1
}

响应:

{  
   "actions":[  
      {  
         "global_action_seq":1446,
         "account_action_seq":1,
         "block_num":1427,
         "block_time":"2018-05-24T09:23:59.500",
         "action_trace":{  
            "receipt":{  
               "receiver":"tester",
               "act_digest":"563edab5729e7548f3ad704e2df5c1044eddbfe4e4a81b91d700466512ee0f37",
               "global_sequence":1446,
               "recv_sequence":2,
               "auth_sequence":[  
                  [  
                     "user",
                     3
                  ]
               ],
               "code_sequence":1,
               "abi_sequence":1
            },
            "act":{  
               "account":"eosio.token",
               "name":"transfer",
               "authorization":[  
                  {  
                     "actor":"user",
                     "permission":"active"
                  }
               ],
               "data":{  
                  "from":"user",
                  "to":"tester",
                  "quantity":"1.2340 EOS",
                  "memo":"m"
               },
               "hex_data":"00000000007015d6000000005c95b1ca343000000000000004454f5300000000016d"
            },
            "elapsed":4,
            "cpu_usage":0,
            "console":"",
            "total_cpu_usage":0,
            "trx_id":"f90bbc85b48f19d9d771a1a765fc15d2f2a166a24bbf2d257a84a977408e19c1",
            "inline_traces":[  

            ]
         }
      },
      {  
         "global_action_seq":1927,
         "account_action_seq":2,
         "block_num":1901,
         "block_time":"2018-05-24T09:27:56.500",
         "action_trace":{  
            "receipt":{  
               "receiver":"tester",
               "act_digest":"442eb822d644686d33de3741cdf0e499e437aa07c29fabb430c46c6c2f7791eb",
               "global_sequence":1927,
               "recv_sequence":3,
               "auth_sequence":[  
                  [  
                     "kris",
                     3
                  ]
               ],
               "code_sequence":1,
               "abi_sequence":1
            },
            "act":{  
               "account":"eosio.token",
               "name":"transfer",
               "authorization":[  
                  {  
                     "actor":"kris",
                     "permission":"active"
                  }
               ],
               "data":{  
                  "from":"kris",
                  "to":"tester",
                  "quantity":"1.2340 EOS",
                  "memo":"m"
               },
               "hex_data":"000000000080dd85000000005c95b1ca343000000000000004454f5300000000016d"
            },
            "elapsed":3,
            "cpu_usage":0,
            "console":"",
            "total_cpu_usage":0,
            "trx_id":"7821509b2a296d1626d0ec790e9d1e8d548a73ee86c11ef68e521429f637a3df",
            "inline_traces":[  

            ]
         }
      }
   ],
   "last_irreversible_block":115138
}

9. POST /v1/history/get_transaction

请求:

{"id":"fff5a929cb28aca17f8038c823db137ff1978c145ad9a94a74ad80f68ff8f9a1"}

响应:

{  
   "id":"fff5a929cb28aca17f8038c823db137ff1978c145ad9a94a74ad80f68ff8f9a1",
   "trx":{  
      "receipt":{  
         "status":"executed",
         "cpu_usage_us":732,
         "net_usage_words":28,
         "trx":[  
            1,
            {  
               "signatures":[  
                  "SIG_K1_Kco3t6gd92yxpU2qL4Gv6BAzNQJ8sk7iTRAUDUx7Tm9wzEAPH1R7ZzPZduoHeycZpgxa9oqqnsVqwhWh4qeWtkryjK5Ht8"
               ],
               "compression":"none",
               "packed_context_free_data":"",
               "packed_trx":"13f4075b0371c3a932ff000000000100a6823403ea3055000000572d3ccdcd01000000005c95b1ca00000000a8ed323229000000005c95b1ca000000000080dd85be2f00000000000004454f5300000000087472616e7366657200"
            }
         ]
      },
      "trx":{  
         "expiration":"2018-05-25T11:31:31",
         "ref_block_num":28931,
         "ref_block_prefix":4281510339,
         "max_net_usage_words":0,
         "max_cpu_usage_ms":0,
         "delay_sec":0,
         "context_free_actions":[  

         ],
         "actions":[  
            {  
               "account":"eosio.token",
               "name":"transfer",
               "authorization":[  
                  {  
                     "actor":"tester",
                     "permission":"active"
                  }
               ],
               "data":{  
                  "from":"tester",
                  "to":"kris",
                  "quantity":"1.2222 EOS",
                  "memo":"transfer"
               },
               "hex_data":"000000005c95b1ca000000000080dd85be2f00000000000004454f5300000000087472616e73666572"
            }
         ],
         "transaction_extensions":[  

         ],
         "signatures":[  
            "SIG_K1_Kco3t6gd92yxpU2qL4Gv6BAzNQJ8sk7iTRAUDUx7Tm9wzEAPH1R7ZzPZduoHeycZpgxa9oqqnsVqwhWh4qeWtkryjK5Ht8"
         ],
         "context_free_data":[  

         ]
      }
   },
   "block_time":"2018-05-25T11:30:32.500",
   "block_num":94472,
   "last_irreversible_block":115438,
   "traces":[  
      {  
         "receipt":{  
            "receiver":"eosio.token",
            "act_digest":"3c4745436bdcf883032f9a917ac961e740d5ebbdd8f54b3966bdbf6c679006af",
            "global_sequence":94559,
            "recv_sequence":30,
            "auth_sequence":[  
               [  
                  "tester",
                  22
               ]
            ],
            "code_sequence":1,
            "abi_sequence":1
         },
         "act":{  
            "account":"eosio.token",
            "name":"transfer",
            "authorization":[  
               {  
                  "actor":"tester",
                  "permission":"active"
               }
            ],
            "data":{  
               "from":"tester",
               "to":"kris",
               "quantity":"1.2222 EOS",
               "memo":"transfer"
            },
            "hex_data":"000000005c95b1ca000000000080dd85be2f00000000000004454f5300000000087472616e73666572"
         },
         "elapsed":540,
         "cpu_usage":0,
         "console":"",
         "total_cpu_usage":0,
         "trx_id":"fff5a929cb28aca17f8038c823db137ff1978c145ad9a94a74ad80f68ff8f9a1",
         "inline_traces":[  
            {  
               "receipt":{  
                  "receiver":"tester",
                  "act_digest":"3c4745436bdcf883032f9a917ac961e740d5ebbdd8f54b3966bdbf6c679006af",
                  "global_sequence":94560,
                  "recv_sequence":24,
                  "auth_sequence":[  
                     [  
                        "tester",
                        23
                     ]
                  ],
                  "code_sequence":1,
                  "abi_sequence":1
               },
               "act":{  
                  "account":"eosio.token",
                  "name":"transfer",
                  "authorization":[  
                     {  
                        "actor":"tester",
                        "permission":"active"
                     }
                  ],
                  "data":{  
                     "from":"tester",
                     "to":"kris",
                     "quantity":"1.2222 EOS",
                     "memo":"transfer"
                  },
                  "hex_data":"000000005c95b1ca000000000080dd85be2f00000000000004454f5300000000087472616e73666572"
               },
               "elapsed":4,
               "cpu_usage":0,
               "console":"",
               "total_cpu_usage":0,
               "trx_id":"fff5a929cb28aca17f8038c823db137ff1978c145ad9a94a74ad80f68ff8f9a1",
               "inline_traces":[  

               ]
            },
            {  
               "receipt":{  
                  "receiver":"kris",
                  "act_digest":"3c4745436bdcf883032f9a917ac961e740d5ebbdd8f54b3966bdbf6c679006af",
                  "global_sequence":94561,
                  "recv_sequence":23,
                  "auth_sequence":[  
                     [  
                        "tester",
                        24
                     ]
                  ],
                  "code_sequence":1,
                  "abi_sequence":1
               },
               "act":{  
                  "account":"eosio.token",
                  "name":"transfer",
                  "authorization":[  
                     {  
                        "actor":"tester",
                        "permission":"active"
                     }
                  ],
                  "data":{  
                     "from":"tester",
                     "to":"kris",
                     "quantity":"1.2222 EOS",
                     "memo":"transfer"
                  },
                  "hex_data":"000000005c95b1ca000000000080dd85be2f00000000000004454f5300000000087472616e73666572"
               },
               "elapsed":4,
               "cpu_usage":0,
               "console":"",
               "total_cpu_usage":0,
               "trx_id":"fff5a929cb28aca17f8038c823db137ff1978c145ad9a94a74ad80f68ff8f9a1",
               "inline_traces":[  

               ]
            }
         ]
      },
      {  
         "receipt":{  
            "receiver":"tester",
            "act_digest":"3c4745436bdcf883032f9a917ac961e740d5ebbdd8f54b3966bdbf6c679006af",
            "global_sequence":94560,
            "recv_sequence":24,
            "auth_sequence":[  
               [  
                  "tester",
                  23
               ]
            ],
            "code_sequence":1,
            "abi_sequence":1
         },
         "act":{  
            "account":"eosio.token",
            "name":"transfer",
            "authorization":[  
               {  
                  "actor":"tester",
                  "permission":"active"
               }
            ],
            "data":{  
               "from":"tester",
               "to":"kris",
               "quantity":"1.2222 EOS",
               "memo":"transfer"
            },
            "hex_data":"000000005c95b1ca000000000080dd85be2f00000000000004454f5300000000087472616e73666572"
         },
         "elapsed":4,
         "cpu_usage":0,
         "console":"",
         "total_cpu_usage":0,
         "trx_id":"fff5a929cb28aca17f8038c823db137ff1978c145ad9a94a74ad80f68ff8f9a1",
         "inline_traces":[  

         ]
      },
      {  
         "receipt":{  
            "receiver":"kris",
            "act_digest":"3c4745436bdcf883032f9a917ac961e740d5ebbdd8f54b3966bdbf6c679006af",
            "global_sequence":94561,
            "recv_sequence":23,
            "auth_sequence":[  
               [  
                  "tester",
                  24
               ]
            ],
            "code_sequence":1,
            "abi_sequence":1
         },
         "act":{  
            "account":"eosio.token",
            "name":"transfer",
            "authorization":[  
               {  
                  "actor":"tester",
                  "permission":"active"
               }
            ],
            "data":{  
               "from":"tester",
               "to":"kris",
               "quantity":"1.2222 EOS",
               "memo":"transfer"
            },
            "hex_data":"000000005c95b1ca000000000080dd85be2f00000000000004454f5300000000087472616e73666572"
         },
         "elapsed":4,
         "cpu_usage":0,
         "console":"",
         "total_cpu_usage":0,
         "trx_id":"fff5a929cb28aca17f8038c823db137ff1978c145ad9a94a74ad80f68ff8f9a1",
         "inline_traces":[  

         ]
      }
   ]
}

======================================================================

分享一些比特币、以太坊、EOS等区块链相关的交互式在线编程实战教程:

  • EOS入门教程,本课程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用各知识点完成一个便签DApp的开发。
  • 深入浅出玩转EOS钱包开发,本课程以手机EOS钱包的完整开发过程为主线,深入学习EOS区块链应用开发,课程内容即涵盖账户、计算资源、智能合约、动作与交易等EOS区块链的核心概念,同时也讲解如何使用eosjs和eosjs-ecc开发包访问EOS区块链,以及如何在React前端应用中集成对EOS区块链的支持。课程内容深入浅出,非常适合前端工程师深入学习EOS区块链应用开发。
  • java比特币开发教程,本课程面向初学者,内容即涵盖比特币的核心概念,例如区块链存储、去中心化共识机制、密钥与脚本、交易与UTXO等,同时也详细讲解如何在Java代码中集成比特币支持功能,例如创建地址、管理钱包、构造裸交易等,是Java工程师不可多得的比特币开发学习课程。
  • php比特币开发教程,本课程面向初学者,内容即涵盖比特币的核心概念,例如区块链存储、去中心化共识机制、密钥与脚本、交易与UTXO等,同时也详细讲解如何在Php代码中集成比特币支持功能,例如创建地址、管理钱包、构造裸交易等,是Php工程师不可多得的比特币开发学习课程。
  • c#比特币开发教程,本课程面向初学者,内容即涵盖比特币的核心概念,例如区块链存储、去中心化共识机制、密钥与脚本、交易与UTXO等,同时也详细讲解如何在C#代码中集成比特币支持功能,例如创建地址、管理钱包、构造裸交易等,是C#工程师不可多得的比特币开发学习课程。
  • java以太坊开发教程,主要是针对java和android程序员进行区块链以太坊开发的web3j详解。
  • python以太坊,主要是针对python工程师使用web3.py进行区块链以太坊开发的详解。
  • php以太坊,主要是介绍使用php进行智能合约开发交互,进行账号创建、交易、转账、代币开发以及过滤器和交易等内容。
  • 以太坊入门教程,主要介绍智能合约与dapp应用开发,适合入门。
  • 以太坊开发进阶教程,主要是介绍使用node.js、mongodb、区块链、ipfs实现去中心化电商DApp实战,适合进阶。
  • ERC721以太坊通证实战,课程以一个数字艺术品创作与分享DApp的实战开发为主线,深入讲解以太坊非同质化通证的概念、标准与开发方案。内容包含ERC-721标准的自主实现,讲解OpenZeppelin合约代码库二次开发,实战项目采用Truffle,IPFS,实现了通证以及去中心化的通证交易所。
  • C#以太坊,主要讲解如何使用C#开发基于.Net的以太坊应用,包括账户管理、状态与交易、智能合约开发与交互、过滤器和交易等。
  • Hyperledger Fabric 区块链开发详解,本课程面向初学者,内容即包含Hyperledger Fabric的身份证书与MSP服务、权限策略、通道配置与启动、链码通信接口等核心概念,也包含Fabric网络设计、nodejs链码与应用开发的操作实践,是Nodejs工程师学习Fabric区块链开发的最佳选择。
  • Hyperledger Fabric java 区块链开发详解,课程面向初学者,内容即包含Hyperledger Fabric的身份证书与MSP服务、权限策略、频道配置与启动、链码通信接口等核心概念,也包含Fabric网络设计、java链码与应用开发的操作实践,是java工程师学习Fabric区块链开发的最佳选择。
  • tendermint区块链开发详解,本课程适合希望使用tendermint进行区块链开发的工程师,课程内容即包括tendermint应用开发模型中的核心概念,例如ABCI接口、默克尔树、多版本状态库等,也包括代币发行等丰富的实操代码,是go语言工程师快速入门区块链开发的最佳选择。

汇智网原创翻译,转载请标明出处。这里是一些EOS的RPC API接口示例

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容