Contract
Defined in: classes/Contract.ts:159
Only accepts ABIS in JSON format. This allows for stronger typing and assurances of data-types Only read-only function calls currently supported.
Example
Section titled “Example”import { Contract, JsonRpcProvider } from 'essential-eth';// UNI airdrop contractconst contractAddress = '0x090D4613473dEE047c3f2706764f49E0821D256e';const provider = new JsonRpcProvider();// for more robust contract calls, provide a fallback:// const provider = new FallthroughProvider(['bad', 'https://free-eth-node.com/api/eth']);
const JSONABI = [ { inputs: [ { internalType: 'uint256', name: 'index', type: 'uint256', }, ], name: 'isClaimed', outputs: [ { internalType: 'bool', name: '', type: 'bool', }, ], stateMutability: 'view', type: 'function', },]
const contract = new Contract( contractAddress, JSONABI, provider,);
(async () => { // prints boolean as to whether index 0 has claimed airdrop or not console.log(await contract.isClaimed(0));})()Extends
Section titled “Extends”Indexable
Section titled “Indexable”[
key:string]:any
The function names on any given contract. Like “isClaimed”, “merkleRoot”, etc.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Contract(
addressOrName,contractInterface,signerOrProvider):Contract
Defined in: classes/Contract.ts:35
Parameters
Section titled “Parameters”addressOrName
Section titled “addressOrName”string
The ethereum address of the smart-contract
contractInterface
Section titled “contractInterface”The JSON ABI of the smart-contract (like http://api.etherscan.io/api?module=contract&action=getabi&address=0x090d4613473dee047c3f2706764f49e0821d256e&format=raw)
signerOrProvider
Section titled “signerOrProvider”An instantiated essential-eth provider
Returns
Section titled “Returns”Contract
Example
Section titled “Example”