使用RPC的接口创建账户同时购买内存并为其抵押CPU和NET资源

1. 前言

前面我们使用RPC API完成了转账。这篇文章继续使用RPC API来创建账号。在EOS中,这些行为都叫做transaction,更本质一点说是一笔transaction中的action。在转账的transaction中,只有一个action,它调用eosio.token合约中的transfer方法。而我们知道,创建账户时需要为账户购买和抵押资源。其实只需要为新账户购买内存资源,否则会创建失败。而抵押CPU和NET资源可以不在创建账户时同时进行。但一般来说,为了使新账户可以操作一些事情,例如转账,都会在创建时同时为其抵押CPU和NET资源。这时就会出现一笔transaction中包含多个action的情况。本篇文章演示了创建账户时存在多个action的情况。

我们需要使用eosio合约来完成下面的步骤。该合约名为eosio.system,位于eos/contracts中。

和之前一样,我们在测试网络http://jungle.cryptolions.io:18888上,使用Postman对API进行测试。

2. 准备步骤

2.1 生成两个公钥

EOS7L9pb38iiqvnrsgzPVqxHnxHmxxeX6bCNbGkehh1hCScEc3ya2
EOS7eZtj6yzESob8Y3vjYwBnM25uZ3HnQa922FmcR3MZuozdiRCEj

2.2 准备钱包和钱包服务

我们使用账户testnetyy111来创建账户

打开钱包服务keosd,这次我们指定其服务IP为8899

yuyangdeMacBook-Pro:keosd yuyang$ keosd --http-server-address=localhost:8899

通过调用钱包的RPC API,我们打开并解锁钱包,保证钱包中有testnetyy111active权限的公私钥。这部分不明白可以先看前面的文章

3. 大致流程

大致流程和之前一样,只是需要多生成几个bin字符串:

  1. abi_json_to_bin_newaccount 将创建账户信息由json格式序列化为bin格式字符串

  2. abi_json_to_bin_buyram 将购买内存信息由json格式序列化为bin格式字符串

  3. abi_json_to_bin_delegatebw 将购买抵押资源信息由json格式序列化为bin格式字符串

  4. get_info 获取当前最新的区块编号

  5. get_block 根据区块编号获取区块详情

  6. get_required_keys(可省略) 传入当前拥有的公钥、bin字符串,区块等信息,筛选出签署交易需要的公钥

  7. sign_transaction 传入上面获取的相关参数,通过钱包中私钥对交易进行签署

  8. push_transaction 根据第七步获取的签名信息,将交易提交到区块链上

4. 详细流程

4.1 生成创建账户的bin字符串

  1. 调用eosio合约的newaccount方法

  2. 传入创建者账户名称和新账户名称

  3. 设置两个权限的公钥

api
http://jungle.cryptolions.io:18888/v1/chain/abi_json_to_bin

params
{
  "code": "eosio",
  "action": "newaccount",
  "args": {
    "creator": "testnetyy111",
    "name": "testnetyy222",
    "owner": {
      "threshold": 1,
      "keys": [
        {
          "key": "EOS7L9pb38iiqvnrsgzPVqxHnxHmxxeX6bCNbGkehh1hCScEc3ya2",
          "weight": 1
        }
      ],
      "accounts": [],
      "waits": []
    },
    "active": {
      "threshold": 1,
      "keys": [
        {
          "key": "EOS7eZtj6yzESob8Y3vjYwBnM25uZ3HnQa922FmcR3MZuozdiRCEj",
          "weight": 1
        }
      ],
      "accounts": [],
      "waits": []
    }
  }
}

return
{
    "binargs": "1042f03eab99b1ca2084f03eab99b1ca0100000001000341a9e89b10df5fb0b425e294e32c6208fc3c97becd61f111b351274cd30cd92801000000010000000100036b7a2e4feec43f2160927f34a046914d9aba7625a492597a0f888d2aaec225ba01000000"
}

4.2 生成购买内存的bin字符串

  1. 调用eosio合约的buyram方法

  2. 传入购买者账户名称和接收者账户名称

  3. 设置购买的金额

api
http://jungle.cryptolions.io:18888/v1/chain/abi_json_to_bin

params
{
   "code": "eosio",
   "action": "buyram",
   "args": {
        "payer": "testnetyy111",
        "receiver": "testnetyy222",
        "quant": "50.0000 EOS",
    }
 }

return
{
    "binargs": "1042f03eab99b1ca2084f03eab99b1ca20a107000000000004454f5300000000"
}

4.3 生成购买抵押资源的bin字符串

  1. 调用eosio合约的delegatebw方法

  2. 传入购买者账户名称和接收者账户名称

  3. 设置购买的资源类型和金额

  4. transfer后面讲抵押和赎回资源时再详细讲

api
http://jungle.cryptolions.io:18888/v1/chain/abi_json_to_bin

params
{
    "code": "eosio",
    "action": "delegatebw",
    "args": {
        "from": "testnetyy111",
        "receiver": "testnetyy222",
        "stake_net_quantity": "20.0000 EOS",
        "stake_cpu_quantity": "20.0000 EOS",
        "transfer": 0,
    }
}

return
{
    "binargs": "1042f03eab99b1ca2084f03eab99b1ca400d03000000000004454f5300000000400d03000000000004454f530000000000"
}

4.4 获取当前最新的区块号

api
http://jungle.cryptolions.io:18888/v1/chain/get_info

params
无

return
{
    "server_version": "08819aae",
    "chain_id": "038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca",
    "head_block_num": 13995827,
    "last_irreversible_block_num": 13995503,
    "last_irreversible_block_id": "00d58defe56615c06fa05fc61639f64b3d72005ed2baff6035c82a8e83ac4b17",
    "head_block_id": "00d58f3333165a76a86f38c98ca50ece1a649a9556276d16f523192b4b5d94c4",
    "head_block_time": "2018-09-12T09:15:35.000",
    "head_block_producer": "eosldndevbp2",
    "virtual_block_cpu_limit": 200000000,
    "virtual_block_net_limit": 1048576000,
    "block_cpu_limit": 199900,
    "block_net_limit": 1048576,
    "server_version_string": "v1.2.5-dirty"
}

获取到区块号"head_block_num": 13995827

4.5 获取当前区块详情

api
http://jungle.cryptolions.io:18888/v1/chain/get_block

params
{"block_num_or_id":"13995827"}

return
{
    "timestamp": "2018-09-12T09:15:35.000",
    "producer": "eosldndevbp2",
    "confirmed": 0,
    "previous": "00d58f32a420c7957547e410d65bca6c0e16d6a32e0c0cfbd428f6a46ca67bfe",
    "transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000",
    "action_mroot": "c71076b9b5100ccd68de98a8b0175036ab6ef26b1d8e2194fa0bf0ff95e4f702",
    "schedule_version": 222,
    "new_producers": null,
    "header_extensions": [],
    "producer_signature": "SIG_K1_KhwPrVWsyVsNL7phXXv9Q1Wf9fFCvx9VZFaLUqBbnn1EJF2M3J9ekCuYwQaDsU9shMpLgPYcNU79dSicLNeza5DmjH8z7A",
    "transactions": [],
    "block_extensions": [],
    "id": "00d58f3333165a76a86f38c98ca50ece1a649a9556276d16f523192b4b5d94c4",
    "block_num": 13995827,
    "ref_block_prefix": 3375919016
}

获取到"timestamp": "2018-09-12T09:15:35.000""ref_block_prefix": 3375919016

4.6 签署交易

  • 这笔交易中有三个action,将上面生成的bin字符串按name填入到data

  • 过期时间我这里加了20分钟。2018-09-12T09:15:35.000 ==> 2018-09-12T09:35:35.000

  • 注意这里钱包服务的端口为8899

api
http://127.0.0.1:8899/v1/wallet/sign_transaction

params
[{
        "ref_block_num": 13995827,
        "ref_block_prefix": 3375919016,
        "expiration": "2018-09-12T09:35:35.000",
        "actions": [{
            "account": "eosio",
            "name": "newaccount",
            "authorization": [{
                "actor": "testnetyy111",
                "permission": "active"
            }],
            "data": "1042f03eab99b1ca2084f03eab99b1ca0100000001000341a9e89b10df5fb0b425e294e32c6208fc3c97becd61f111b351274cd30cd92801000000010000000100036b7a2e4feec43f2160927f34a046914d9aba7625a492597a0f888d2aaec225ba01000000"
        },
        {
            "account": "eosio",
            "name": "buyram",
            "authorization": [{
                "actor": "testnetyy111",
                "permission": "active"
            }],
            "data": "1042f03eab99b1ca2084f03eab99b1ca20a107000000000004454f5300000000"
        },
        {
            "account": "eosio",
            "name": "delegatebw",
            "authorization": [{
                "actor": "testnetyy111",
                "permission": "active"
            }],
            "data": "1042f03eab99b1ca2084f03eab99b1ca400d03000000000004454f5300000000400d03000000000004454f530000000000"
        }],
        "signatures": []
    },
    ["EOS6Z7mUQeFC2cQTT3xMyZh2wsLQoHih1bTMgRhr3dbichprTi7Rc"], "038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca"
]

