1

I want to do a very simple operation: send eth to another address.

Here is what I did:

Method 1 . use personal.send_transaction JSON-RPC interface. ( seems deprecated )

I run:

curl --request POST   --data '{
    "jsonrpc":"2.0",
    "method":"personal_sendTransaction",
    "params":[
      {
        "gas": "0x5208",
        "gasPrice": "0x178411b200",
        "from": "0x7CCfaF74ADBA37b2eF11B4caa3ce3759xxxxxxxx",
        "to": "0x3Ae7a18407B17037B2ECC4901c1b77Dbxxxxxxxx",
        "value": "0x4f94ae6af8000"
      },
      "my_pass_word"
    ],
    "id": 4004
  }'   --header 'Content-Type: application/json' http://172.16.1.53:8800

response:

{
    "jsonrpc":"2.0",
    "result":"0x76af9bc26ac39f6011c76c3adf2914ab8b677ad95a8687ed0b3de058d4866bb6",
    "id":4004
}

however, this tx could NOT be found in etherscan.

and got this log:

2020-12-20 07:45:03 UTC http.worker10 WARN rpc  personal_sendTransaction is deprecated and will be removed in future versions: Account management is being phased out see #9997 for alternatives.
2020-12-20 07:45:03 UTC http.worker10 DEBUG own_tx  Imported to the pool (hash 0x76af9bc26ac39f6011c76c3adf2914ab8b677ad95a8687ed0b3de058d4866bb6)
2020-12-20 07:45:03 UTC http.worker10 DEBUG txqueue  [0x76af9bc26ac39f6011c76c3adf2914ab8b677ad95a8687ed0b3de058d4866bb6] Added to the pool.
2020-12-20 07:45:03 UTC http.worker10 DEBUG txqueue  [0x76af9bc26ac39f6011c76c3adf2914ab8b677ad95a8687ed0b3de058d4866bb6] Sender: 0x7ccf…xxxx, nonce: 887, gasPrice: 101000000000, gas: 21000, value: 1400000000000000, dataLen: 0))
2020-12-20 07:45:03 UTC IO Worker #1 DEBUG sync  Finished transaction propagation, took 0ms
2020-12-20 07:45:03 UTC http.worker10 DEBUG txqueue  Re-computing pending set for block: 11475896
2020-12-20 07:45:03 UTC http.worker10 DEBUG miner  Attempting to push 1 transactions.
2020-12-20 07:45:03 UTC http.worker10 DEBUG miner  Adding tx 0x76af9bc26ac39f6011c76c3adf2914ab8b677ad95a8687ed0b3de058d4866bb6 took 3 ms
2020-12-20 07:45:03 UTC http.worker10 DEBUG miner  Pushed 1 transactions in 3 ms
2020-12-20 07:45:03 UTC http.worker10 DEBUG rpc  [Some(Num(4004))] Took 42ms
2020-12-20 07:45:03 UTC http.worker10 DEBUG rpc  Response: {"jsonrpc":"2.0","result":"0x76af9bc26ac39f6011c76c3adf2914ab8b677ad95a8687ed0b3de058d4866bb6","id":4004}.

method 2. called eth_sendRawTransaction to my local ETH node.

I did this following the steps:

Step 2.1 got the private key ( really correct, I promise, I got this via 2 language API , and they are the same! )

<my_private_key>

Step 2.2 got the signed tx by my code:

const get_raw_tx = function(params){

  console.info("== params:")
  console.info(params)
  const privateKey = Buffer.from(
    params.private_key,
    'hex',
  )

  const txParams = { 
    nonce: params.nonce,
    gasPrice: params.gas_price,
    gasLimit: params.gas_limit,
    to: params.to_address,
    value: params.crypto_amount,
    data: params.data,
  }

  const tx = new EthereumTx(txParams, { chain: 'mainnet', hardfork: 'petersburg' })
  tx.sign(privateKey)
  const serializedTx = tx.serialize()
  const rawTx = '0x' + serializedTx.toString('hex');
  return rawTx
}

and HTTP GET method:

  • crypto_amount: 0.0013 ETH
  • gas_limit: 21000, in hex: 0x5208
  • gas_price: 121000000000 ( 121 Gwei) , in hex: 0x1c2c297a00
$ curl http://localhost:8000/get_tx?private_key=MY_PRIVATE_KEY&nonce=0x01&gas_price=0x1c2c297a00&gas_limit=0x2710&to_address=0xC6d64494D2042B69aceAd368395f8e4Fxxxxxxxx&crypto_amount=1300000000000000

and got this signed TX string:

0xf86d820d1b851c2c297a00825208943ae7a18407b17037b2ecc4901c1b77db98367cda87049e57d63540008026a07931b78f0f596f49655d2c0418156f742ffab64cb2c545616d1f3843e4f4f778a026d63f88d6166ec32223c1e850fb9245e4b5df6d50237080684fc933e7ac0e4b

