0

Sorry I probably create a topic that was answered multiple times but unfortunately I couldn't find a solution. I'm trying to use RPC server of Geth to send a raw transaction. I've an address with a balance enough and a private key for that address, so I'm trying to call sendRawTransaction and it throws an error "insufficient funds for .. blabla". I have encoded the raw transaction correctly (I believe) since rlpdump shows a correct output. Please help me to find a reason what is happening

  • What do I have:
    1. The latest version of Geth is running in the fast mode
    2. 99.99% synchronization
    3. An address with 0.5 Ether and a private key of that address
    4. An address of a recipient
    5. C++ client application that uses the RPC server of Geth

I encoded the following fields of the raw transaction according to RLP:

  • Nonce (since there weren't any transactions from the address I've set it to 0x0)
  • Gas price (Getting it from RPC server by appropriate method, 0x3b9aca00 Wei)
  • Gas limit (Getting it from the latest block, now it is 5000)
  • Address of the recipient
  • Amount in Wei (I'm trying to send 0.05 Ether so it's 0xb1a2bc2ec50000 Wei)
  • Empty string

Then I calculate Keccak-256 hash from that RLP encoded byte array and sign the hash by the private key by using ECDSA from OpenSSL. Afterwards I append V value to the RLP encoded byte array (V = chaindID * 2 + 35 = 37) and both R and S from calculated signature.

Then I convert the total byte array to hex string, prepend it with 0x prefix and send it to the RPC Server by JSON RPC request eth_sendRawTransaction. And finally I get the error insufficient funds. Please any ideas how to solve it, thanks in advance

P.S.: Please don't show me examples of EthereumJS usage and same libraries for other languages, I don't need any libraries, I'm just trying to understand how should it work in details

UPD: The problem was in wrong signature calculation

6
  • 3
    Possible duplicate of Why is my ether balance 0 in geth, even though the sync is nearly complete?
    – Ismael
    Jun 19, 2019 at 18:44
  • You will not be able to send transaction if the synchronization has not finished.
    – Ismael
    Jun 19, 2019 at 18:45
  • I thought there is a miner only can obtain a fully synchronized node. I've tried the light mode but there were some problems with getTransaction and getBlock methods, I don't remember exact error messages. For example, in Bitcoin I could send a transaction while the blockchain is not synchronized fully
    – G-Virus
    Jun 19, 2019 at 20:48
  • By the way, I tried to push a raw transaction data to Etherscan.io, and it says also insufficient funds
    – G-Virus
    Jun 19, 2019 at 20:51
  • It is strange that Etherscan.io fails... can you try to decode a sample raw transaction with blockchains.tools/rawTransactionDecoder?l=ETH? perhaps the RLP encoding is wrong, also there are certain requirements that have to be enforced when ECDSA signing in Ethereum s<n/2 (where is the parameter from ECDSA). As an alternative to running your node you can use Infura.io.
    – Ismael
    Jun 21, 2019 at 18:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.