import { rootStore, useStore } from '@/store/index';
const { god } = useStore()
// or const god = rootStore.god
god.currentChain.chainId // for current connected chain id
god.currentChain.Coin // eth/bnb/iotx
god.currentChain.Coin.balance // current balance
god.currentNetwork.account // for current connected account address
god.setShowConnecter() // to show/close the Wallet Selector
god.currentNetwork.loadBalance() // to load chain coin balance
god.currentNetwork.multicall() // main function to batch read state from contract
god.currentNetwork.execContract() // main function to execute contract
// multicall/execContract example
import ERC20ABI from "..."
address: "0x810ee35443639348adbbc467b33310d2ab43c168",
balance: new BignumberState({}),
const {address, abi} = newToken
await god.currentNetwork.multicall([
{ address, abi, method: 'symbol', handler: (v: any) => (newToken.symbol = v.toString()) },
{ address, abi, method: 'name', handler: (v: any) => (newToken.name = v.toString()) },
{ address, abi, method: 'decimals', handler: (v: any) => (newToken.decimals = Number(v.toString())) },
{ address, abi, method: 'balanceOf', params:[god.currentNetwork.account] handler: newToken.balance},
await god.currenNetwork.execContract({adderss,abi,method:"transfer", params:["0x", "100000000000000000"]})
await god.currenNetwork.execContract({adderss,abi,method:"approve", params:["0x", "100000000000000000"]})
// to help share the bignumber between on function and UI
import BN from 'bignumber.js';
import { BigNumberState } from '@/store/standard/BigNumberState';
const tokenAmount = new BigNumberState({value: new BN(1000000000000000000), decimals: 18 })
console.log(tokenAmount.value.toFixed(0), tokenAmount.format)
// 1000000000000000000, 1
tokenAmount.setValue(new BN(2000000000000000000))
// 2000000000000000000, 2