Namespace
L1 network name (e.g. 'mainnet', 'goerli')
Optional
chain: TChainChain
Optional
address: stringToken address.
Optional
decimals: numberToken decimals.
Optional
symbol: stringToken symbol.
Optional
name: stringToken name.
Optional
image: stringOptional
signer: Provider | SignerEthers signer.
Optional
chainProviders: ChainProvidersToken class instance.
Instantiates Token class.
Readonly
addressReadonly
chainReadonly
contractReadonly
decimalsRest
...args: [signerOrProvider: TProvider]Readonly
imageReadonly
nameNetwork name
Ethers signer or provider
Protected
_getProtected
_getspender address.
Optional
address: stringEthers Transaction object.
Returns token allowance.
import { Hop, Chain } from '@hop-protocol/sdk'
const hop = new Hop('mainnet')
const bridge = hop.bridge('USDC')
const token = bridge.getCanonicalToken(Chain.Polygon)
const spender = await bridge.getSendApprovalAddress(Chain.Polygon)
const account = '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
const allowance = await token.allowance(spender, account)
console.log(allowance)
spender address.
amount allowed to spend.
Ethers Transaction object.
Approve address to spend tokens if not enough allowance .
import { Hop, Chain } from '@hop-protocol/sdk'
const bridge = hop.bridge('USDC').connect(signer)
const spender = '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
const amount = '1000000000000000000'
const tx = await bridge.approve(Chain.Gnosis, spender, amount)
Optional
address: stringaccount address.
Ethers Transaction object.
Returns token balance of signer.
import { Hop, Chain } from '@hop-protocol/sdk'
const bridge = hop.bridge('USDC').connect(signer)
const spender = '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
const allowance = bridge.allowance(Chain.Gnosis, spender)
Ether's Signer
Percentage to bump by.
Bumped as price as BigNumber
Calculates current gas price plus increased percentage amount.
import { Hop } from '@hop-protocol/sdk'
const hop = new Hop()
const bumpedGasPrice = await hop.getBumpedGasPrice(signer, 1.20)
console.log(bumpedGasPrice.toNumber())
Chain model.
Returns Chain ID for specified Chain model.
Chain model.
Ethers provider.
Returns Ethers provider for specified Chain model.
Private
getToken name or model.
Token model.
Returns a Token instance.
recipient address.
Token amount.
Ethers Transaction object.
ERC20 token transfer
import { Hop } from '@hop-protocol/sdk'
const bridge = hop.bridge('USDC').connect(signer)
const recipient = '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
const amount = '1000000000000000000'
const tx = await bridge.erc20Transfer(spender, amount)
Static
fromJSONGenerated using TypeDoc
Class reprensenting ERC20 Token Token