Interface IOP_20Contract

This interface represents the OP_20 base contract. IOP_20Contract

Contracts

import { IOP_20Contract } from '../abi/shared/interfaces/IOP_20Contract.js';
import { OP_20_ABI } from '../abi/shared/json/OP_20_ABI.js';
import { CallResult } from '../contracts/CallResult.js';
import { getContract } from '../contracts/Contract.js';
import { JSONRpcProvider } from '../providers/JSONRpcProvider.js';

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);
interface IOP_20Contract {
    address: BitcoinAddressLike;
    allowance(owner: BitcoinAddressLike, spender: BitcoinAddressLike): Promise<BaseContractProperty>;
    approve(spender: BitcoinAddressLike, value: bigint): Promise<BaseContractProperty>;
    balanceOf(address: BitcoinAddressLike): Promise<BaseContractProperty>;
    burn(to: BitcoinAddressLike, value: bigint): Promise<BaseContractProperty>;
    decimals(): Promise<BaseContractProperty>;
    decodeEvent(event: NetEvent): OPNetEvent<{}>;
    decodeEvents(events: ContractEvents | NetEvent[]): OPNetEvent<{}>[];
    encodeCalldata(method: string, ...args: unknown[]): Buffer;
    isAddressOwner(address: BitcoinAddressLike): Promise<BaseContractProperty>;
    mint(to: BitcoinAddressLike, value: bigint): Promise<BaseContractProperty>;
    name(): Promise<BaseContractProperty>;
    owner(): Promise<BaseContractProperty>;
    setSender(sender: BitcoinAddressLike): void;
    symbol(): Promise<BaseContractProperty>;
    totalSupply(): Promise<BaseContractProperty>;
    transfer(to: BitcoinAddressLike, value: bigint): Promise<BaseContractProperty>;
    transferFrom(from: BitcoinAddressLike, to: BitcoinAddressLike, value: bigint): Promise<BaseContractProperty>;
}

Hierarchy (view full)

Properties

Methods