0.3.2 • Published 6 days ago
@zomet/sdk v0.3.2
SDK for apps
Using
Ethereum based
Initialization
import { evm } from '@zomet/sdk';
import ABI from 'your/path/to/abi.json';
const contract = new evm.Contract('eth', ethContractAddress, ABI);
// you can init contract instance of standard eazier
// it is instance of Contract and it includes all of Contract properties and methods
const BEP20USDTContract = new evm.standards.ERC20('bsc', USDTAddressBEP20);
// optionally you can call the init() method
// it optimizes future calls
// and allows you to initialize additional parameters in contract instance
// also it check if address is contract
// we advise you to do this before starting work with the contract
await contract.init({
oldContractName: 'Old Token',
oldChainId: 124,
})
contract.oldContractName // "Old Token"
contract.oldChainId // 124
// also it set name, decimals, and symbol for contract if it possible
contract.name // Tether USD
contract.symbol // USDT
contract.decimals // 18
Call write method of Contract ABI
await contract.call('symbol'); // USDT
await contract.call('decimals'); // 18
await contract.call('balanceOf', walletAddress); // 22.332133244
Get wallet balance
// wrapper for contract.call('balanceOf', walletAddress)
await contract.getWalletBalance(walletAddress); // 22.332133244
Get gas price
await contract.getGasPrice(); // 6000000000 (6gwei)
Transaction Building and Transaction Gas estimation
const tx = {
method: 'transfer',
args: [recepientAddress, 1],
from: senderAddress,
value: 0, // may be if it native token sending
// you can set custom gas and gas price,
// they will added to transaction object
gas: 192380,
gasPrice: 5000000000
}
// building tranaction for signing
await contract.buildTransaction(tx);
// estimate gas for transaction, gas param shouldn't be in transaction object
contract.estimateGas(tx); // 31843
Getting user or block info from node
// https://docs.ethers.org/v5/api/providers/provider/
const provider = await contract.getProvider();
await provider.getTransactionCount(walletAddress) // 23
await provider.getBlock(766754) // block info Object
0.3.2
6 days ago
0.3.1
6 days ago
0.3.0
20 days ago
0.2.222
1 month ago
0.2.221
1 month ago
0.2.220
3 months ago
0.2.219
3 months ago
0.2.218
3 months ago
0.2.217
3 months ago
0.2.216
3 months ago
0.2.215
3 months ago
0.2.214
3 months ago
0.2.213
3 months ago
0.2.211
4 months ago
0.2.210
4 months ago
0.2.209
5 months ago
0.2.208
5 months ago
0.2.207
5 months ago
0.2.206
6 months ago
0.2.118
10 months ago
0.2.205
6 months ago
0.2.204
6 months ago
0.2.203
6 months ago
0.2.202
6 months ago
0.2.201
7 months ago
0.2.200
8 months ago
0.2.2
8 months ago
0.2.117
11 months ago
0.2.1
12 months ago
0.2.116
11 months ago
0.2.0
12 months ago
0.2.115
12 months ago
0.2.114
12 months ago
0.2.113
12 months ago
0.2.112
12 months ago
0.2.111
12 months ago
0.1.0
1 year ago