return
{
    "expiration": "2018-09-12T09:35:35",
    "ref_block_num": 36659,
    "ref_block_prefix": 3375919016,
    "max_net_usage_words": 0,
    "max_cpu_usage_ms": 0,
    "delay_sec": 0,
    "context_free_actions": [],
    "actions": [
        {
            "account": "eosio",
            "name": "newaccount",
            "authorization": [
                {
                    "actor": "testnetyy111",
                    "permission": "active"
                }
            ],
            "data": "1042f03eab99b1ca2084f03eab99b1ca0100000001000341a9e89b10df5fb0b425e294e32c6208fc3c97becd61f111b351274cd30cd92801000000010000000100036b7a2e4feec43f2160927f34a046914d9aba7625a492597a0f888d2aaec225ba01000000"
        },
        {
            "account": "eosio",
            "name": "buyram",
            "authorization": [
                {
                    "actor": "testnetyy111",
                    "permission": "active"
                }
            ],
            "data": "1042f03eab99b1ca2084f03eab99b1ca20a107000000000004454f5300000000"
        },
        {
            "account": "eosio",
            "name": "delegatebw",
            "authorization": [
                {
                    "actor": "testnetyy111",
                    "permission": "active"
                }
            ],
            "data": "1042f03eab99b1ca2084f03eab99b1ca400d03000000000004454f5300000000400d03000000000004454f530000000000"
        }
    ],
    "transaction_extensions": [],
    "signatures": [
        "SIG_K1_Kdux2Y4uBQnTHuEChMcgVUSpxPMRZaMKjnFu6PoprBx1Lnx8k2bLP2k31VtK9V1YuCjznAVqVEMMeTixgZyYa3ELMboqYV"
    ],
    "context_free_data": []
}

获取到signatures

4.7 提交交易

api
http://jungle.cryptolions.io:18888/v1/chain/push_transaction

params
{
  "compression": "none",
  "transaction": {
    "expiration": "2018-09-12T09:35:35.000",
    "ref_block_num": 13995827,
    "ref_block_prefix": 3375919016,
    "context_free_actions": [],
    "actions": [
        {
            "account": "eosio",
            "name": "newaccount",
            "authorization": [
                {
                    "actor": "testnetyy111",
                    "permission": "active"
                }
            ],
            "data": "1042f03eab99b1ca2084f03eab99b1ca0100000001000341a9e89b10df5fb0b425e294e32c6208fc3c97becd61f111b351274cd30cd92801000000010000000100036b7a2e4feec43f2160927f34a046914d9aba7625a492597a0f888d2aaec225ba01000000"
        },
        {
            "account": "eosio",
            "name": "buyram",
            "authorization": [
                {
                    "actor": "testnetyy111",
                    "permission": "active"
                }
            ],
            "data": "1042f03eab99b1ca2084f03eab99b1ca20a107000000000004454f5300000000"
        },
        {
            "account": "eosio",
            "name": "delegatebw",
            "authorization": [
                {
                    "actor": "testnetyy111",
                    "permission": "active"
                }
            ],
            "data": "1042f03eab99b1ca2084f03eab99b1ca400d03000000000004454f5300000000400d03000000000004454f530000000000"
        }
    ],
    "transaction_extensions": []
  },
  "signatures": [
        "SIG_K1_Kdux2Y4uBQnTHuEChMcgVUSpxPMRZaMKjnFu6PoprBx1Lnx8k2bLP2k31VtK9V1YuCjznAVqVEMMeTixgZyYa3ELMboqYV"
   ]
}

