Skip to main content

Getting Contract Instance with EdexaClient

The edexaClient provides a convenient interface to interact with different types of Ethereum smart contracts. Among its functionalities, it offers two specific methods, getERC20Instance and getERC721Instance, to instantiate the ERC-20 and ERC-721 token contracts respectively. These instances allow developers to interact with the corresponding token standards with ease.


getERC20Instance Method

Description

This method allows developers to acquire an instance of an ERC-20 token contract, enabling them to interact with the contract's methods and properties.

Method Signature

getERC20Instance(contractAddress: string): ERC20Instance

Parameters

ParameterTypeDescription
contractAddressstringThe Ethereum address of the ERC-20 token contract you wish to interact with.

Returns

  • An ERC20Instance object that encapsulates the functionalities of the ERC-20 token located at the specified contract address.

Usage Example

const erc20Address = "0x4DB67190e915C15aA8CCd889F35185D73dA37878";
const erc20 = edexaClient.getERC20Instance(erc20Address);

getERC721Instance Method

Description

This method allows developers to obtain an instance of an ERC-721 token contract, thereby offering a straightforward way to interact with the unique functionalities of non-fungible tokens (NFTs).

Method Signature

getERC721Instance(contractAddress: string): ERC721Instance

Parameters

ParameterTypeDescription
contractAddressstringThe Ethereum address of the ERC-721 token contract you aim to interact with.

Returns

  • An ERC721Instance object that embodies the features of the ERC-721 token situated at the given contract address.

Usage Example

const erc721Address = "0xD519C0B20A67983896791B8bf53005292a1D2710";
const erc721 = edexaClient.getERC721Instance(erc721Address);

getStableCoinInstance Method

Description

This method is designed to create an instance of a StableCoin contract. It is useful for interacting with stablecoin contracts on the blockchain network specified by the given RPC URL.

Method Signature

getStableCoinInstance(address: string, rpc: string, provider?: any): StableCoin

Parameters

  • address: string - The address of the StableCoin contract.
  • rpc: string (optional, default = "https://testnet.edexa.com/rpc") - The RPC URL of the blockchain network.
  • provider: any (optional) - A custom provider for web3 interactions.

Return

  • Returns a new instance of StableCoin configured with the specified address and RPC.

Usage Example

const stableCoinInstance = getStableCoinInstance("0x123...", "https://mainnet.edexa.com/rpc");

Notes

  • Ensure you provide valid Ethereum contract addresses when utilizing these methods. Incorrect addresses could result in errors or unintended behavior.

  • After obtaining the respective instance (either ERC20Instance or ERC721Instance), you can call various methods pertaining to each token standard.

  • Always refer to the official documentation of the respective library and contracts to gain a deeper understanding of the functionalities and available methods.