UNPKG

@dahlia-labs/use-ethers

Version:
18 lines 562 B
import { getAddress } from "@ethersproject/address"; import { Contract } from "@ethersproject/contracts"; export function getContract(address, ABI, provider) { if (!isAddress(address)) { throw Error(`Invalid 'address' parameter '${address}'.`); } return new Contract(address, ABI, provider); } // returns the checksummed address if the address is valid, otherwise returns false export function isAddress(value) { try { return getAddress(value); } catch { return false; } } //# sourceMappingURL=contracts.js.map