return
{
    "transaction_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
    "processed": {
        "id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
        "receipt": {
            "status": "executed",
            "cpu_usage_us": 5966,
            "net_usage_words": 43
        },
        "elapsed": 5966,
        "net_usage": 344,
        "scheduled": false,
        "action_traces": [
            {
                "receipt": {
                    "receiver": "eosio",
                    "act_digest": "3c4d74c9634ac8adb4efe534575de240c6bd0c5571e1569fbb61bdbc24fda1f7",
                    "global_sequence": 33340943,
                    "recv_sequence": 15451045,
                    "auth_sequence": [
                        [
                            "testnetyy111",
                            54
                        ]
                    ],
                    "code_sequence": 11,
                    "abi_sequence": 12
                },
                "act": {
                    "account": "eosio",
                    "name": "newaccount",
                    "authorization": [
                        {
                            "actor": "testnetyy111",
                            "permission": "active"
                        }
                    ],
                    "data": {
                        "creator": "testnetyy111",
                        "name": "testnetyy222",
                        "owner": {
                            "threshold": 1,
                            "keys": [
                                {
                                    "key": "EOS7L9pb38iiqvnrsgzPVqxHnxHmxxeX6bCNbGkehh1hCScEc3ya2",
                                    "weight": 1
                                }
                            ],
                            "accounts": [],
                            "waits": []
                        },
                        "active": {
                            "threshold": 1,
                            "keys": [
                                {
                                    "key": "EOS7eZtj6yzESob8Y3vjYwBnM25uZ3HnQa922FmcR3MZuozdiRCEj",
                                    "weight": 1
                                }
                            ],
                            "accounts": [],
                            "waits": []
                        }
                    },
                    "hex_data": "1042f03eab99b1ca2084f03eab99b1ca0100000001000341a9e89b10df5fb0b425e294e32c6208fc3c97becd61f111b351274cd30cd92801000000010000000100036b7a2e4feec43f2160927f34a046914d9aba7625a492597a0f888d2aaec225ba01000000"
                },
                "elapsed": 1112,
                "cpu_usage": 0,
                "console": "",
                "total_cpu_usage": 0,
                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                "inline_traces": []
            },
            {
                "receipt": {
                    "receiver": "eosio",
                    "act_digest": "a7884494c409371fcfa5df12aad8a061906416e687ab6aa4f58fca8be5d88035",
                    "global_sequence": 33340944,
                    "recv_sequence": 15451046,
                    "auth_sequence": [
                        [
                            "testnetyy111",
                            55
                        ]
                    ],
                    "code_sequence": 11,
                    "abi_sequence": 12
                },
                "act": {
                    "account": "eosio",
                    "name": "buyram",
                    "authorization": [
                        {
                            "actor": "testnetyy111",
                            "permission": "active"
                        }
                    ],
                    "data": {
                        "payer": "testnetyy111",
                        "receiver": "testnetyy222",
                        "quant": "50.0000 EOS"
                    },
                    "hex_data": "1042f03eab99b1ca2084f03eab99b1ca20a107000000000004454f5300000000"
                },
                "elapsed": 1457,
                "cpu_usage": 0,
                "console": "",
                "total_cpu_usage": 0,
                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                "inline_traces": [
                    {
                        "receipt": {
                            "receiver": "eosio.token",
                            "act_digest": "3002817afe2f79146cff845d5a633c20b4481676a9a058414d9e5ce0d301fd8d",
                            "global_sequence": 33340945,
                            "recv_sequence": 1726107,
                            "auth_sequence": [
                                [
                                    "eosio.ram",
                                    240361
                                ],
                                [
                                    "testnetyy111",
                                    56
                                ]
                            ],
                            "code_sequence": 3,
                            "abi_sequence": 3
                        },
                        "act": {
                            "account": "eosio.token",
                            "name": "transfer",
                            "authorization": [
                                {
                                    "actor": "testnetyy111",
                                    "permission": "active"
                                },
                                {
                                    "actor": "eosio.ram",
                                    "permission": "active"
                                }
                            ],
                            "data": {
                                "from": "testnetyy111",
                                "to": "eosio.ram",
                                "quantity": "49.7500 EOS",
                                "memo": "buy ram"
                            },
                            "hex_data": "1042f03eab99b1ca000090e602ea30555c9707000000000004454f5300000000076275792072616d"
                        },
                        "elapsed": 522,
                        "cpu_usage": 0,
                        "console": "",
                        "total_cpu_usage": 0,
                        "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                        "inline_traces": [
                            {
                                "receipt": {
                                    "receiver": "testnetyy111",
                                    "act_digest": "3002817afe2f79146cff845d5a633c20b4481676a9a058414d9e5ce0d301fd8d",
                                    "global_sequence": 33340946,
                                    "recv_sequence": 21,
                                    "auth_sequence": [
                                        [
                                            "eosio.ram",
                                            240362
                                        ],
                                        [
                                            "testnetyy111",
                                            57
                                        ]
                                    ],
                                    "code_sequence": 3,
                                    "abi_sequence": 3
                                },
                                "act": {
                                    "account": "eosio.token",
                                    "name": "transfer",
                                    "authorization": [
                                        {
                                            "actor": "testnetyy111",
                                            "permission": "active"
                                        },
                                        {
                                            "actor": "eosio.ram",
                                            "permission": "active"
                                        }
                                    ],
                                    "data": {
                                        "from": "testnetyy111",
                                        "to": "eosio.ram",
                                        "quantity": "49.7500 EOS",
                                        "memo": "buy ram"
                                    },
                                    "hex_data": "1042f03eab99b1ca000090e602ea30555c9707000000000004454f5300000000076275792072616d"
                                },
                                "elapsed": 64,
                                "cpu_usage": 0,
                                "console": "",
                                "total_cpu_usage": 0,
                                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                                "inline_traces": []
                            },
                            {
                                "receipt": {
                                    "receiver": "eosio.ram",
                                    "act_digest": "3002817afe2f79146cff845d5a633c20b4481676a9a058414d9e5ce0d301fd8d",
                                    "global_sequence": 33340947,
                                    "recv_sequence": 267887,
                                    "auth_sequence": [
                                        [
                                            "eosio.ram",
                                            240363
                                        ],
                                        [
                                            "testnetyy111",
                                            58
                                        ]
                                    ],
                                    "code_sequence": 3,
                                    "abi_sequence": 3
                                },
                                "act": {
                                    "account": "eosio.token",
                                    "name": "transfer",
                                    "authorization": [
                                        {
                                            "actor": "testnetyy111",
                                            "permission": "active"
                                        },
                                        {
                                            "actor": "eosio.ram",
                                            "permission": "active"
                                        }
                                    ],
                                    "data": {
                                        "from": "testnetyy111",
                                        "to": "eosio.ram",
                                        "quantity": "49.7500 EOS",
                                        "memo": "buy ram"
                                    },
                                    "hex_data": "1042f03eab99b1ca000090e602ea30555c9707000000000004454f5300000000076275792072616d"
                                },
                                "elapsed": 7,
                                "cpu_usage": 0,
                                "console": "",
                                "total_cpu_usage": 0,
                                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                                "inline_traces": []
                            }
                        ]
                    },
                    {
                        "receipt": {
                            "receiver": "eosio.token",
                            "act_digest": "caa4b0daeab300e365be174604ceb8c971e8981013b936b526110562f73f15d5",
                            "global_sequence": 33340948,
                            "recv_sequence": 1726108,
                            "auth_sequence": [
                                [
                                    "testnetyy111",
                                    59
                                ]
                            ],
                            "code_sequence": 3,
                            "abi_sequence": 3
                        },
                        "act": {
                            "account": "eosio.token",
                            "name": "transfer",
                            "authorization": [
                                {
                                    "actor": "testnetyy111",
                                    "permission": "active"
                                }
                            ],
                            "data": {
                                "from": "testnetyy111",
                                "to": "eosio.ramfee",
                                "quantity": "0.2500 EOS",
                                "memo": "ram fee"
                            },
                            "hex_data": "1042f03eab99b1caa0d492e602ea3055c40900000000000004454f53000000000772616d20666565"
                        },
                        "elapsed": 365,
                        "cpu_usage": 0,
                        "console": "",
                        "total_cpu_usage": 0,
                        "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                        "inline_traces": [
                            {
                                "receipt": {
                                    "receiver": "testnetyy111",
                                    "act_digest": "caa4b0daeab300e365be174604ceb8c971e8981013b936b526110562f73f15d5",
                                    "global_sequence": 33340949,
                                    "recv_sequence": 22,
                                    "auth_sequence": [
                                        [
                                            "testnetyy111",
                                            60
                                        ]
                                    ],
                                    "code_sequence": 3,
                                    "abi_sequence": 3
                                },
                                "act": {
                                    "account": "eosio.token",
                                    "name": "transfer",
                                    "authorization": [
                                        {
                                            "actor": "testnetyy111",
                                            "permission": "active"
                                        }
                                    ],
                                    "data": {
                                        "from": "testnetyy111",
                                        "to": "eosio.ramfee",
                                        "quantity": "0.2500 EOS",
                                        "memo": "ram fee"
                                    },
                                    "hex_data": "1042f03eab99b1caa0d492e602ea3055c40900000000000004454f53000000000772616d20666565"
                                },
                                "elapsed": 68,
                                "cpu_usage": 0,
                                "console": "",
                                "total_cpu_usage": 0,
                                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                                "inline_traces": []
                            },
                            {
                                "receipt": {
                                    "receiver": "eosio.ramfee",
                                    "act_digest": "caa4b0daeab300e365be174604ceb8c971e8981013b936b526110562f73f15d5",
                                    "global_sequence": 33340950,
                                    "recv_sequence": 267803,
                                    "auth_sequence": [
                                        [
                                            "testnetyy111",
                                            61
                                        ]
                                    ],
                                    "code_sequence": 3,
                                    "abi_sequence": 3
                                },
                                "act": {
                                    "account": "eosio.token",
                                    "name": "transfer",
                                    "authorization": [
                                        {
                                            "actor": "testnetyy111",
                                            "permission": "active"
                                        }
                                    ],
                                    "data": {
                                        "from": "testnetyy111",
                                        "to": "eosio.ramfee",
                                        "quantity": "0.2500 EOS",
                                        "memo": "ram fee"
                                    },
                                    "hex_data": "1042f03eab99b1caa0d492e602ea3055c40900000000000004454f53000000000772616d20666565"
                                },
                                "elapsed": 10,
                                "cpu_usage": 0,
                                "console": "",
                                "total_cpu_usage": 0,
                                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                                "inline_traces": []
                            }
                        ]
                    }
                ]
            },
            {
                "receipt": {
                    "receiver": "eosio",
                    "act_digest": "3b1f73c0ca73dce2a8c6bcc3a397071a860ecc9798f3cd688382381648dcee10",
                    "global_sequence": 33340951,
                    "recv_sequence": 15451047,
                    "auth_sequence": [
                        [
                            "testnetyy111",
                            62
                        ]
                    ],
                    "code_sequence": 11,
                    "abi_sequence": 12
                },
                "act": {
                    "account": "eosio",
                    "name": "delegatebw",
                    "authorization": [
                        {
                            "actor": "testnetyy111",
                            "permission": "active"
                        }
                    ],
                    "data": {
                        "from": "testnetyy111",
                        "receiver": "testnetyy222",
                        "stake_net_quantity": "20.0000 EOS",
                        "stake_cpu_quantity": "20.0000 EOS",
                        "transfer": 0
                    },
                    "hex_data": "1042f03eab99b1ca2084f03eab99b1ca400d03000000000004454f5300000000400d03000000000004454f530000000000"
                },
                "elapsed": 1561,
                "cpu_usage": 0,
                "console": "",
                "total_cpu_usage": 0,
                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                "inline_traces": [
                    {
                        "receipt": {
                            "receiver": "eosio.token",
                            "act_digest": "034a15a7b1f83236e705f90e22fe246499a990e3699e1f3d8985fe65f1abaa32",
                            "global_sequence": 33340952,
                            "recv_sequence": 1726109,
                            "auth_sequence": [
                                [
                                    "testnetyy111",
                                    63
                                ]
                            ],
                            "code_sequence": 3,
                            "abi_sequence": 3
                        },
                        "act": {
                            "account": "eosio.token",
                            "name": "transfer",
                            "authorization": [
                                {
                                    "actor": "testnetyy111",
                                    "permission": "active"
                                }
                            ],
                            "data": {
                                "from": "testnetyy111",
                                "to": "eosio.stake",
                                "quantity": "40.0000 EOS",
                                "memo": "stake bandwidth"
                            },
                            "hex_data": "1042f03eab99b1ca0014341903ea3055801a06000000000004454f53000000000f7374616b652062616e647769647468"
                        },
                        "elapsed": 471,
                        "cpu_usage": 0,
                        "console": "",
                        "total_cpu_usage": 0,
                        "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                        "inline_traces": [
                            {
                                "receipt": {
                                    "receiver": "testnetyy111",
                                    "act_digest": "034a15a7b1f83236e705f90e22fe246499a990e3699e1f3d8985fe65f1abaa32",
                                    "global_sequence": 33340953,
                                    "recv_sequence": 23,
                                    "auth_sequence": [
                                        [
                                            "testnetyy111",
                                            64
                                        ]
                                    ],
                                    "code_sequence": 3,
                                    "abi_sequence": 3
                                },
                                "act": {
                                    "account": "eosio.token",
                                    "name": "transfer",
                                    "authorization": [
                                        {
                                            "actor": "testnetyy111",
                                            "permission": "active"
                                        }
                                    ],
                                    "data": {
                                        "from": "testnetyy111",
                                        "to": "eosio.stake",
                                        "quantity": "40.0000 EOS",
                                        "memo": "stake bandwidth"
                                    },
                                    "hex_data": "1042f03eab99b1ca0014341903ea3055801a06000000000004454f53000000000f7374616b652062616e647769647468"
                                },
                                "elapsed": 54,
                                "cpu_usage": 0,
                                "console": "",
                                "total_cpu_usage": 0,
                                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                                "inline_traces": []
                            },
                            {
                                "receipt": {
                                    "receiver": "eosio.stake",
                                    "act_digest": "034a15a7b1f83236e705f90e22fe246499a990e3699e1f3d8985fe65f1abaa32",
                                    "global_sequence": 33340954,
                                    "recv_sequence": 238454,
                                    "auth_sequence": [
                                        [
                                            "testnetyy111",
                                            65
                                        ]
                                    ],
                                    "code_sequence": 3,
                                    "abi_sequence": 3
                                },
                                "act": {
                                    "account": "eosio.token",
                                    "name": "transfer",
                                    "authorization": [
                                        {
                                            "actor": "testnetyy111",
                                            "permission": "active"
                                        }
                                    ],
                                    "data": {
                                        "from": "testnetyy111",
                                        "to": "eosio.stake",
                                        "quantity": "40.0000 EOS",
                                        "memo": "stake bandwidth"
                                    },
                                    "hex_data": "1042f03eab99b1ca0014341903ea3055801a06000000000004454f53000000000f7374616b652062616e647769647468"
                                },
                                "elapsed": 8,
                                "cpu_usage": 0,
                                "console": "",
                                "total_cpu_usage": 0,
                                "trx_id": "19f84ed92b1b5b4987f65b3c581ac5a59c814fca29a106d7154332d23755de60",
                                "inline_traces": []
                            }
                        ]
                    }
                ]
            }
        ],
        "except": null
    }
}

