Class TokenNamespace

Class reprensenting ERC20 Token Token

Hierarchy

Constructors

Properties

Accessors

Methods

_getBonderAddress _getMessengerWrapperAddress allowance approve balanceOf checkBlocklist connect debugTimeLog eq estimateGas estimateOptimismL1FeeFromData fetchBonderAvailableLiquidityData fetchBonderAvailableLiquidityDataWithIpfsFallback fetchConfigFromS3 fetchCoreConfigData fetchCoreConfigDataWithIpfsFallback fetchIpfsBonderAvailableLiquidityData fetchIpfsCoreConfigData geConfigChains getArbChainAddress getAvailableRoutes getBumpedGasPrice getChainId getChainProvider getChainProviderUrls getChainProviders getConfigAddresses getDebugTimeLogs getDestinationFeeGasPriceMultiplier getErc20 getExplorerUrl getExplorerUrlForAccount getExplorerUrlForTransactionHash getExplorerUrlForTransferId getFeeBps getGasEstimateFromAddress getImageUrl getIpfsBaseConfigUrl getIsBridgeDeprecated getL1AmbBridgeAddress getL1BridgeAddress getL1CanonicalBridgeAddress getL1CanonicalTokenAddress getL1PosErc20PredicateAddress getL1PosRootChainManagerAddress getL2AmbBridgeAddress getL2AmmWrapperAddress getL2BridgeAddress getL2CanonicalBridgeAddress getL2CanonicalTokenAddress getL2HopBridgeTokenAddress getL2SaddleLpTokenAddress getL2SaddleSwapAddress getNativeTokenBalance getProviderRpcUrl getRelayerFee getS3ConfigData getSignerAddress getSignerOrProvider getSupportedAssets getSupportedAssetsForChain getSupportedChains getSupportedTokens getTokenBalancesForAccount getTransferStatus getTransferTimes getWethContract getWrapTokenEstimatedGas getWrappedToken isValidChain isValidNetwork needsApproval overrides populateApproveTx populateUnwrapTokenTx populateWrapTokenTx resolveDnslink sendTransaction setAvailableLiqudityJsonUrl setBaseConfigUrl setChainProvider setChainProviderUrls setChainProviders setConfigAddresses setConfigFileFetchEnabled setCoreConfigJsonUrl setGasPriceMultiplier toChainModel toJSON toTokenModel totalSupply transfer txOverrides unwrapToken wrapToken fromJSON

Constructors

  • Parameters

    • networkOrOptionsObject: string | TokenConstructorOptions

      L1 network name (e.g. 'mainnet', 'goerli')

    • Optional chain: TChain

      Chain

    • Optional address: string

      Token address.

    • Optional decimals: number

      Token decimals.

    • Optional symbol: string

      Token symbol.

    • Optional name: string

      Token name.

    • Optional image: string
    • Optional signer: Provider | Signer

      Ethers signer.

    • Optional chainProviders: ChainProviders

    Returns Token

    Token class instance.

    Desc

    Instantiates Token class.

Properties

_symbol: string
address: string
addresses: Record<string, any>
baseConfigUrl: string = defaultBaseConfigUrl
baseExplorerUrl: string = 'https://explorer.hop.exchange'
blocklist: Record<string, boolean> = null
bonders: Record<string, any>
bridgeDeprecated: Record<string, boolean>
chain: Chain
chainProviders: ChainProviders = {}
chains: Record<string, any>
configFileFetchEnabled: boolean = true
contract: Contract
customAvailableLiquidityJsonUrl: string = ''
customCoreConfigJsonUrl: string = ''
debugTimeLogsCache: any[] = []
debugTimeLogsCacheEnabled: boolean = false
debugTimeLogsEnabled: boolean = false
decimals: number
destinationFeeGasPriceMultiplier: number = 1
fees: {
    [token: string]: Record<string, number>;
}

Type declaration

  • [token: string]: Record<string, number>
gasPriceMultiplier: number = 0
getContract: ((factory, address, provider) => Promise<any>) = getContract

Type declaration

    • (factory, address, provider): Promise<any>
    • Parameters

      • factory: Factory
      • address: string
      • provider: TProvider

      Returns Promise<any>

getGasPrice: ((...args) => Promise<BigNumber>) = ...

Type declaration

    • (...args): Promise<BigNumber>
    • Parameters

      Returns Promise<BigNumber>

image: string
name: string
network: string

Network name

relayerFeeEnabled: Record<string, boolean>
relayerFeeWei: Record<string, string>
signer: TProvider

Ethers signer or provider

