我正在尝试按照此处的文档实现BlockCypher以太坊API: https://www.blockcypher.com/dev/ethereum/#transaction-api
我正在使用测试网络 / beth / test ,而不是 / eth / main 。
我成功创建了2个地址并调用了水龙头,用一个1000000000000000000 wei来填充一个地址。
但是我似乎无法发送有效的交易...... 以下是所有(测试)信息:
ADDRESS 1
{
"private": "42eb005cbebd33f55b821864fcdc0755876317345ac9d8ad2bf94d734f78395f",
"public": "04c7238abb2e99c50ef3e4fabe21dbf2701f9dc60de24b40e743e84745984957ba7059a3e0b38c226b3580a95ed0e154fba407d089f5c02f90aa5797ead7fc190e",
"address": "7a9373010ce86d8fcd7dd46588d351cddabe7ce8"
}
ADDRESS 2
{
"private": "4a62456df43b89244d349948008064cfe1279ef3a632823f30b371ac54f879a1",
"public": "046c01b338e3c5224aa70fa302fefa5c9767d0f79aa16327e703d01924e894809460b22ab52974706543682d8e16063fd6cbd302b052762a3be5d7720efc4d2fa9",
"address": "73befec27510c64c303d82191eaf276a94603090"
}
地址2包含1000000000000000000 wei,我正在尝试向地址1发送1200000000000000 wei。
我使用New Transaction方法,我发送:
{"inputs":[{"addresses": ["73befec27510c64c303d82191eaf276a94603090"]}],"outputs":[{"addresses": ["7a9373010ce86d8fcd7dd46588d351cddabe7ce8"], "value": 1200000000000000}]}
我收到了这个回复:
{
"tx": {
"block_height": -1,
"block_index": 0,
"hash": "4e875a673e59f0b2d16123659b3a72a8d818a7cb832c5ed1a4bbf8f5b0a4ee87",
"addresses": [
"73befec27510c64c303d82191eaf276a94603090"
],
"total": 1200000000000000,
"fees": 21000000000000,
"size": 43,
"gas_limit": 21000,
"gas_price": 1000000000,
"received": "2018-05-27T13:51:23.247159854Z",
"ver": 0,
"double_spend": false,
"vin_sz": 1,
"vout_sz": 1,
"inputs": [
{
"sequence": 0,
"addresses": [
"73befec27510c64c303d82191eaf276a94603090"
]
}
],
"outputs": [
{
"value": 1200000000000000,
"addresses": [
"7a9373010ce86d8fcd7dd46588d351cddabe7ce8"
]
}
]
},
"tosign": [
"8b765bd6c2065f612eb00aa55c50759049779cff50151395aefc5a3dafa5cc10"
]
}
然后我使用Signer和New Transaction响应中的ToSign,以及地址2的Hex编码私钥:
signer 8b765bd6c2065f612eb00aa55c50759049779cff50151395aefc5a3dafa5cc10 34613632343536646634336238393234346433343939343830303830363463666531323739656633613633323832336633306233373161633534663837396131
我收到了这个签名:
30440220644db87755b0a8620e7e52bd64977c79350c0989afd587090be13a8f76efbf3a0220463eb6351c839b086f5874f6a125ec4723fb30eb26a6a831600cb4d3034cd9d3
然后我尝试了BlockCypher的Send Transaction方法,这是我的请求:
{
"tx": {
"block_height": -1,
"block_index": 0,
"hash": "4e875a673e59f0b2d16123659b3a72a8d818a7cb832c5ed1a4bbf8f5b0a4ee87",
"addresses": [
"73befec27510c64c303d82191eaf276a94603090"
],
"total": 1200000000000000,
"fees": 21000000000000,
"size": 43,
"gas_limit": 21000,
"gas_price": 1000000000,
"received": "2018-05-27T13:51:23.247159854Z",
"ver": 0,
"double_spend": false,
"vin_sz": 1,
"vout_sz": 1,
"inputs": [
{
"sequence": 0,
"addresses": [
"73befec27510c64c303d82191eaf276a94603090"
]
}
],
"outputs": [
{
"value": 1200000000000000,
"addresses": [
"7a9373010ce86d8fcd7dd46588d351cddabe7ce8"
]
}
]
},
"tosign": [
"8b765bd6c2065f612eb00aa55c50759049779cff50151395aefc5a3dafa5cc10"
],
"pubkeys": ["046c01b338e3c5224aa70fa302fefa5c9767d0f79aa16327e703d01924e894809460b22ab52974706543682d8e16063fd6cbd302b052762a3be5d7720efc4d2fa9"],
"signatures": ["30440220644db87755b0a8620e7e52bd64977c79350c0989afd587090be13a8f76efbf3a0220463eb6351c839b086f5874f6a125ec4723fb30eb26a6a831600cb4d3034cd9d3"]
}
我收回了这个错误:
"Address 0xF6A14d976c86bDbe050cA9426aD491d750be33B1 computed from signature differs from provided one 73befec27510c64c303d82191eaf276a94603090."
知道我做错了什么?
我已经尝试了几件事,在线阅读了一些类似的问题,但仍然没有运气。
我也尝试过BlockCypher的Raw Transaction方法,也没有运气......
我不清楚它是什么意思为“原始十六进制编码事务”,我试图发送我发送给新事务的Hex-Encoded输入:
{"inputs":[{"addresses": ["73befec27510c64c303d82191eaf276a94603090"]}],"outputs":[{"addresses": ["7a9373010ce86d8fcd7dd46588d351cddabe7ce8"], "value": 1200000000000000}]}
所以我发送了https://api.blockcypher.com/v1/beth/test/txs/push?token=[mytoken]:
{"tx":"22696E70757473223A5B7B22616464726573736573223A205B2237336265666563323735313063363463333033643832313931656166323736613934363033303930225D7D5D2C226F757470757473223A5B7B22616464726573736573223A205B2237613933373330313063653836643866636437646434363538386433353163646461626537636538225D2C202276616C7565223A20313230303030303030303030303030307D5D"}
但我收到错误:
“rlp: expected input list for types.TxData”.
拜托,非常感谢任何帮助!
答案 0 :(得分:0)
您要传递给签名者工具的私钥不正确。由于地址2在您的示例中是发件人,因此您应该改用它的私钥,即4a62456df43b89244d349948008064cfe1279ef3a632823f30b371ac54f879a1。