我是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."}
我做错了吗?
我也尝试只将https://api.trongrid.io/wallet/gettransactionsign与两个参数raw_data_hex和privateKey一起使用(我认为这足以签名)
但出现错误:
{"Error":"class java.lang.NullPointerException : null"}
我很困惑...
P.S。主要问题是: 如何准备/构建数据以传递给API /wallet/broadcasthex?
答案 0 :(得分:0)
Protobuf必须由protobuf库处理。使用字段获取/设置方法。 不是二进制Concat。