@portkey/contracts
Installation
Using NPM
npm install @portkey/contracts
Using Yarn
yarn add @portkey/contracts
Prerequisites
Package.json Scripts
Script | Description |
---|
clean | Uses rm to remove dist/ |
build | Uses tsc to build package and dependent packages |
lint | Uses eslint to lint package |
lint:fix | Uses eslint to check and fix any warnings |
format | Uses prettier to format the code |
Basic Usage
import { getContractBasic } from '@portkey/contracts'
const contract = await getContractBasic({
chainType: 'aelf',
account: 'your account',
contractAddress: 'contractAddress',
caContractAddress: 'caContractAddress',
callType: 'ca',
caHash: 'caHash',
rpcUrl: 'rpcUrl',
});
const contract = await getContractBasic({
account: 'your account',
contractAddress: 'contractAddress',
chainType: 'aelf',
rpcUrl: 'rpcUrl',
})
import detectProvider from '@portkey/detect-provider';
const provider = await detectProvider();
const chainProvider = await provider.getChain('AELF');
const contract = await getContractBasic({
chainProvider,
contractAddress: 'contractAddress',
});
contract.callViewMethod('your method', paramsOption);
contract.callSendMethod('your method', 'your address', paramsOption);
standard types
contract types