web3-plugin-count-transaction
v1.3.0
Published
This plugin returns the number of transactions for for any given Ethereum address
Downloads
6
Readme
CountTransactionPlugin
CountTransactionPlugin
It is a Web3.js plugin that allows counting the number of transactions for a given Ethereum contract address.
Requirements
- Node.js
- Web3.js
Installation
You can install the plugin via npm:
npm install web3-plugin-count-transaction
Usage
Example :
import Web3 from "web3"; import { CountTransactionPlugin } from "count-transaction-plugin";
- you can use this provider or any provider.
const web3 = new Web3("https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID");
- need to create object and bind it to the previous Web3 object.
const countTransactionPlugin = new CountTransactionPlugin("YOUR_CONTRACT_ADDRESS");
web3.extend({ property: 'countTrans', methods: [ { name: 'getCountTrans', call: 'eth_getTransactionCount', params: 1 } ] });
use plugin.
web3.countTrans.getCountTrans("YOUR_CONTRACT_ADDRESS").then((count) => { console.log("Number of transactions:", count); });