Importing ABI
ABIs
ABIs (Application Binary Interface) define the contract interface, including function signatures, parameter types, return types, and event definitions. For detailed information, refer to the Understanding ABIs section.
Built-in ABIs
The library includes pre-built ABIs for standard contract types. The table below lists the available built-in ABIs and their associated interface:
| ABI | Interface | Description |
|---|---|---|
| OP_20_ABI | IOP20Contract | Fungible tokens |
| OP_20S_ABI | IOP20SContract | Stable fungible tokens |
| OP_721_ABI | IOP721Contract | NFTs (Non-fungible tokens) |
| EXTENDED_OP721_ABI | IExtendedOP721Contract | NFTs (Non-fungible tokens) with minting features |
| MOTOSWAP_ROUTER_ABI | IMotoswapRouterContract | DEX router |
| MotoswapPoolAbi | IMotoswapPoolContract | Liquidity pools |
| MotoSwapFactoryAbi | IMotoswapFactoryContract | Pair factory |
| MOTO_ABI | IMoto | Moto token |
Importing Built-in ABIs
typescript
import {
// Token ABIs
OP_20_ABI,
OP_20S_ABI,
OP_721_ABI,
// DEX ABIs
MOTOSWAP_ROUTER_ABI,
MotoswapPoolAbi,
MotoSwapFactoryAbi,
MOTO_ABI,
// Staking ABIs
STAKING_ABI,
MOTOCHEF_ABI,
} from 'opnet';Importing Built-in Interfaces
typescript
import {
// Token interfaces
IOP20Contract,
IOP20SContract,
IOP721Contract,
IExtendedOP721Contract,
// DEX interfaces
IMotoswapRouterContract,
IMotoswapPoolContract,
IMotoswapFactoryContract,
IMoto,
} from 'opnet';Custom ABIs
Custom ABIs can also be defined for application-specific contracts.
Declaring a custom ABI
typescript
const myAbi = {
functions: [
{
name: 'myMethod',
inputs: [{ name: 'value', type: 'UINT256' }],
outputs: [{ name: 'result', type: 'BOOL' }],
},
],
events: [
{
name: 'MyEvent',
values: [{ name: 'data', type: 'UINT256' }],
},
],
};