4.8 查询新账户状态

api
http://jungle.cryptolions.io:18888/v1/chain/get_account

params
{"account_name":"testnetyy222"}

return
{
    "account_name": "testnetyy222",
    "head_block_num": 13997774,
    "head_block_time": "2018-09-12T09:32:28.500",
    "privileged": false,
    "last_code_update": "1970-01-01T00:00:00.000",
    "created": "2018-09-12T09:29:54.500",
    "ram_quota": 822899,
    "net_weight": 200000,
    "cpu_weight": 200000,
    "net_limit": {
        "used": 0,
        "available": 3835267,
        "max": 3835267
    },
    "cpu_limit": {
        "used": 0,
        "available": 730289,
        "max": 730289
    },
    "ram_usage": 2996,
    "permissions": [
        {
            "perm_name": "active",
            "parent": "owner",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS7eZtj6yzESob8Y3vjYwBnM25uZ3HnQa922FmcR3MZuozdiRCEj",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        },
        {
            "perm_name": "owner",
            "parent": "",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS7L9pb38iiqvnrsgzPVqxHnxHmxxeX6bCNbGkehh1hCScEc3ya2",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        }
    ],
    "total_resources": {
        "owner": "testnetyy222",
        "net_weight": "20.0000 EOS",
        "cpu_weight": "20.0000 EOS",
        "ram_bytes": 821499
    },
    "self_delegated_bandwidth": null,
    "refund_request": null,
    "voter_info": null
}

使用cleos查询:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "http://jungle.cryptolions.io:18888" get account testnetyy222
permissions: 
     owner     1:    1 EOS7L9pb38iiqvnrsgzPVqxHnxHmxxeX6bCNbGkehh1hCScEc3ya2
        active     1:    1 EOS7eZtj6yzESob8Y3vjYwBnM25uZ3HnQa922FmcR3MZuozdiRCEj
memory: 
     quota:     803.6 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:      20.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        3.658 MiB  
     limit:            3.658 MiB  

cpu bandwidth:
     delegated:      20.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        730.3 ms   
     limit:            730.3 ms   

转自:https://blog.csdn.net/akai9898/article/details/83445244

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值