etherscan-util
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

etherscan-util Build Status npm

This package allows creating ethers.js contract instances without manually downloading ABI: etherscanUtil.getVerifiedContractAt('<address>'). It supports Mainnet, BSC, and most testnets.

Installation

npm install etherscan-util

Usage

import ethers from "ethers";
import EtherscanUtil from "etherscan-util";
// You can also use `const EtherscanUtil = require('etherscan-util')`

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const etherscanUtil = new EtherscanUtil(provider, ETHERSCAN_API_KEY);
const contract = await etherscanUtil.getVerifiedContractAt('<address>');

It requires only contract address and will fetch the ABI for the contract automatically from Etherscan. If signer is not supplied to getVerifiedContractAt, it will initialize contract instance with provider/signer that was supplied to EtherscanUtil constructor.

Here are function definitions:

function constructor(
  providerOrSigner: ethers.providers.Provider | ethers.Signer, 
  etherscanApiKey?: string);

async function getVerifiedContractAt(
  address: string,
  signer?: ethers.Signer
): Promise<ethers.Contract>;

Package Sidebar

Install

npm i etherscan-util

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

24.6 kB

Total Files

23

Last publish

Collaborators

  • semenov.roman