Skip to content

Latest commit

 

History

History
103 lines (64 loc) · 3.17 KB

DOCUMENTATION.md

File metadata and controls

103 lines (64 loc) · 3.17 KB

Multichain Database

CI TS GPLv3 license Version Downloads/week

💾 Installation

npm install @web3-systems/multiscan-client
yarn add @web3-systems/multiscan-client
git clone https://github.com/web3-systems/multiscan-client

🏎️  Quickstart

The multiscan-client library is built to support multiple Etherscan/Clonescan service API endpoints. Developers can connect to Etherscan, Polygonscan and Avalanche with a single instance.

The MultiscanClient class wraps the Etherscan API.

Updating function signatures with chainId to specify a target API endpoint.

Example

provider.getAccountBalance('0x000.0000')

is now...

multiprovider.getAccountBalance('0x000.0000', 1);

The function signature (as you can see) now consumes chainId in the last argument position.

Default Parameters

A new MultiscanClient can be initialized with defaultChainId and apikey.

Shared API Keys w/ Multiple Chain IDs

ChainId supported by a single API endpoint provider (e.x. 1,3,4,5) share an API key. In other words, if you connect to Etherscan Mainnet (chainId: 1) the Etherecan Rinkeby (chainId: 4) is also automatically available.

To connect to a new service API provider a new API key must be supplied to the client instance - along with a chainId or provider name.

Initialize

Chain IDs are mapped to service provider(s).

If chainId 1,2,3,4,5,42 is passed Etherscan is the default client.

If chainId 137,8001 is passed Polygonscan is the default client.

If chainId 43114,43114 is passed Snowtrace is the default client.

import { MultiscanClient } from '@web3-systems/multiscan-client';

const client = new MultiscanClient(1, 'etherscan-apikey');

Multiple Connections

import { MultiscanClient } from '@web3-systems/multiscan-client';

let client: MultiscanClient;

// Set API key and default client for all Etherscan API endpoints: 1,2,3,4,5
client = new MultiscanClient(1, 'etherscan-apikey');

// Sets API key for all Polygoncanscan API endpoints: 137, 80001
client.setApiKey(137, 'polygonscan-apikey');

// Get Account Balance from default MultiscanClient
const balanceEthereum = await client.getAccountBalance('0x000...000');

// Get Account Balance using optional chainId parameter
const balancePolygon = await client.getAccountBalance('0x000...000', 137);
const balanceMumbai = await client.getAccountBalance('0x000...000', 80001);

📖  Overview

Coming soon...

🧩  Examples

Coming soon...

💻  Developer Experience

The package is setup using the TSDX zero-config CLI which includes:

  • Typescript
  • Rollup
  • Jest
  • Prettier
  • ESLint