Fantom RPC
How to use it
// yarn add @tatumio/tatum
import { TatumSDK, Fantom, Network } from '@tatumio/tatum'
const tatum = await TatumSDK.init<Fantom>({ network: Network.FANTOM })
const result = await tatum.rpc.getTransactionCount('0x365a2dabcdb56f4f595c3af088b8975c26331448', 'latest')
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs
Overview
The eth_getTransactionCount
method is an method that retrieves the number of transactions sent from a given address. It is a useful method for developers who need to keep track of an account's nonce value to avoid transaction collisions or incorrect order of execution. The nonce value is essential for ensuring transaction uniqueness and preventing replay attacks.
Use cases for this method include:
- Determining the nonce value for a new transaction to be sent from a specific address
- Monitoring the number of transactions sent by an address to observe its activity
- Troubleshooting transaction issues and verifying if a transaction was submitted successfully
Parameters
The eth_getTransactionCount
method accepts two parameters:
address
- The address whose transaction count will be retrieved.- Example:
"0x82487dF5b4cF19DB597A092c8103759466Be9e5a"
- Example:
blockParameter
- A string indicating the block number or block state to consider when retrieving the transaction count.- Possible values:
"earliest"
,"latest"
,"pending"
, or a specific block number in hexadecimal format - Example:
"latest"
- Possible values:
Return Object
The method returns a single value:
transactionCount
- A hexadecimal representation of the number of transactions sent from the specified address.- Example:
"0x1e"
- Example:
JSON-RPC Request and Response Examples
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getTransactionCount",
"params": ["0x742d35Cc6634C0532925a3b844Bc454e4438f44e", "latest"]
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1e"
}