关于波场(TRON)

一、机制和规则

  • 3秒钟出一个块
  • 27个超级代表SR负责出块
  • 100个超级代表合伙人
  • 注册成为超级代表候选人,需要燃烧9999个 TRX

一、常用接口

docker exec -it tron tail -f /tron/FullNode/logs/tron.log

curl http://172.17.0.2:9090/admin/accounts

curl http://172.17.0.2:9090/admin/accounts?format=hex


1、生成账户1的地址和私钥
curl -X POST  http://172.17.0.2:9090/wallet/generateaddress
{
    "privateKey": "b330dd67248ad76a63769f6680d9bb2de7171ed0a20ed3f25ec96301362fb8ff",
    "address": "TTsdBSYaoN8smz8uXVVeLuy66pXpNwnxg9",
    "hexAddress": "41c463f3b339232b17818a3f13c9372c4451c4d600"
}


2、构建创建账户1的交易
curl --request POST \
  --url http://172.17.0.2:9090/wallet/createaccount\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"owner_address":"417701f6e3b41c3dddb27cac4be8ad14200a4cd688", "account_address": "41c463f3b339232b17818a3f13c9372c4451c4d600"}'

  {"visible":false,"txID":"f28340970e12fffbaa6e8113c1e597ccdef532b2be5b6c5d6a5f481e52d4b0b7","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"417701f6e3b41c3dddb27cac4be8ad14200a4cd688","account_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"32e8","ref_block_hash":"f768e066d0e27611","expiration":1576052874000,"timestamp":1576052815535},"raw_data_hex":"0a0232e82208f768e066d0e276114090b6c9a0ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a15417701f6e3b41c3dddb27cac4be8ad14200a4cd688121541c463f3b339232b17818a3f13c9372c4451c4d60070afedc5a0ef2d"}
  

3、对创建账户1的交易签名
注意:对任何交易签名之前,需要对有效期(exp."expiration":1576054674000)修改,后延一段时间,比如十分钟,需要再十分钟内完成签名并广播出去
参考使用时间戳和时间转换工具:https://tool.lu/timestamp/
curl --request POST \
  --url http://172.17.0.2:9090/wallet/gettransactionsign\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"transaction" :{"txID":"f28340970e12fffbaa6e8113c1e597ccdef532b2be5b6c5d6a5f481e52d4b0b7","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"417701f6e3b41c3dddb27cac4be8ad14200a4cd688","account_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"32e8","ref_block_hash":"f768e066d0e27611","expiration":1576054674000,"timestamp":1576052815535},"raw_data_hex":"0a0232e82208f768e066d0e276114090b6c9a0ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a15417701f6e3b41c3dddb27cac4be8ad14200a4cd688121541c463f3b339232b17818a3f13c9372c4451c4d60070afedc5a0ef2d"},"privateKey": "0a08fc749f8455339ede85897089de2908fe58a3469c20a3ebd70c8adc8cc5d3"}'

{"visible":false,"signature":["2bdaa2e304a0c1083280c81c82282776b7cdc6cfc6753e566c3adff9ef7011324a9d58949b39ec6e5b6d1822c88ab6de87cbcf543bb342faea66ad2798489c2d00"],"txID":"4cb3211ac9d5fc513d12aad94c46136d7c2d05fcf89889f65abaeb358d8b9e11","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"417701f6e3b41c3dddb27cac4be8ad14200a4cd688","account_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"32e8","ref_block_hash":"f768e066d0e27611","expiration":1576054674000,"timestamp":1576052815535},"raw_data_hex":"0a0232e82208f768e066d0e2761140d0a4b7a1ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a15417701f6e3b41c3dddb27cac4be8ad14200a4cd688121541c463f3b339232b17818a3f13c9372c4451c4d60070afedc5a0ef2d"}


4、对创建账户1的交易进行广播
curl --request POST \
  --url http://172.17.0.2:9090/wallet/broadcasttransaction\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"signature":["2bdaa2e304a0c1083280c81c82282776b7cdc6cfc6753e566c3adff9ef7011324a9d58949b39ec6e5b6d1822c88ab6de87cbcf543bb342faea66ad2798489c2d00"],"txID":"4cb3211ac9d5fc513d12aad94c46136d7c2d05fcf89889f65abaeb358d8b9e11","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"417701f6e3b41c3dddb27cac4be8ad14200a4cd688","account_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"32e8","ref_block_hash":"f768e066d0e27611","expiration":1576054674000,"timestamp":1576052815535},"raw_data_hex":"0a0232e82208f768e066d0e2761140d0a4b7a1ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a15417701f6e3b41c3dddb27cac4be8ad14200a4cd688121541c463f3b339232b17818a3f13c9372c4451c4d60070afedc5a0ef2d"}'

{"result": true}


5、查询账户1信息
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41c463f3b339232b17818a3f13c9372c4451c4d600"}'

  {"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","create_time": 1576053297000,"account_resource": {},"owner_permission": {"permission_name": "owner","threshold": 1,"keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]},"active_permission": [{"type": "Active","id": 2,"permission_name": "active","threshold": 1,"operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000","keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]}]}

{
    "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
    "create_time": 1576053297000,
    "account_resource": {},
    "owner_permission": {
        "permission_name": "owner",
        "threshold": 1,
        "keys": [
            {
                "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
                "weight": 1
            }
        ]
    },
    "active_permission": [
        {
            "type": "Active",
            "id": 2,
            "permission_name": "active",
            "threshold": 1,
            "operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000",
            "keys": [
                {
                    "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
                    "weight": 1
                }
            ]
        }
    ]
}


