Function getContract

  • Creates a new contract instance.

    Type Parameters

    Parameters

    Returns BaseContract<T> & Omit<T, keyof BaseContract<T>>

    The contract instance.

    const provider: JSONRpcProvider = new JSONRpcProvider('https://regtest.opnet.org');
    const contract: IOP_20Contract = getContract<IOP_20Contract>(
    'bcrt1qxeyh0pacdtkqmlna9n254fztp3ptadkkfu6efl',
    OP_20_ABI,
    provider,
    );

    const balanceExample = await contract.balanceOf(
    'bcrt1pyrs3eqwnrmd4ql3nwvx66yzp0wc24xd2t9pf8699ln340pjs7f3sar3tum',
    );

    if ('error' in balanceExample) throw new Error('Error in fetching balance');
    console.log('Balance:', balanceExample.decoded);