Step 2.3 I make a JSON-PRC call like this:

curl --location --request POST 'http://my-server-ip:port'   --header 'Content-Type: application/json'   --data-raw '{
    "jsonrpc":"2.0",
    "method":"eth_sendRawTransaction",
    "params":["0xf86d820d1b851c2c297a00825208943ae7a18407b17037b2ecc4901c1b77db98367cda87049e57d63540008026a07931b78f0f596f49655d2c0418156f742ffab64cb2c545616d1f3843e4f4f778a026d63f88d6166ec32223c1e850fb9245e4b5df6d50237080684fc933e7ac0e4b"],
    "id": 4004
  }'

and this is the response:

{
    "jsonrpc":"2.0",
    "result":"0x06a1958e25ef269346cc79043c4c4343b9df86bf0b135c257b9b7077e7d83bc7",
    "id":4004
}

this tx still could not be found on ( http://etherscan.io/tx/0x06a1958e25ef269346cc79043c4c4343b9df86bf0b135c257b9b7077e7d83bc7 )

no error or warning in log.

method 3. called infura API

curl https://mainnet.infura.io/v3/MY-PROJECT-ID     
    -X POST
    -H "Content-Type: application/json"
    -d '{
         "jsonrpc":"2.0",
         "method":"eth_sendRawTransaction",
         "params":["0xf86d820d1b851c2c297a00825208943ae7a18407b17037b2ecc4901c1b77db98367cda87049e57d63540008026a07931b78f0f596f49655d2c0418156f742ffab64cb2c545616d1f3843e4f4f778a026d63f88d6166ec32223c1e850fb9245e4b5df6d50237080684fc933e7ac0e4b"],
         "id":1
       }'

and got response from infura:

{
    "jsonrpc":"2.0",
    "id":1,
    "result":"0x5809db5cdbdab054ca7f5f383e59ba6df74e3f5e87a33b90df1b1c6e7d0ae587"
}

still, this TX could not be found on etherscan.io

so, could someone help me, why all these methods are failed.

thanks a lot!

p.s.

my environment

Ubuntu 18.04 server

client: openethereum ( OpenEthereum/v3.0.1-stable-8ca8089-20200601/x86_64-unknown-linux-gnu/rustc1.43.1 )

command to launch it: nohup ./openethereum &

config file: ( in .local/share/openethereum/config.toml)

[parity]
mode = "active"
identity = "lueluelue"
[rpc]
apis = ["web3", "eth", "pubsub", "net", "parity", "parity_pubsub", "traces", "rpc", "shh", "shh_pubsub", "personal", "parity_accounts", "secretstore"]
server_threads = 2

port = 8800
interface = "172.my.i.p"

[websockets]
apis = ["web3", "eth", "pubsub", "net", "parity", "parity_pubsub", "traces", "rpc", "shh", "shh_pubsub", "personal"]

[misc]
log_file = "/home/ubuntu/eth.log"
logging = "debug"

[mining]
min_gas_price = 1 

and I ran the JSON-RPC calls when the block is not completed synced. ( synced to 1 days ago)

6
  • Which ethereum client are you using? geth, openethereum, besu, .... What's the command line used to launch it? Is the client fully synchronized? Is the nonce correct? – Ismael Dec 20 '20 at 21:22
  • I am using openethereum ( OpenEthereum/v3.0.1-stable-8ca8089-20200601/x86_64-unknown-linux-gnu/rustc1.43.1), the command line lauching it is ohup ./openethereum &, and I will update my question and put this information on it. – Siwei Dec 20 '20 at 23:10
  • @Ismael Is it because I run the JSON-RPC calls on the in-completed synced node? should I wait until it's fully synced? and I am doubting that my signed tx is incorrect. how to check it? thanks a lot! – Siwei Dec 20 '20 at 23:20
  • You can use eth_getBlockByNumber to obtain the latest block number it should be close to the latest block in any block explorer like etherscan. – Ismael Dec 22 '20 at 3:52
  • OK, I will try. thanks ! – Siwei Dec 22 '20 at 12:11
0

OK I got it: the parameter nonce is important!

My fault: I randomly give the nonce parameter, which is not valid in some way. ( I don't know )

After searching many posts, I found the nonce is important! ( according to https://nonseodion.medium.com/7-easy-steps-to-resolve-cancel-pending-ethereum-transactions-88d7d8bce053 , this post talks about the relation ship between nonce and pending transactions )

also this post: https://info.etherscan.com/how-to-cancel-ethereum-pending-transactions mentioned nonce.

so, to make clear which number should be my address, I created a transaction using MetaMask, and very soon, I got its state:

0.204465275198051046 Eth
Nonce: 912

0.202643275198051046 Eth
Nonce: 913     <!---  this should be your next transaction's nonce! 

enter image description here

So I changed my code, specified the correct nonce , and then my new signed transaction broadcasted in 3 seconds!

^_^

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.