@tokensuite/chainkit
v0.3.0
Published
Chain operations
Downloads
12
Keywords
Readme
Chainkit Module
Chain operations
Installation
Yarn
yarn add @tokensuite/chainkit
NPM
npm install @tokensuite/chainkit --save
Getting Started
Let's register the ChainkitModule in app.module.ts
import { Module } from '@nestjs/common'
import { RedisModule } from '@kiwi-mobility/redis';
@Module({
imports: [
ChainkitModule.register({
defaultProvider: Network.Type.BINANCE_TESTNET,
privateKey?: PRIVATE_KEY,
providers: {
[Network.Type.BINANCE_TESTNET]: {
url: 'https://data-seed-prebsc-1-s1.binance.org:8545/',
},
},
contracts: {
[ContractNames.ERC20]: {
address: ERC20_ADDRESS,
abi: Erc20ABI,
},
},
}),
],
})
export class AppModule {}
And use in your service
import { Injectable } from '@nestjs/common';
import { Chainkit } from '@tokensuite/chainkit';
import { Erc20 } from 'types/ethers-contracts';
enum Contracts {
ERC20 = 'erc20',
}
@Injectable()
export class Service {
constructor(
private readonly chainkit: Chainkit,
) {
const erc20 = chainkit.contract<Erc20>(ContractNames.ERC20);,
// OR
const erc20 = chainkit.contract<Erc20>({
address: '',
abi: ABI,
network: Network.Type.ETHEREUM,
});
erc20.getOwner();
erc20.transfer(
'0xAA429559357E576A940663dfB1c5C98AAC3c8cb8',
'0',
);
const erc721 = chainkit.contract<Erc20>({
});
}
}