web3js.eth.getTransactionCount(CONTRACT_ADDRESS+'').then( txcount => {
console.log( "-> getTransactionCount: " + txcount );
});
Always return 1, but my contract has lot of transactions. Any idea why? Thanks
web3js.eth.getTransactionCount(CONTRACT_ADDRESS+'').then( txcount => {
console.log( "-> getTransactionCount: " + txcount );
});
Always return 1, but my contract has lot of transactions. Any idea why? Thanks
getTransactionCount returns the account nonce.
For an Externally Owned Account (EOA) the nonce is the number of previously sent transactions which starts at 0 and is incremented by 1 for each transaction sent hence the name of the function getTransactionCount.
However, for Contract Accounts (CA) the nonce is the number of contract created by this contract. CA's nonce starts at 1 (since EIP-161) and is also incremented by 1 for each CREATE or CREATE2 call which creates a new contract.
Your contract never sent a single transaction because contract cannot do that. They can do message calls but the transaction is coming from an EOA. A value of 1 in that case simply means that your contract never created other contracts by means of CREATE or CREATE2, it's nonce is therefore the default value : 1.
You could check the nonce of a contract factory this as the Uniswap V2 Factory Contract to see that its nonce is greater than 1, and is incremented everytime a contract is created by this factory contract.