Common information
This package provides an ability to access and use basic smart contracts without any need to compile them manually.
List of provided smart contract interfaces:
- ERC20
- to be continued...
List of provided tokens:
- MassTransfer ERC20 compatible token
Usage
First of all, import a module
const ContractsContext =
Then there might be two ways:
- load it with node uri
const context = ContractsContext
- or inject
web3
instance directly
const context = web3 options
options
parameter should have the next layout: see parameteroptions
structure.from
,gas
andgasPrice
are needed to be provided,data
is optional.
After initial setup contracts are available to use them.
For example, to load any ERC20
-token (let use EOS token address) you need to do
const tokenAddress = "0x7b39940dbac110f1227d37c395675def270afcd7"const erc20Token = context
// to get token's total supplyconst totalSupply = await erc20Tokenmethodsconsole
// or if you want to get user's token balanceconst userAddress = "0x00000000000000000000000000000000000000b1"const balanceOf = await erc20Tokenmethodsconsole
Examples
Some example of how to use smart contracts you can find in examples directory