6、查询账户1资源信息
curl --request POST \
  --url http://172.17.0.2:9090/wallet/getaccountresource \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41c463f3b339232b17818a3f13c9372c4451c4d600"}'

  {"freeNetLimit": 5000,"TotalNetLimit": 43200000000,"TotalEnergyLimit": 50000000000000}


内置的超级代表私钥
da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0
内置超级代表对地址
41928c9af0651632157ef27a2cf17ca72c575a4d21

7、转账 41928c9af0651632157ef27a2cf17ca72c575a4d21  to  41c463f3b339232b17818a3f13c9372c4451c4d600    1000000000000

7.1 创建
curl --request POST \
  --url http://172.17.0.2:9090/wallet/createtransaction \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"to_address": "41c463f3b339232b17818a3f13c9372c4451c4d600", "owner_address": "41928c9af0651632157ef27a2cf17ca72c575a4d21", "amount": 1000000000000 }'

  {"visible":false,"txID":"cdd0e203057e91763a202c253149e9b8a0f6a655074540272c44c58aba6b1603","raw_data":{"contract":[{"parameter":{"value":{"amount":1000000000000,"owner_address":"41928c9af0651632157ef27a2cf17ca72c575a4d21","to_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"4042","ref_block_hash":"e270e146667b4284","expiration":1576063128000,"timestamp":1576063069025},"raw_data_hex":"0a0240422208e270e146667b428440c0a3bba5ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541928c9af0651632157ef27a2cf17ca72c575a4d21121541c463f3b339232b17818a3f13c9372c4451c4d6001880a094a58d1d70e1d6b7a5ef2d"}

7.2 签名

curl --request POST \
  --url http://172.17.0.2:9090/wallet/gettransactionsign\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"transaction" :{"txID":"cdd0e203057e91763a202c253149e9b8a0f6a655074540272c44c58aba6b1603","raw_data":{"contract":[{"parameter":{"value":{"amount":1000000000000,"owner_address":"41928c9af0651632157ef27a2cf17ca72c575a4d21","to_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"4042","ref_block_hash":"e270e146667b4284","expiration":1576064328000,"timestamp":1576063069025},"raw_data_hex":"0a0240422208e270e146667b428440c0a3bba5ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541928c9af0651632157ef27a2cf17ca72c575a4d21121541c463f3b339232b17818a3f13c9372c4451c4d6001880a094a58d1d70e1d6b7a5ef2d"},"privateKey": "da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0"}'

{"visible":false,"signature":["e73ee960e69cdc1363de33c1c9a0ef515b53041a69287e07d9c5fc7704335fc7255be197ffd926bc84d0f5e506f02e89b1c8f68086f50fb04b722cbfc7ef487400"],"txID":"aa5d84a5f08b9f4a02086a423e6ca17d8d5d737493f9f0ad5fdaaef51b2b3aad","raw_data":{"contract":[{"parameter":{"value":{"amount":1000000000000,"owner_address":"41928c9af0651632157ef27a2cf17ca72c575a4d21","to_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"4042","ref_block_hash":"e270e146667b4284","expiration":1576064328000,"timestamp":1576063069025},"raw_data_hex":"0a0240422208e270e146667b428440c0c284a6ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541928c9af0651632157ef27a2cf17ca72c575a4d21121541c463f3b339232b17818a3f13c9372c4451c4d6001880a094a58d1d70e1d6b7a5ef2d"}


7.3 广播

curl --request POST \
  --url http://172.17.0.2:9090/wallet/broadcasttransaction\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"signature":["e73ee960e69cdc1363de33c1c9a0ef515b53041a69287e07d9c5fc7704335fc7255be197ffd926bc84d0f5e506f02e89b1c8f68086f50fb04b722cbfc7ef487400"],"txID":"aa5d84a5f08b9f4a02086a423e6ca17d8d5d737493f9f0ad5fdaaef51b2b3aad","raw_data":{"contract":[{"parameter":{"value":{"amount":1000000000000,"owner_address":"41928c9af0651632157ef27a2cf17ca72c575a4d21","to_address":"41c463f3b339232b17818a3f13c9372c4451c4d600"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"4042","ref_block_hash":"e270e146667b4284","expiration":1576064328000,"timestamp":1576063069025},"raw_data_hex":"0a0240422208e270e146667b428440c0c284a6ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541928c9af0651632157ef27a2cf17ca72c575a4d21121541c463f3b339232b17818a3f13c9372c4451c4d6001880a094a58d1d70e1d6b7a5ef2d"}'

{"result": true}

7.4 查询
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41c463f3b339232b17818a3f13c9372c4451c4d600"}'

  {"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","balance": 1000000000000,"create_time": 1576053297000,"account_resource": {},"owner_permission": {"permission_name": "owner","threshold": 1,"keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]},"active_permission": [{"type": "Active","id": 2,"permission_name": "active","threshold": 1,"operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000","keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]}]}


8、创建第账户2
8.1 生成账户2的地址和私钥
curl -X POST  http://172.17.0.2:9090/wallet/generateaddress
{"privateKey":"e1b19af8450bf152fef5d376f39d1ec5a774ff0e01799e95ed69d0e0e694815b","address":"TXNqBR5jMrJGvtmVi1VTm7Q2SLnZD6iBGe","hexAddress":"41ead268af95c329d748c56eef386e9388aa0f54db"}

8.2 创建账户2的交易
curl --request POST \
  --url http://172.17.0.2:9090/wallet/createaccount\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600", "account_address": "41ead268af95c329d748c56eef386e9388aa0f54db"}'

{"visible":false,"txID":"f913864ebc82a309ca8d118cb4e729ac2be81652abca7f5f04965cc47483c67c","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","account_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"4389","ref_block_hash":"fb9abf9064a3920e","expiration":1576065645000,"timestamp":1576065586330},"raw_data_hex":"0a0243892208fb9abf9064a3920e40c8f3d4a6ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db709aa9d1a6ef2d"}

"txID":"f913864ebc82a309ca8d118cb4e729ac2be81652abca7f5f04965cc47483c67c","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","account_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"4389","ref_block_hash":"fb9abf9064a3920e","expiration":1576066245000,"timestamp":1576065586330},"raw_data_hex":"0a0243892208fb9abf9064a3920e40c8f3d4a6ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db709aa9d1a6ef2d"

8.3 签名
curl --request POST \
  --url http://172.17.0.2:9090/wallet/gettransactionsign\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"transaction" :{"txID":"f913864ebc82a309ca8d118cb4e729ac2be81652abca7f5f04965cc47483c67c","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","account_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"4389","ref_block_hash":"fb9abf9064a3920e","expiration":1576066245000,"timestamp":1576065586330},"raw_data_hex":"0a0243892208fb9abf9064a3920e40c8f3d4a6ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db709aa9d1a6ef2d"},"privateKey": "b330dd67248ad76a63769f6680d9bb2de7171ed0a20ed3f25ec96301362fb8ff"}'

{"visible":false,"signature":["ceeb1cc640ad4c4aa481be06d151e18a1c6165987927876203ece4b8457939167b258e25447e3ecf4ac3eb8ca94b24e373efd4e9c73f8b919811b859e7d5c5ce00"],"txID":"2b23168da368d86b48b8cc4f3f0d800ef01ba1ffcb095295659fbf8157d063df","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","account_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"4389","ref_block_hash":"fb9abf9064a3920e","expiration":1576066245000,"timestamp":1576065586330},"raw_data_hex":"0a0243892208fb9abf9064a3920e4088c3f9a6ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db709aa9d1a6ef2d"}

8.4 广播
curl --request POST \
  --url http://172.17.0.2:9090/wallet/broadcasttransaction\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"signature":["ceeb1cc640ad4c4aa481be06d151e18a1c6165987927876203ece4b8457939167b258e25447e3ecf4ac3eb8ca94b24e373efd4e9c73f8b919811b859e7d5c5ce00"],"txID":"2b23168da368d86b48b8cc4f3f0d800ef01ba1ffcb095295659fbf8157d063df","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","account_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.AccountCreateContract"},"type":"AccountCreateContract"}],"ref_block_bytes":"4389","ref_block_hash":"fb9abf9064a3920e","expiration":1576066245000,"timestamp":1576065586330},"raw_data_hex":"0a0243892208fb9abf9064a3920e4088c3f9a6ef2d5a6612640a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e4163636f756e74437265617465436f6e7472616374122e0a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db709aa9d1a6ef2d"}'

{"result": true}

8.5 查询
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41ead268af95c329d748c56eef386e9388aa0f54db"}'

  {"address": "41ead268af95c329d748c56eef386e9388aa0f54db","create_time": 1576066152000,"account_resource": {},"owner_permission": {"permission_name": "owner","threshold": 1,"keys": [{"address": "41ead268af95c329d748c56eef386e9388aa0f54db","weight": 1}]},"active_permission": [{"type": "Active","id": 2,"permission_name": "active","threshold": 1,"operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000","keys": [{"address": "41ead268af95c329d748c56eef386e9388aa0f54db","weight": 1}]}]}



9、账户1给第账户2转账
9.1 构建转账交易
curl --request POST \
  --url http://172.17.0.2:9090/wallet/createtransaction \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"to_address": "41ead268af95c329d748c56eef386e9388aa0f54db", "owner_address": "41c463f3b339232b17818a3f13c9372c4451c4d600", "amount": 800000000000 }'

  {"visible":false,"txID":"83b06caf73ffd7425b4b395a10a5ea797832264141ea61bf4eedae668d7e03bc","raw_data":{"contract":[{"parameter":{"value":{"amount":800000000000,"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","to_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"448d","ref_block_hash":"88de8bb34bdeb2a3","expiration":1576066425000,"timestamp":1576066365198},"raw_data_hex":"0a02448d220888de8bb34bdeb2a340a8c184a7ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db188080dd9da417708eee80a7ef2d"}

"txID":"83b06caf73ffd7425b4b395a10a5ea797832264141ea61bf4eedae668d7e03bc","raw_data":{"contract":[{"parameter":{"value":{"amount":800000000000,"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","to_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"448d","ref_block_hash":"88de8bb34bdeb2a3","expiration":1576067145000,"timestamp":1576066365198},"raw_data_hex":"0a02448d220888de8bb34bdeb2a340a8c184a7ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db188080dd9da417708eee80a7ef2d"

9.2 签名
curl --request POST \
  --url http://172.17.0.2:9090/wallet/gettransactionsign\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"transaction" :{"txID":"83b06caf73ffd7425b4b395a10a5ea797832264141ea61bf4eedae668d7e03bc","raw_data":{"contract":[{"parameter":{"value":{"amount":800000000000,"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","to_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"448d","ref_block_hash":"88de8bb34bdeb2a3","expiration":1576067145000,"timestamp":1576066365198},"raw_data_hex":"0a02448d220888de8bb34bdeb2a340a8c184a7ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db188080dd9da417708eee80a7ef2d"},"privateKey": "b330dd67248ad76a63769f6680d9bb2de7171ed0a20ed3f25ec96301362fb8ff"}'

{"visible":false,"signature":["20346687e759ed7eb8bb41fb7d5b35e2393e4c45c8a4d372779b804de40d494a2f8fb244483f7ef2866a9a82f8394b4d831058b4a827c8206d222e941f3d2ea001"],"txID":"1f8fe26dd9b71286c7c2d28cab7d4ef796cb8a7b497061d5804774a0f1db2ce1","raw_data":{"contract":[{"parameter":{"value":{"amount":800000000000,"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","to_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"448d","ref_block_hash":"88de8bb34bdeb2a3","expiration":1576067145000,"timestamp":1576066365198},"raw_data_hex":"0a02448d220888de8bb34bdeb2a340a8bab0a7ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db188080dd9da417708eee80a7ef2d"}

9.3 广播
curl --request POST \
  --url http://172.17.0.2:9090/wallet/broadcasttransaction\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"signature":["20346687e759ed7eb8bb41fb7d5b35e2393e4c45c8a4d372779b804de40d494a2f8fb244483f7ef2866a9a82f8394b4d831058b4a827c8206d222e941f3d2ea001"],"txID":"1f8fe26dd9b71286c7c2d28cab7d4ef796cb8a7b497061d5804774a0f1db2ce1","raw_data":{"contract":[{"parameter":{"value":{"amount":800000000000,"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","to_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"448d","ref_block_hash":"88de8bb34bdeb2a3","expiration":1576067145000,"timestamp":1576066365198},"raw_data_hex":"0a02448d220888de8bb34bdeb2a340a8bab0a7ef2d5a6a080112660a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412350a1541c463f3b339232b17818a3f13c9372c4451c4d600121541ead268af95c329d748c56eef386e9388aa0f54db188080dd9da417708eee80a7ef2d"}'

{"result": true}

9.4 查询
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41ead268af95c329d748c56eef386e9388aa0f54db"}'
  
  {"address": "41ead268af95c329d748c56eef386e9388aa0f54db","balance": 800000000000,"create_time": 1576066152000,"account_resource": {},"owner_permission": {"permission_name": "owner","threshold": 1,"keys": [{"address": "41ead268af95c329d748c56eef386e9388aa0f54db","weight": 1}]},"active_permission": [{"type": "Active","id": 2,"permission_name": "active","threshold": 1,"operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000","keys": [{"address": "41ead268af95c329d748c56eef386e9388aa0f54db","weight": 1}]}]}

curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41c463f3b339232b17818a3f13c9372c4451c4d600"}'
  
  {"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","balance": 199999900000,"create_time": 1576053297000,"latest_opration_time": 1576066923000,"free_net_usage": 269,"latest_consume_free_time": 1576066923000,"account_resource": {},"owner_permission": {"permission_name": "owner","threshold": 1,"keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]},"active_permission": [{"type": "Active","id": 2,"permission_name": "active","threshold": 1,"operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000","keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]}]}


10、账户1申请超级代表
10.1 构建交易
curl --request POST \
  --url http://172.17.0.2:9090/wallet/createwitness \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600", "url": "007570646174654e616d6531353330363038383733343633"}'

  {"visible":false,"txID":"d6275b5e28beb1dff9b24cadcb9b95f26af2d7de42073443e1fa910a6aae316d","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","url":"007570646174654e616d6531353330363038383733343633"},"type_url":"type.googleapis.com/protocol.WitnessCreateContract"},"type":"WitnessCreateContract"}],"ref_block_bytes":"45b8","ref_block_hash":"e57bfb2071011556","expiration":1576067322000,"timestamp":1576067264561},"raw_data_hex":"0a0245b82208e57bfb20710115564090a1bba7ef2d5a6b080512670a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746e657373437265617465436f6e747261637412310a1541c463f3b339232b17818a3f13c9372c4451c4d6001218007570646174654e616d653135333036303838373334363370b1e0b7a7ef2d"}
  "txID":"d6275b5e28beb1dff9b24cadcb9b95f26af2d7de42073443e1fa910a6aae316d","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","url":"007570646174654e616d6531353330363038383733343633"},"type_url":"type.googleapis.com/protocol.WitnessCreateContract"},"type":"WitnessCreateContract"}],"ref_block_bytes":"45b8","ref_block_hash":"e57bfb2071011556","expiration":1576067922000,"timestamp":1576067264561},"raw_data_hex":"0a0245b82208e57bfb20710115564090a1bba7ef2d5a6b080512670a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746e657373437265617465436f6e747261637412310a1541c463f3b339232b17818a3f13c9372c4451c4d6001218007570646174654e616d653135333036303838373334363370b1e0b7a7ef2d"

10.2 签名
curl --request POST \
  --url http://172.17.0.2:9090/wallet/gettransactionsign\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"transaction" :{  "txID":"d6275b5e28beb1dff9b24cadcb9b95f26af2d7de42073443e1fa910a6aae316d","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","url":"007570646174654e616d6531353330363038383733343633"},"type_url":"type.googleapis.com/protocol.WitnessCreateContract"},"type":"WitnessCreateContract"}],"ref_block_bytes":"45b8","ref_block_hash":"e57bfb2071011556","expiration":1576067922000,"timestamp":1576067264561},"raw_data_hex":"0a0245b82208e57bfb20710115564090a1bba7ef2d5a6b080512670a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746e657373437265617465436f6e747261637412310a1541c463f3b339232b17818a3f13c9372c4451c4d6001218007570646174654e616d653135333036303838373334363370b1e0b7a7ef2d"},"privateKey": "b330dd67248ad76a63769f6680d9bb2de7171ed0a20ed3f25ec96301362fb8ff"}'

{"visible":false,"signature":["1810f017400731fedd63f43f2bfc9895f241443f6203f5a7bf46ca242ec91f5d27b0410a8a33f9e3c804c1614cbfdc1299e698906d340116ef85fbbcb24bb64e00"],"txID":"7d75eb7731c4a1203931f4be302adeaafef07f9dc1f824a7b3742ffb48b11d20","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","url":"007570646174654e616d6531353330363038383733343633"},"type_url":"type.googleapis.com/protocol.WitnessCreateContract"},"type":"WitnessCreateContract"}],"ref_block_bytes":"45b8","ref_block_hash":"e57bfb2071011556","expiration":1576067922000,"timestamp":1576067264561},"raw_data_hex":"0a0245b82208e57bfb207101155640d0f0dfa7ef2d5a6b080512670a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746e657373437265617465436f6e747261637412310a1541c463f3b339232b17818a3f13c9372c4451c4d6001218007570646174654e616d653135333036303838373334363370b1e0b7a7ef2d"}

10.3 广播
curl --request POST \
  --url http://172.17.0.2:9090/wallet/broadcasttransaction\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"signature":["1810f017400731fedd63f43f2bfc9895f241443f6203f5a7bf46ca242ec91f5d27b0410a8a33f9e3c804c1614cbfdc1299e698906d340116ef85fbbcb24bb64e00"],"txID":"7d75eb7731c4a1203931f4be302adeaafef07f9dc1f824a7b3742ffb48b11d20","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","url":"007570646174654e616d6531353330363038383733343633"},"type_url":"type.googleapis.com/protocol.WitnessCreateContract"},"type":"WitnessCreateContract"}],"ref_block_bytes":"45b8","ref_block_hash":"e57bfb2071011556","expiration":1576067922000,"timestamp":1576067264561},"raw_data_hex":"0a0245b82208e57bfb207101155640d0f0dfa7ef2d5a6b080512670a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746e657373437265617465436f6e747261637412310a1541c463f3b339232b17818a3f13c9372c4451c4d6001218007570646174654e616d653135333036303838373334363370b1e0b7a7ef2d"}'

{"result": true}

10.4 查询
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41c463f3b339232b17818a3f13c9372c4451c4d600"}'

查询结果: 烧掉了9999个TRX, "is_witness": true
  {"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","balance": 190000900000,"create_time": 1576053297000,"latest_opration_time": 1576067571000,"is_witness": true,"free_net_usage": 537,"latest_consume_free_time": 1576067571000,"account_resource": {},"owner_permission": {"permission_name": "owner","threshold": 1,"keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]},"witness_permission": {"type": "Witness","id": 1,"permission_name": "witness","threshold": 1,"keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]},"active_permission": [{"type": "Active","id": 2,"permission_name": "active","threshold": 1,"operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000","keys": [{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","weight": 1}]}]}


11、账户2锁TRX
冻结 10万 TRX
11.1 构建交易
curl --request POST \
  --url http://172.17.0.2:9090/wallet/freezebalance \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db", "frozen_balance": 100000000000,"frozen_duration": 3,"resource" : "BANDWIDTH"}'

  {"visible":false,"txID":"ce7815b8e63e9854cfe92eca514a83714faa778d4703a9065bc2a0e6136bf679","raw_data":{"contract":[{"parameter":{"value":{"frozen_duration":3,"frozen_balance":100000000000,"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.FreezeBalanceContract"},"type":"FreezeBalanceContract"}],"ref_block_bytes":"8a2c","ref_block_hash":"55f0077e318565fc","expiration":1576119900000,"timestamp":1576119840900},"raw_data_hex":"0a028a2c220855f0077e318565fc40e0aec4c0ef2d5a5a080b12560a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e6365436f6e747261637412200a1541ead268af95c329d748c56eef386e9388aa0f54db1080d0dbc3f40218037084e1c0c0ef2d"}

11.2 签名
curl --request POST \
  --url http://172.17.0.2:9090/wallet/gettransactionsign\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"transaction" :{ "txID":"ce7815b8e63e9854cfe92eca514a83714faa778d4703a9065bc2a0e6136bf679","raw_data":{"contract":[{"parameter":{"value":{"frozen_duration":3,"frozen_balance":100000000000,"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.FreezeBalanceContract"},"type":"FreezeBalanceContract"}],"ref_block_bytes":"8a2c","ref_block_hash":"55f0077e318565fc","expiration":1576121100000,"timestamp":1576119840900},"raw_data_hex":"0a028a2c220855f0077e318565fc40e0aec4c0ef2d5a5a080b12560a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e6365436f6e747261637412200a1541ead268af95c329d748c56eef386e9388aa0f54db1080d0dbc3f40218037084e1c0c0ef2d"},"privateKey": "e1b19af8450bf152fef5d376f39d1ec5a774ff0e01799e95ed69d0e0e694815b"}'

把构建交易返回数据:txID开始以及后面的数据复制一份,修改有效期往后一段时间 "expiration":1576119900000 ----> 1576121100000,再全部复制放到 transaction域,使用账户2的私钥
"txID":"ce7815b8e63e9854cfe92eca514a83714faa778d4703a9065bc2a0e6136bf679","raw_data":{"contract":[{"parameter":{"value":{"frozen_duration":3,"frozen_balance":100000000000,"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.FreezeBalanceContract"},"type":"FreezeBalanceContract"}],"ref_block_bytes":"8a2c","ref_block_hash":"55f0077e318565fc","expiration":1576121100000,"timestamp":1576119840900},"raw_data_hex":"0a028a2c220855f0077e318565fc40e0aec4c0ef2d5a5a080b12560a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e6365436f6e747261637412200a1541ead268af95c329d748c56eef386e9388aa0f54db1080d0dbc3f40218037084e1c0c0ef2d"

{"visible":false,"signature":["9fb8bc9f9673cd7da2f287e8f191fec7ad7340b8696a275238c54c929e18458d0722d30d857319209445feaa361b6f5d70e19778ec6c0328abfdd40c3cd8bce701"],"txID":"c529ad499c4c4385c07d7c9a619f1a32fd47115c7a8864a8f7c8b7e47ff56446","raw_data":{"contract":[{"parameter":{"value":{"frozen_duration":3,"frozen_balance":100000000000,"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.FreezeBalanceContract"},"type":"FreezeBalanceContract"}],"ref_block_bytes":"8a2c","ref_block_hash":"55f0077e318565fc","expiration":1576121100000,"timestamp":1576119840900},"raw_data_hex":"0a028a2c220855f0077e318565fc40e0cd8dc1ef2d5a5a080b12560a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e6365436f6e747261637412200a1541ead268af95c329d748c56eef386e9388aa0f54db1080d0dbc3f40218037084e1c0c0ef2d"}

11.3 广播
curl --request POST \
  --url http://172.17.0.2:9090/wallet/broadcasttransaction\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"signature":["9fb8bc9f9673cd7da2f287e8f191fec7ad7340b8696a275238c54c929e18458d0722d30d857319209445feaa361b6f5d70e19778ec6c0328abfdd40c3cd8bce701"],"txID":"c529ad499c4c4385c07d7c9a619f1a32fd47115c7a8864a8f7c8b7e47ff56446","raw_data":{"contract":[{"parameter":{"value":{"frozen_duration":3,"frozen_balance":100000000000,"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db"},"type_url":"type.googleapis.com/protocol.FreezeBalanceContract"},"type":"FreezeBalanceContract"}],"ref_block_bytes":"8a2c","ref_block_hash":"55f0077e318565fc","expiration":1576121100000,"timestamp":1576119840900},"raw_data_hex":"0a028a2c220855f0077e318565fc40e0cd8dc1ef2d5a5a080b12560a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e6365436f6e747261637412200a1541ead268af95c329d748c56eef386e9388aa0f54db1080d0dbc3f40218037084e1c0c0ef2d"}'

{"result": true}

11.4 冻结10万TRX后的查询
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41ead268af95c329d748c56eef386e9388aa0f54db"}'

  返回:
  {"address": "41ead268af95c329d748c56eef386e9388aa0f54db","balance": 700000000000,"frozen": [{"frozen_balance": 100000000000,"expire_time": 1576379730000}],"create_time": 1576066152000,"latest_opration_time": 1576120530000,"free_net_usage": 252,"latest_consume_free_time": 1576120530000,"account_resource": {},"owner_permission": {"permission_name": "owner","threshold": 1,"keys": [{"address": "41ead268af95c329d748c56eef386e9388aa0f54db","weight": 1}]},"active_permission": [{"type": "Active","id": 2,"permission_name": "active","threshold": 1,"operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000","keys": [{"address": "41ead268af95c329d748c56eef386e9388aa0f54db","weight": 1}]}]}
  
  格式化:
  {
    "address": "41ead268af95c329d748c56eef386e9388aa0f54db",
    "balance": 700000000000,
    "frozen": [
        {
            "frozen_balance": 100000000000,
            "expire_time": 1576379730000
        }
    ],
    "create_time": 1576066152000,
    "latest_opration_time": 1576120530000,
    "free_net_usage": 252,
    "latest_consume_free_time": 1576120530000,
    "account_resource": {},
    "owner_permission": {
        "permission_name": "owner",
        "threshold": 1,
        "keys": [
            {
                "address": "41ead268af95c329d748c56eef386e9388aa0f54db",
                "weight": 1
            }
        ]
    },
    "active_permission": [
        {
            "type": "Active",
            "id": 2,
            "permission_name": "active",
            "threshold": 1,
            "operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000",
            "keys": [
                {
                    "address": "41ead268af95c329d748c56eef386e9388aa0f54db",
                    "weight": 1
                }
            ]
        }
    ]
}



12、账户2给账户1投票 10万 TP
41ead268af95c329d748c56eef386e9388aa0f54db vote to 41c463f3b339232b17818a3f13c9372c4451c4d600
12.1 构建投票交易
curl --request POST \
  --url http://172.17.0.2:9090/wallet/votewitnessaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db", "votes": [{"vote_address": "41c463f3b339232b17818a3f13c9372c4451c4d600", "vote_count": 100000}]}'

{"visible":false,"txID":"56dd9a812776c1cf5542169e22ee2f73d8032a00f7d3279086389e4d18ded13e","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db","votes":[{"vote_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","vote_count":100000}]},"type_url":"type.googleapis.com/protocol.VoteWitnessContract"},"type":"VoteWitnessContract"}],"ref_block_bytes":"8cd2","ref_block_hash":"d0e722cae221acb5","expiration":1576121934000,"timestamp":1576121875537},"raw_data_hex":"0a028cd22208d0e722cae221acb540b0c1c0c1ef2d5a6c080412680a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412340a1541ead268af95c329d748c56eef386e9388aa0f54db121b0a1541c463f3b339232b17818a3f13c9372c4451c4d60010a08d0670d1f8bcc1ef2d"}

12.2 签名
curl --request POST \
  --url http://172.17.0.2:9090/wallet/gettransactionsign\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"transaction" :{ "txID":"56dd9a812776c1cf5542169e22ee2f73d8032a00f7d3279086389e4d18ded13e","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db","votes":[{"vote_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","vote_count":100000}]},"type_url":"type.googleapis.com/protocol.VoteWitnessContract"},"type":"VoteWitnessContract"}],"ref_block_bytes":"8cd2","ref_block_hash":"d0e722cae221acb5","expiration":1576123134000,"timestamp":1576121875537},"raw_data_hex":"0a028cd22208d0e722cae221acb540b0c1c0c1ef2d5a6c080412680a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412340a1541ead268af95c329d748c56eef386e9388aa0f54db121b0a1541c463f3b339232b17818a3f13c9372c4451c4d60010a08d0670d1f8bcc1ef2d"},"privateKey": "e1b19af8450bf152fef5d376f39d1ec5a774ff0e01799e95ed69d0e0e694815b"}'

把构建交易返回数据:txID开始以及后面的数据复制一份,修改有效期往后一段时间 "expiration":1576121934000 ----> 1576123134000,再全部复制放到 transaction域,使用账户2的私钥
"txID":"56dd9a812776c1cf5542169e22ee2f73d8032a00f7d3279086389e4d18ded13e","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db","votes":[{"vote_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","vote_count":100000}]},"type_url":"type.googleapis.com/protocol.VoteWitnessContract"},"type":"VoteWitnessContract"}],"ref_block_bytes":"8cd2","ref_block_hash":"d0e722cae221acb5","expiration":1576123134000,"timestamp":1576121875537},"raw_data_hex":"0a028cd22208d0e722cae221acb540b0c1c0c1ef2d5a6c080412680a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412340a1541ead268af95c329d748c56eef386e9388aa0f54db121b0a1541c463f3b339232b17818a3f13c9372c4451c4d60010a08d0670d1f8bcc1ef2d"

返回:
{"visible":false,"signature":["3d6c8eaea5ecdc6d2ad58a2c4b8ebbeffcceecf9b7e6c1f11fb228dd1a11aef62a8837e766fccf208b09a24ea077adf6e15b4e5bf028f8ef332415a3d3915bc700"],"txID":"d70f8203d0c26896f902b03e2e977750fc3349cf24f276ceb26130905cda1b4c","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db","votes":[{"vote_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","vote_count":100000}]},"type_url":"type.googleapis.com/protocol.VoteWitnessContract"},"type":"VoteWitnessContract"}],"ref_block_bytes":"8cd2","ref_block_hash":"d0e722cae221acb5","expiration":1576123134000,"timestamp":1576121875537},"raw_data_hex":"0a028cd22208d0e722cae221acb540b0e089c2ef2d5a6c080412680a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412340a1541ead268af95c329d748c56eef386e9388aa0f54db121b0a1541c463f3b339232b17818a3f13c9372c4451c4d60010a08d0670d1f8bcc1ef2d"}

12.3 广播
curl --request POST \
  --url http://172.17.0.2:9090/wallet/broadcasttransaction\
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"signature":["3d6c8eaea5ecdc6d2ad58a2c4b8ebbeffcceecf9b7e6c1f11fb228dd1a11aef62a8837e766fccf208b09a24ea077adf6e15b4e5bf028f8ef332415a3d3915bc700"],"txID":"d70f8203d0c26896f902b03e2e977750fc3349cf24f276ceb26130905cda1b4c","raw_data":{"contract":[{"parameter":{"value":{"owner_address":"41ead268af95c329d748c56eef386e9388aa0f54db","votes":[{"vote_address":"41c463f3b339232b17818a3f13c9372c4451c4d600","vote_count":100000}]},"type_url":"type.googleapis.com/protocol.VoteWitnessContract"},"type":"VoteWitnessContract"}],"ref_block_bytes":"8cd2","ref_block_hash":"d0e722cae221acb5","expiration":1576123134000,"timestamp":1576121875537},"raw_data_hex":"0a028cd22208d0e722cae221acb540b0e089c2ef2d5a6c080412680a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412340a1541ead268af95c329d748c56eef386e9388aa0f54db121b0a1541c463f3b339232b17818a3f13c9372c4451c4d60010a08d0670d1f8bcc1ef2d"}'

{"result": true}

12.4 投票后的查询,先查询账户2(投票账户)
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41ead268af95c329d748c56eef386e9388aa0f54db"}'

  返回格式化数据:
  {
    "address": "41ead268af95c329d748c56eef386e9388aa0f54db",
    "balance": 700000000000,
    "votes": [
        {
            "vote_address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
            "vote_count": 100000
        }
    ],
    "frozen": [
        {
            "frozen_balance": 100000000000,
            "expire_time": 1576379730000
        }
    ],
    "net_usage": 271,
    "create_time": 1576066152000,
    "latest_opration_time": 1576122237000,
    "free_net_usage": 247,
    "latest_consume_time": 1576122237000,
    "latest_consume_free_time": 1576120530000,
    "account_resource": {},
    "owner_permission": {
        "permission_name": "owner",
        "threshold": 1,
        "keys": [
            {
                "address": "41ead268af95c329d748c56eef386e9388aa0f54db",
                "weight": 1
            }
        ]
    },
    "active_permission": [
        {
            "type": "Active",
            "id": 2,
            "permission_name": "active",
            "threshold": 1,
            "operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000",
            "keys": [
                {
                    "address": "41ead268af95c329d748c56eef386e9388aa0f54db",
                    "weight": 1
                }
            ]
        }
    ]
}

12.5 投票后的查询,先查询账户1(获票账户)
curl --request POST \
  --url http://172.17.0.2:9090/walletsolidity/getaccount \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: edfb73b6-6e9b-4b07-9abf-607fe908d5ec' \
  --header 'cache-control: no-cache' \
  --data '{"address":"41c463f3b339232b17818a3f13c9372c4451c4d600"}'
  返回格式化数据
  {
    "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
    "balance": 190000900000,
    "create_time": 1576053297000,
    "latest_opration_time": 1576067571000,
    "is_witness": true,
    "free_net_usage": 195,
    "latest_consume_free_time": 1576067571000,
    "account_resource": {},
    "owner_permission": {
        "permission_name": "owner",
        "threshold": 1,
        "keys": [
            {
                "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
                "weight": 1
            }
        ]
    },
    "witness_permission": {
        "type": "Witness",
        "id": 1,
        "permission_name": "witness",
        "threshold": 1,
        "keys": [
            {
                "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
                "weight": 1
            }
        ]
    },
    "active_permission": [
        {
            "type": "Active",
            "id": 2,
            "permission_name": "active",
            "threshold": 1,
            "operations": "7fff1fc0033e0100000000000000000000000000000000000000000000000000",
            "keys": [
                {
                    "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
                    "weight": 1
                }
            ]
        }
    ]
}



13、解冻已经结束冻结期的trx,会同时失去这部分trx带来的带宽和投票权

curl -X POST http://127.0.0.1:8090/wallet/unfreezebalance -d '{
"owner_address":"41e472f387585c2b58bc2c9bb4492bc1f17342cd1",
"resource": "BANDWIDTH",
"receiver_address":"414332f387585c2b58bc2c9bb4492bc1f17342cd1"
}'
参数说明:
owner_address是解冻trx账号的地址,默认为hexString格式    
resource可以是BANDWIDTH或者ENERGY
receiverAddress表示受委托账户的地址,默认为hexString格式    
可选参数Permission_id,多重签名时使用,设置交易多重签名时使用的permissionId     
返回值:解冻trx的transaction

完成操作需要三步:构建交易,签名,广播,详细参考创建账户,转账,冻结,投票等交易过程


14、超级代表领取奖励
wallet/freezebalance
作用:冻结trx,获取带宽,获取投票权
demo:curl -X POST http://127.0.0.1:8090/wallet/freezebalance -d '{
"owner_address":"41e472f387585c2b58bc2c9bb4492bc1f17342cd1", 
"frozen_balance": 10000,
"frozen_duration": 3,
"resource" : "BANDWIDTH",
"receiver_address":"414332f387585c2b58bc2c9bb4492bc1f17342cd1"
}'
参数说明:
owner_address是冻结trx账号的地址,默认为hexString格式    
frozen_balance是冻结trx的数量
frozen_duration是冻结天数,最少是3天
resource: 冻结trx获取资源的类型(可以是BANDWIDTH或者ENERGY,BANDWIDTH为带宽,ENERGY为虚拟机消耗资源)
receiverAddress表示受委托账户的地址,默认为hexString格式           
可选参数Permission_id,多重签名时使用,设置交易多重签名时使用的permissionId      
返回值:冻结trx的transaction

完成操作需要三步:构建交易,签名,广播,详细参考创建账户,转账,冻结,投票等交易过程


15、查看超级代表列表

curl -X POST  http://172.17.0.2:9090/walletsolidity/listwitnesses

{"witnesses": [{"address": "41928c9af0651632157ef27a2cf17ca72c575a4d21","voteCount": 10000,"url": "http://tronstudio.com","totalProduced": 167671,"latestBlockNum": 167671,"latestSlotNum": 525374507,"isJobs": true},{"address": "41c463f3b339232b17818a3f13c9372c4451c4d600","url": "\u0000updateName1530608873463"}]}

{
    "witnesses": [
        {
            "address": "41928c9af0651632157ef27a2cf17ca72c575a4d21",
            "voteCount": 10000,
            "url": "http://tronstudio.com",
            "totalProduced": 167671,
            "latestBlockNum": 167671,
            "latestSlotNum": 525374507,
            "isJobs": true
        },
        {
            "address": "41c463f3b339232b17818a3f13c9372c4451c4d600",
            "url": "\u0000updateName1530608873463"
        }
    ]
}
  



你可能感兴趣的:(区块链,tron,波场)