2

我是 php 开发人员并试图广播 tron 交易。请不要向我建议 java 库。我认为这个操作可以通过 API 调用来完成。

我了解 3 个步骤:创建、签名和广播

第 1 步:使用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."}

我做错了吗?

我也尝试使用只有两个参数 raw_data_hex 和 privateKey 的 https://api.trongrid.io/wallet/gettransactionsign (我认为这足以签名)但出现错误 {"Error":"class java.lang.NullPointerException : null"}

我很困惑...

PS 主要问题是:如何准备/构建数据以传递给 API /wallet/broadcasthex

4

1 回答 1

0

protobuf 必须由 protobuf 库处理。使用字段获取/设置方法。不是二进制连接。

于 2020-08-12T17:13:14.220 回答