7

Here is my transaction from ethereum.

transaction is shown as followed

{
    blockNumber:12,
    contractAddress:null,
    cumulativeGasUsed:22977,
    gasUsed:22977,
    status:1,
    transactionIndex:0,
tx:"0x92c1ec18a97bce88fca9649711280ec84241cd230ffa5dc51485a6637b238fc0"

}

Using the code below gives me a error,

var count = web3.eth.getTransactionCount(tx);


Error: Provided address "0x92c1ec18a97bce88fca9649711280ec84241cd230ffa5dc51485a6637b238fc0" 
is invalid, the capitalization checksum test failed, or its an indrect 
IBAN address which can't be converted.

update I changed the transaction hash to the eth address, the call returns me

{
    _bitField:33554432
    _fulfillmentHandler0:undefined
    _promise0:undefined
    _receiver0:undefined
    _rejectionHandler0:155
}

instead of the count value

what is the problem?

user824624
  • 579
  • 1
  • 8
  • 25

1 Answers1

2

txin your example is the transaction hash. Function getTransactionCount(...), however, needs an account as parameter.This is what is recognized, therefore the error.

If you want to get more information on the transaction, use web3.eth.getTransaction(tx). Here, tx has to be the transaction hash.

gisdev_p
  • 1,801
  • 1
  • 9
  • 18
  • by using web3.eth.getTransaction(tx), can I get the nouce for the transaction? – user824624 Nov 24 '17 at 08:24
  • Yes, you can get the nonce and all other parameters related to the transaction, see here: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgettransaction – gisdev_p Nov 24 '17 at 08:28
  • I tried the eth address, but can't get the counting value. (question updated) – user824624 Nov 25 '17 at 07:19
  • Looks like you are using Node.js and missing the success callback handler. But hard to say more without knowing the code that causes this. – gisdev_p Nov 25 '17 at 08:51
  • yes, it looks like a callback. but from its api, it doesn't need a callback handler – user824624 Nov 25 '17 at 09:28
  • That*s true, the function can be ran synchronous as well as asynchronous (i.e. with callback) if you use javascript. If you use Node.js it seems like the asynchronous version is required or called by defaut. You can try supplying a callback function. – gisdev_p Nov 25 '17 at 10:58
  • yes, you are right, we must make a callback function :) – user824624 Nov 25 '17 at 11:00
  • @gisdev_p Hi, I have similar problem, I asked my question here : link I guess it might be because of removing callback from the code, since I was receiving error of callback is not defined. Do you have a suggestion to solve this error ? Thanks – Questioner Jul 03 '18 at 15:54