@magnaflow/contract-sdk
v1.0.2
Published
Standardized contract interaction SDK for multi-chain smart contracts
Maintainers
Readme
@magnaflow/contract-sdk
Contract call helpers built on top of @magnaflow/chain-provider.
What It Provides
ContractManagerfor low-level read, write, and gas estimationContractCalleras a thin convenience wrapper- EIP-712 digest signing with
signDigest - Standard MagnaFlow error selector parsing
- Bundled ABIs for payout and ERC-20 flows
Install
npm install @magnaflow/contract-sdkKey Exports
ContractManagerContractCallersignDigestparseEvmErrorparseContractErrorcreateFriendlyErrorMessageMAGNAFLOW_ERROR_SELECTORSpayout_new_abiORDER_STRUCT_TYPEERC20_ABI
Example
import { ContractCaller, ERC20_ABI } from '@magnaflow/contract-sdk';
import { createChainProvider } from '@magnaflow/chain-provider';
const provider = createChainProvider(chainConfig, process.env.MNEMONIC);
const caller = new ContractCaller(provider);
const balance = await caller.call({
address: '0x55d398326f99059fF775485246999027B3197955',
abi: ERC20_ABI,
functionName: 'balanceOf',
args: ['0x1234...'],
});Notes
- EVM contract read/write is implemented.
- Tron contract read/write is not implemented in the current release and should be treated as unsupported.
Development
bunx nx run contract-sdk:lint
bunx nx run contract-sdk:test
bunx nx run contract-sdk:buildLicense
This package is part of the merchant-v2-sdk monorepo and is covered by the root MIT license.
See ../../LICENSE for details.
