【发布时间】:2020-08-01 19:23:28
【问题描述】:
我是 php 开发人员,正在尝试广播 tron 交易。请不要向我建议 java 库。我认为这个操作可以通过 API 调用来完成。
我了解 3 个步骤:创建、签名和广播
第一步:使用https://api.trongrid.io/wallet/createtransaction
并获取 raw_data_hex
结果:0a02df8d22080ffa79d7279ecb2a40a88bc8d9ba2e5a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a1541e3b634e89a3edd652651b5c775870fc364cf2a061215413131e7dd9fe0ce528f9d86036fcfef56967d8807180170ecc8c4d9ba2e
第 2 步:从https://developers.tron.network/docs/account#signature 逐步创建标志
结果:6bca53954ac706ddf59745e0e9d09e7c3709e58d1bdf35a06d0b974c1eaa0eca695d7b2aecd7200988f415a447e70064939ba56a6dd3c71725c547f3452ffaef00
和“将此签名添加回交易”:
0a02df8d22080ffa79d7279ecb2a40a88bc8d9ba2e5a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a1541e3b634e89a3edd652651b5c775870fc364cf2a061215413131e7dd9fe0ce528f9d86036fcfef56967d8807180170ecc8c4d9ba2e6bca53954ac706ddf59745e0e9d09e7c3709e58d1bdf35a06d0b974c1eaa0eca695d7b2aecd7200988f415a447e70064939ba56a6dd3c71725c547f3452ffaef00
第 3 步:由https://api.trongrid.io/wallet/broadcasthex 广播此内容
结果:
{"Error":"class com.google.protobuf.InvalidProtocolBufferException : While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either that the input has been truncated or that an embedded message misreported its own length."}
我做错了吗?
我也尝试使用https://api.trongrid.io/wallet/gettransactionsign,只有两个参数 raw_data_hex 和 privateKey(我认为这足以签名)
但出现错误:
{"Error":"class java.lang.NullPointerException : null"}
我很困惑...
附:主要问题是: 如何准备/构建数据以传递给 API /wallet/broadcasthex?
【问题讨论】:
-
欢迎来到 Stack Overflow。请通过tour 了解 Stack Overflow 的工作原理,并阅读How to Ask 了解如何提高问题的质量。然后edit 你的问题包含你拥有的源代码作为minimal reproducible example,可以被其他人测试。请参阅:Why is “Can someone help me?” not an actual question?.