Create other Project

Simple Usage of the dappkit

All objects are created in a similar fashion, and we will use StakingContract as an example

Here you can create a Staking Contract with a given ERC20 Contract Address, login with metamask & connect with solidity methods available

import { Web3Connection, StakingContract } from '@taikai/dappkit';

const web3Connection = new Web3Connection({ 
    web3Host: 'WEB3_LINK'
});

await web3Connection.start();

const deployer = new StakingContract(web3Connection);
await deployer.loadAbi();

await web3Connection.connect();

const tx = await deployer.deployJsonAbi('0xCONTRACT_ADDRESS');

// Creating new Instance of StakingContract to be able to access the tokens
const stakingContract = new StakingContract(web3Connection, tx.contractAddress);
await stakingContract.start();

console.log(await stakingContract.availableTokens());

What if the contract was deployed already?

If the Contract is already deployed the use case is very similar

import { Web3Connection, StakingContract } from '@taikai/dappkit';

const web3Connection = new Web3Connection({
    web3Host: 'WEB3_LINK'
});

await web3Connection.start();

const stakingContrat = new StakingContract(web3Connection, '0xCONTRACT_ADDRESS');
await stakingContrat.start();

await web3Connection.connect();

console.log(await stakingContrat.availableTokens());

Last updated