Accessors

  • get availableLiqudityJsonUrl(): string
  • Returns string

  • get configChains(): string[]
  • Returns string[]

  • get coreConfigJsonUrl(): string
  • Returns string

  • get supportedChains(): string[]
  • Returns string[]

  • get supportedNetworks(): string[]
  • Returns string[]

Methods

  • Parameters

    • spender: string

      spender address.

    • Optional address: string

    Returns Promise<BigNumber>

    Ethers Transaction object.

    Desc

    Returns token allowance.

    Example

    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)
  • Parameters

    • spender: string

      spender address.

    • amount: BigNumberish = ethers.constants.MaxUint256

      amount allowed to spend.

    Returns Promise<any>

    Ethers Transaction object.

    Desc

    Approve address to spend tokens if not enough allowance .

    Example

    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)
  • Parameters

    • Optional address: string

      account address.

    Returns Promise<BigNumber>

    Ethers Transaction object.

    Desc

    Returns token balance of signer.

    Example

    import { Hop, Chain } from '@hop-protocol/sdk'

    const bridge = hop.bridge('USDC').connect(signer)
    const spender = '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
    const allowance = bridge.allowance(Chain.Gnosis, spender)
  • Parameters

    • signer: Provider | Signer

      Ethers Signer for signing transactions.

    Returns Token

    New Token SDK instance with connected signer.

    Desc

    Returns a token instance with signer connected. Used for adding or changing signer.

  • Parameters

    • gasLimit: BigNumberish
    • data: string = '0x'
    • to: string = constants.AddressZero
    • destChain: string | Chain = Chain.Optimism

    Returns Promise<any>

  • Parameters

    • signer: TProvider

      Ether's Signer

    • percent: number

      Percentage to bump by.

    Returns Promise<BigNumber>

    Bumped as price as BigNumber

    Desc

    Calculates current gas price plus increased percentage amount.

    Example

    import { Hop } from '@hop-protocol/sdk'

    const hop = new Hop()
    const bumpedGasPrice = await hop.getBumpedGasPrice(signer, 1.20)
    console.log(bumpedGasPrice.toNumber())
  • Parameters

    • chain: Chain

      Chain model.

    Returns number

    • Chain ID.

    Desc

    Returns Chain ID for specified Chain model.

  • Parameters

    • chain: string | Chain

      Chain model.

    Returns any

    Ethers provider.

    Desc

    Returns Ethers provider for specified Chain model.

  • Returns Promise<any>

    Ethers contract instance.

    Desc

    Returns a token Ethers contract instance.

  • Returns Promise<string>

  • Parameters

    • Optional address: string

    Returns Promise<BigNumber>

  • Parameters

    • destinationChain: TChain
    • tokenSymbol: string

    Returns Promise<BigNumber>

  • Returns Promise<string>

    Ethers signer address.

    Desc

    Returns the connected signer address.

    Example

    import { Hop } from '@hop-protocol/sdk'

    const hop = new Hop()
    const address = await hop.getSignerAddress()
    console.log(address)
  • Parameters

    • chain: TChain

      Chain name or model

    • signer: TProvider = ...

      Ethers signer or provider

    Returns Promise<Provider | Signer>

    Ethers signer or provider

    Desc

    Returns the connected signer if it's connected to the specified chain id, otherwise it returns a regular provider for the specified chain.

  • Parameters

    • sourceChainSlug: string
    • destinationChainSlug: string

    Returns Promise<any>

  • Returns Promise<any>

  • Parameters

    Returns Promise<any>

  • Parameters

    • spender: string
    • amount: BigNumberish
    • Optional address: string

    Returns Promise<boolean>

  • Parameters

    • spender: string
    • amount: BigNumberish = ethers.constants.MaxUint256

    Returns Promise<any>

  • Parameters

    • amount: BigNumberish

    Returns Promise<any>

  • Parameters

    • amount: BigNumberish

    Returns Promise<any>

  • Parameters

    • transactionRequest: TransactionRequest
    • chain: TChain

    Returns Promise<any>

  • Parameters

    • chain: TChain

      Chain name or model.

    Returns Chain

    Chain model with connected provider.

    Desc

    Returns a Chain model instance with connected provider.

  • Returns Promise<BigNumber>

  • Parameters

    • recipient: string

      recipient address.

    • amount: BigNumberish

      Token amount.

    Returns Promise<any>

    Ethers Transaction object.

    Desc

    ERC20 token transfer

    Example

    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)
  • Parameters

    • amount: BigNumberish

    Returns Promise<any>

  • Parameters

    • amount: BigNumberish
    • estimateGasOnly: boolean = false

    Returns Promise<any>

Generated using TypeDoc