1.0.1 • Published 2 years ago

@cuonghx.gu-tech/erc20-basic v1.0.1

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Usage

import { ERC20Basic, ERC20Basic__factory} from "erc20-basic-sdk"
import {BigNumber, ethers, Wallet} from "ethers"

const provider = new ethers.providers.JsonRpcProvider({
    url: 'https://sandbox1.japanopenchain.org:8545/'
  })

// use the concrete contract factory if you need to operate on the bytecode (ie. deploy)
async function deployTestToken(ownerPK: string): Promise<ERC20Basic> {
    const owner = new Wallet(ownerPK, provider);
    return new ERC20Basic__factory(owner).deploy(
        "TEST123",
        "TEST123",
        100,
        18
    );
}

// to call existing contracts, a factory for both the concrete contract and for the interface
// can be used since the ABI is the same
async function getTokenBalance(walletAddress: string, tokenAddress: string): Promise<BigNumber> {
    const token = ERC20Basic__factory.connect(tokenAddress, provider);
    return token.balanceOf(walletAddress);
}

Command

  • Set .env file cp .env.example .env
  • Install package npm i
  • Prepare npm run prepare
1.0.1

2 years ago

1.0.0

2 years ago