AnswerBun.com

eth.sendTransaction successful or not?

Ethereum Asked by askingtoomuch on December 25, 2020

I sent 1 ETH on a private chain from node1 to node2.

>eth.sendTransaction({
from: "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b",
gasPrice: "5000000000",
gas: "21000",
to: '0xdba556d4250060d8be5abc82f50653430cee5769',
value: "1000000000000000000",
data: ""
}, 'password')

Result (TxHash)

"0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9129205"

But when I check TxHash

> eth.getTransaction("0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9129205")
{
  blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  blockNumber: null,
  from: "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b",
  gas: 21000,
  gasPrice: 5000000000,
  hash: "0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9129205",
  input: "0x",
  nonce: 8,
  r: "0xbe40d0d29d00b48459ba36933eec4338065d2eb5511855316b8fa237c43c95ca",
  s: "0x568b749c609e9dfea9d35fad8e372a747a6eeedb58bbecd20103f8a2dd88cce3",
  to: "0xdba556d4250060d8be5abc82f50653430cee5769",
  transactionIndex: 0,
  v: "0x9c8",
  value: 1000000000000000000
}

And check the number of transaction of the recipient,

> eth.getTransactionCount("0xdba556d4250060d8be5abc82f50653430cee5769")
0

Was the transaction successful?

genesis.json

{
    "config": {
   "chainID": 1234,
   "homesteadBlock": 0,
   "eip155Block": 0,
   "eip158Block": 0
 },
 "alloc": {
    "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b": {
      "balance": "100000000000000000000000000000"
    }
 },
 "difficulty": "0x4000",
 "gasLimit": "0xffffffff",
 "nonce": "0x0000000000000000",
 "coinbase": "0x0000000000000000000000000000000000000000",
 "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "extraData": "0x123458db4e347b1234537c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
 "timestamp": "0x00"
}

Transaction receipt:

> eth.getTransactionReceipt("0xfd723065f3c389b91d379450caad235066762c53749780459                       218218ff9129205")
{
  blockHash: "0x305262bbae04f2646d55724c4e87e836e558cc2c30bd874c2b2c768622113832                       ",
  blockNumber: 30198,
  contractAddress: null,
  cumulativeGasUsed: 21000,
  from: "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b",
  gasUsed: 21000,
  logs: [],
  logsBloom: "0x0000000000000000000000000000000000000000000000000000000000000000                       00000000000000000000000000000000000000000000000000000000000000000000000000000000                       00000000000000000000000000000000000000000000000000000000000000000000000000000000                       00000000000000000000000000000000000000000000000000000000000000000000000000000000                       00000000000000000000000000000000000000000000000000000000000000000000000000000000                       00000000000000000000000000000000000000000000000000000000000000000000000000000000                       000000000000000000000000000000000000000000000000",
  root: "0xafbb5fe68186740e11cab692ad5c3b88a1b450cc27f93a2a627138a8a347d155",
  to: "0xdba556d4250060d8be5abc82f50653430cee5769",
  transactionHash: "0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9                       129205",
  transactionIndex: 0
}

2 Answers

Personally, I would not rely on getTransactionCount to verify if a transaction was successful. I would check the balance of the receiving address using getBalance.

> eth.getBalance("0xdba556d4250060d8be5abc82f50653430cee5769")

or, if you want to use web3 https://web3js.readthedocs.io/en/1.0/web3-eth.html#getbalance

Answered by j4ys0n on December 25, 2020

It's because getTransactionCount(address) returns the number of transactions sent from the address. You are passing the address which received the eth so its count will be 0. If you try with 0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b, it should give you 1.

Answered by Elisha Drion on December 25, 2020

Add your own answers!

Related Questions

Verifying Signatures from other ECC Curves with ecRecover

1  Asked on August 26, 2021 by notoriousj

 

Geth Providing error on its directory path

1  Asked on March 2, 2021 by sahitya-kumar-suman

       

What storage is assigned to mappings in solidity?

1  Asked on February 27, 2021 by trevor-lee-oakley

   

Metamask not allowing any transaction by code

1  Asked on February 26, 2021 by shoaib-iqbal

 

The blockchain trilemma

1  Asked on February 26, 2021

   

History of Ethereum

1  Asked on February 22, 2021 by phil-boltt

 

Transferring an ERC-20 using web3js 1.0.0

1  Asked on February 21, 2021 by john-murphy

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP