@5ire/api-contract 中文文档教程
@polkadot/api-contract
允许对 Substrate 合约 ABI 进行编码和解码的接口。
import {ApiPromise, WsProvider } from '@5ire/api';
import { Abi } from '@5ire/api-contract';
const wsProvider = new WsProvider(<...Node Url...>);
const api = await ApiPromise.create({ provider: wsProvider });
const abi = new Abi(<...JSON ABI...>, api.registry.getChainProperties());
api.tx.contracts
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
.signAndSend(<keyring pair>, (result: SubmittableResult) => { ... });
@polkadot/api-contract
Interfaces to allow for the encoding and decoding of Substrate contract ABIs.
import {ApiPromise, WsProvider } from '@5ire/api';
import { Abi } from '@5ire/api-contract';
const wsProvider = new WsProvider(<...Node Url...>);
const api = await ApiPromise.create({ provider: wsProvider });
const abi = new Abi(<...JSON ABI...>, api.registry.getChainProperties());
api.tx.contracts
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
.signAndSend(<keyring pair>, (result: SubmittableResult) => { ... });