0

I am trying to implement the BlockCypher Ethereum API following the docs here: https://www.blockcypher.com/dev/ethereum/#transaction-api

I am using the Test Network /beth/test, rather than /eth/main.

I successfully created 2 addresses and called the faucet to fill one address with some 1000000000000000000 wei.

But then I can’t seem to be able to send a valid transaction… Here are all (test) info:

ADDRESS 1

{
"private": "42eb005cbebd33f55b821864fcdc0755876317345ac9d8ad2bf94d734f78395f",
"public": "04c7238abb2e99c50ef3e4fabe21dbf2701f9dc60de24b40e743e84745984957ba7059a3e0b38c226b3580a95ed0e154fba407d089f5c02f90aa5797ead7fc190e",
"address": "7a9373010ce86d8fcd7dd46588d351cddabe7ce8"

}

ADDRESS 2

{
"private": "4a62456df43b89244d349948008064cfe1279ef3a632823f30b371ac54f879a1",
"public": "046c01b338e3c5224aa70fa302fefa5c9767d0f79aa16327e703d01924e894809460b22ab52974706543682d8e16063fd6cbd302b052762a3be5d7720efc4d2fa9",
"address": "73befec27510c64c303d82191eaf276a94603090"

}

Address 2 contains 1000000000000000000 wei, and I am trying to send 1200000000000000 wei to Address 1.

I use the New Transaction method, I send this:

{"inputs":[{"addresses": ["73befec27510c64c303d82191eaf276a94603090"]}],"outputs":[{"addresses": ["7a9373010ce86d8fcd7dd46588d351cddabe7ce8"], "value": 1200000000000000}]}

And I get this response:

{
"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"
]

}

Then I use Signer with the ToSign from the New Transaction response, and a Hex-Encoded Private Key of Address 2:

signer 8b765bd6c2065f612eb00aa55c50759049779cff50151395aefc5a3dafa5cc10 34613632343536646634336238393234346433343939343830303830363463666531323739656633613633323832336633306233373161633534663837396131

I get this signature:

30440220644db87755b0a8620e7e52bd64977c79350c0989afd587090be13a8f76efbf3a0220463eb6351c839b086f5874f6a125ec4723fb30eb26a6a831600cb4d3034cd9d3

So then I try the Send Transaction method of BlockCypher, here’s my request:

{
"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"]

}

And I get back this error:

"Address 0xF6A14d976c86bDbe050cA9426aD491d750be33B1 computed from signature differs from provided one 73befec27510c64c303d82191eaf276a94603090."

Any idea of what am I doing wrong?

I tried several things already, read a few similar issues online, but still no luck.

I also tried the Raw Transaction method of BlockCypher, and also no luck there..

I am not clear what it means as “raw hex-encoded transaction”, I tried to send the Hex-Encoded input I sent to New Transaction:

{"inputs":[{"addresses": ["73befec27510c64c303d82191eaf276a94603090"]}],"outputs":[{"addresses": ["7a9373010ce86d8fcd7dd46588d351cddabe7ce8"], "value": 1200000000000000}]}

So I sent to https://api.blockcypher.com/v1/beth/test/txs/push?token=[mytoken] this:

{"tx":"22696E70757473223A5B7B22616464726573736573223A205B2237336265666563323735313063363463333033643832313931656166323736613934363033303930225D7D5D2C226F757470757473223A5B7B22616464726573736573223A205B2237613933373330313063653836643866636437646434363538386433353163646461626537636538225D2C202276616C7565223A20313230303030303030303030303030307D5D"}

But I get the error:

“rlp: expected input list for types.TxData”.

Please, any help is very much appreciated!

0

The private key you're passing to the signer tool (3461...) does not match either addresses you're using for the transaction. As Address 2 is the sender in your example, you should be using its private key instead (4a62...).

| improve this answer | |
  • Thanks Matthieu, I appreciate it! the Sender private key is 4a62456df43b89244d349948008064cfe1279ef3a632823f30b371ac54f879a1, I hex encode this and get 34613632343536646634336238393234346433343939343830303830363463666531323739656633613633323832336633306233373161633534663837396131. Then I send this to signer along with the hex encoded "tosign" that from 8b765bd6c2065f612eb00aa55c50759049779cff50151395aefc5a3dafa5cc10 becomes 8b765bd6c2065f612eb00aa55c50759049779cff50151395aefc5a3dafa5cc10. They should be both hex encoded, right? – noiseFree Jun 20 '18 at 17:08
  • Yes, but the private key we return is already hex encoded. So you can provided it as-is to the signer. You only need to hex-encode if you start with binary data (or convert if if you have formats, like WIF). – Matthieu Jun 20 '18 at 19:35
  • That's it! darn.. thanks so much, I did not realize that. – noiseFree Jun 20 '18 at 20:41
  • Both tosign and private key seems already hex encoded... i simply passed both to signer and it works. – Sohan Feb 17 '19 at 5:19
0

You don't need to put in the

"pubkeys": ["046c01b338e3c5224aa70fa302fefa5c9767d0f79aa16327e703d01924e894809460b22ab52974706543682d8e16063fd6cbd302b052762a3be5d7720efc4d2fa9"],

at the end.

I haven't used the test net for eth... but since they say its the same thing...

try this instead.

curl -sd '{ "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" ], "signatures": ["30440220644db87755b0a8620e7e52bd64977c79350c0989afd587090be13a8f76efbf3a0220463eb6351c839b086f5874f6a125ec4723fb30eb26a6a831600cb4d3034cd9d3"]}' https://api.blockcypher.com/v1/beth/test/txs/send?token=yourblockcyphertoken

you might need to create a new txskeleton... I don't know how long they are valid for... but since you got that part down, shouldn't be a problem. just sign the new tosign string with the signer and should be good.

| improve this answer | |
  • Unfortunately even without the pubkeys I get the same error.. I really can't figure out what is wrong. thinking of using another API and way to do eth transactions at this point.. but thank you for the reply! – noiseFree Jun 20 '18 at 11:35
0

"input" is the receiver & "output" is the sender. In your example you have that backwards. The signer PK must match the "output" address.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.