Skip to main content

erc20Bridger

Classes

AdminErc20Bridger

Defined in: assetBridger/erc20Bridger.ts:977

Admin functionality for the token bridge

Extends

Constructors

Constructor
new AdminErc20Bridger(childNetwork: ArbitrumNetwork): AdminErc20Bridger;

Defined in: assetBridger/erc20Bridger.ts:205

Bridger for moving ERC20 tokens back and forth between parent-to-child

Parameters
ParameterType
childNetworkArbitrumNetwork
Returns

AdminErc20Bridger

Inherited from

Erc20Bridger.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
nativeToken?readonlystringIn case of a chain that uses ETH as its native/gas token, this is either undefined or the zero address In case of a chain that uses an ERC-20 token from the parent network as its native/gas token, this is the address of said token on the parent networkErc20Bridger.nativeTokenassetBridger/assetBridger.ts:40

Accessors

nativeTokenIsEth
Get Signature
get protected nativeTokenIsEth(): boolean;

Defined in: assetBridger/assetBridger.ts:72

Whether the chain uses ETH as its native/gas token

Returns

boolean

Inherited from

Erc20Bridger.nativeTokenIsEth

Methods

approveGasToken()
approveGasToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>;

Defined in: assetBridger/erc20Bridger.ts:276

Approves the custom gas token to be spent by the relevant gateway on the parent network

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise<ContractTransaction>

Inherited from

Erc20Bridger.approveGasToken

approveToken()
approveToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>;

Defined in: assetBridger/erc20Bridger.ts:339

Approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise<ContractTransaction>

Inherited from

Erc20Bridger.approveToken

checkChildNetwork()
protected checkChildNetwork(sop: SignerOrProvider): Promise<void>;

Defined in: assetBridger/assetBridger.ts:61

Check the signer/provider matches the child network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise<void>

Inherited from

Erc20Bridger.checkChildNetwork

checkParentNetwork()
protected checkParentNetwork(sop: SignerOrProvider): Promise<void>;

Defined in: assetBridger/assetBridger.ts:50

Check the signer/provider matches the parent network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise<void>

Inherited from

Erc20Bridger.checkParentNetwork

deposit()
deposit(params: Erc20DepositParams | ParentToChildTxReqAndSignerProvider): Promise<ParentContractCallTransaction>;

Defined in: assetBridger/erc20Bridger.ts:769

Execute a token deposit from parent to child network

Parameters
ParameterTypeDescription
paramsErc20DepositParams | ParentToChildTxReqAndSignerProvider
Returns

Promise<ParentContractCallTransaction>

Inherited from

Erc20Bridger.deposit

getApproveGasTokenRequest()
getApproveGasTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>;

Defined in: assetBridger/erc20Bridger.ts:260

Creates a transaction request for approving the custom gas token to be spent by the relevant gateway on the parent network

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>

Inherited from

Erc20Bridger.getApproveGasTokenRequest

getApproveTokenRequest()
getApproveTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>;

Defined in: assetBridger/erc20Bridger.ts:306

Get a tx request to approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>

Inherited from

Erc20Bridger.getApproveTokenRequest

getChildErc20Address()
getChildErc20Address(erc20ParentAddress: string, parentProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:491

Get the corresponding child network token address for the provided parent network token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise<string>

Inherited from

Erc20Bridger.getChildErc20Address

getChildGatewayAddress()
getChildGatewayAddress(erc20ParentAddress: string, childProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:244

Get the address of the child gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
childProviderProvider
Returns

Promise<string>

Inherited from

Erc20Bridger.getChildGatewayAddress

getChildGatewaySetEvents()
getChildGatewaySetEvents(
childProvider: Provider,
filter: object,
customNetworkChildGatewayRouter?: string): Promise<object[]>;

Defined in: assetBridger/erc20Bridger.ts:1233

Get all the gateway set events on the child gateway router

Parameters
ParameterTypeDescription
childProviderProviderThe provider for the child network
filter{ fromBlock: BlockTag; toBlock: BlockTag; }An object containing fromBlock and toBlock to filter events
filter.fromBlockBlockTag-
filter.toBlock?BlockTag-
customNetworkChildGatewayRouter?stringOptional address of the custom network child gateway router
Returns

Promise<object[]>

An array of GatewaySetEvent event arguments

Throws

If the network is custom and customNetworkChildGatewayRouter is not provided

getChildTokenContract()
getChildTokenContract(childProvider: Provider, childTokenAddr: string): L2GatewayToken;

Defined in: assetBridger/erc20Bridger.ts:462

Get the child network token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesn't check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
childProviderProvider
childTokenAddrstring
Returns

L2GatewayToken

Inherited from

Erc20Bridger.getChildTokenContract

getDepositRequest()
getDepositRequest(params: DepositRequest): Promise<ParentToChildTransactionRequest>;

Defined in: assetBridger/erc20Bridger.ts:655

Get the arguments for calling the deposit function

Parameters
ParameterTypeDescription
paramsDepositRequest
Returns

Promise<ParentToChildTransactionRequest>

Inherited from

Erc20Bridger.getDepositRequest

getParentErc20Address()
getParentErc20Address(erc20ChildChainAddress: string, childProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:514

Get the corresponding parent network address for the provided child network token Validates the returned address against the child network router to ensure it is correctly mapped to the provided erc20ChildChainAddress

Parameters
ParameterTypeDescription
erc20ChildChainAddressstring
childProviderProvider
Returns

Promise<string>

Inherited from

Erc20Bridger.getParentErc20Address

getParentGatewayAddress()
getParentGatewayAddress(erc20ParentAddress: string, parentProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:226

Get the address of the parent gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise<string>

Inherited from

Erc20Bridger.getParentGatewayAddress

getParentGatewaySetEvents()
getParentGatewaySetEvents(parentProvider: Provider, filter: object): Promise<object[]>;

Defined in: assetBridger/erc20Bridger.ts:1207

Get all the gateway set events on the Parent gateway router

Parameters
ParameterTypeDescription
parentProviderProviderThe provider for the parent network
filter{ fromBlock: BlockTag; toBlock: BlockTag; }An object containing fromBlock and toBlock to filter events
filter.fromBlockBlockTag-
filter.toBlockBlockTag-
Returns

Promise<object[]>

An array of GatewaySetEvent event arguments

getParentTokenContract()
getParentTokenContract(parentProvider: Provider, parentTokenAddr: string): ERC20;

Defined in: assetBridger/erc20Bridger.ts:478

Get the parent token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesnt check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
parentProviderProvider
parentTokenAddrstring
Returns

ERC20

Inherited from

Erc20Bridger.getParentTokenContract

getWithdrawalEvents()
getWithdrawalEvents(
childProvider: Provider,
gatewayAddress: string,
filter: object,
parentTokenAddress?: string,
fromAddress?: string,
toAddress?: string): Promise<object & object[]>;

Defined in: assetBridger/erc20Bridger.ts:367

Get the child network events created by a withdrawal

Parameters
ParameterTypeDescription
childProviderProvider
gatewayAddressstring
filter{ fromBlock: BlockTag; toBlock: BlockTag; }
filter.fromBlockBlockTag-
filter.toBlock?BlockTag-
parentTokenAddress?string
fromAddress?string
toAddress?string-
Returns

Promise<object & object[]>

Inherited from

Erc20Bridger.getWithdrawalEvents

getWithdrawalRequest()
getWithdrawalRequest(params: Erc20WithdrawParams): Promise<ChildToParentTransactionRequest>;

Defined in: assetBridger/erc20Bridger.ts:826

Get the arguments for calling the token withdrawal function

Parameters
ParameterTypeDescription
paramsErc20WithdrawParams
Returns

Promise<ChildToParentTransactionRequest>

Inherited from

Erc20Bridger.getWithdrawalRequest

isDepositDisabled()
isDepositDisabled(parentTokenAddress: string, parentProvider: Provider): Promise<boolean>;

Defined in: assetBridger/erc20Bridger.ts:560

Whether the token has been disabled on the router

Parameters
ParameterTypeDescription
parentTokenAddressstring
parentProviderProvider
Returns

Promise<boolean>

Inherited from

Erc20Bridger.isDepositDisabled

isRegistered()
isRegistered(params: object): Promise<boolean>;

Defined in: assetBridger/erc20Bridger.ts:924

Checks if the token has been properly registered on both gateways. Mostly useful for tokens that use a custom gateway.

Parameters
ParameterTypeDescription
params{ childProvider: Provider; erc20ParentAddress: string; parentProvider: Provider; }
params.childProviderProvider
params.erc20ParentAddressstring
params.parentProviderProvider
Returns

Promise<boolean>

Inherited from

Erc20Bridger.isRegistered

registerCustomToken()
registerCustomToken(
parentTokenAddress: string,
childTokenAddress: string,
parentSigner: Signer,
childProvider: Provider): Promise<ParentContractTransaction<ParentTransactionReceipt>>;

Defined in: assetBridger/erc20Bridger.ts:1035

Register a custom token on the Arbitrum bridge See https://developer.offchainlabs.com/docs/bridging_assets#the-arbitrum-generic-custom-gateway for more details

Parameters
ParameterTypeDescription
parentTokenAddressstringAddress of the already deployed parent token. Must inherit from https://developer.offchainlabs.com/docs/sol_contract_docs/md_docs/arb-bridge-peripherals/tokenbridge/ethereum/icustomtoken.
childTokenAddressstringAddress of the already deployed child token. Must inherit from https://developer.offchainlabs.com/docs/sol_contract_docs/md_docs/arb-bridge-peripherals/tokenbridge/arbitrum/iarbtoken.
parentSignerSignerThe signer with the rights to call registerTokenOnL2 on the parent token
childProviderProviderArbitrum rpc provider
Returns

Promise<ParentContractTransaction<ParentTransactionReceipt>>

setGateways()
setGateways(
parentSigner: Signer,
childProvider: Provider,
tokenGateways: TokenAndGateway[],
options?: GasOverrides): Promise<ParentContractCallTransaction>;

Defined in: assetBridger/erc20Bridger.ts:1266

Register the provided token addresses against the provided gateways

Parameters
ParameterTypeDescription
parentSignerSigner
childProviderProvider
tokenGatewaysTokenAndGateway[]
options?GasOverrides-
Returns

Promise<ParentContractCallTransaction>

withdraw()
withdraw(params: 
| OmitTyped<Erc20WithdrawParams, "from"> & object
| ChildToParentTxReqAndSigner): Promise<ChildContractTransaction>;

Defined in: assetBridger/erc20Bridger.ts:889

Withdraw tokens from child to parent network

Parameters
ParameterTypeDescription
params| OmitTyped<Erc20WithdrawParams, "from"> & object | ChildToParentTxReqAndSigner
Returns

Promise<ChildContractTransaction>

Inherited from

Erc20Bridger.withdraw

fromProvider()
static fromProvider(childProvider: Provider): Promise<Erc20Bridger>;

Defined in: assetBridger/erc20Bridger.ts:216

Instantiates a new Erc20Bridger from a child provider

Parameters
ParameterTypeDescription
childProviderProvider
Returns

Promise<Erc20Bridger>

Inherited from

Erc20Bridger.fromProvider


Erc20Bridger

Defined in: assetBridger/erc20Bridger.ts:191

Bridger for moving ERC20 tokens back and forth between parent-to-child

Extends

Extended by

Constructors

Constructor
new Erc20Bridger(childNetwork: ArbitrumNetwork): Erc20Bridger;

Defined in: assetBridger/erc20Bridger.ts:205

Bridger for moving ERC20 tokens back and forth between parent-to-child

Parameters
ParameterType
childNetworkArbitrumNetwork
Returns

Erc20Bridger

Overrides
AssetBridger<
Erc20DepositParams | ParentToChildTxReqAndSignerProvider,
OmitTyped<Erc20WithdrawParams, 'from'> | ChildToParentTransactionRequest
>.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
nativeToken?readonlystringIn case of a chain that uses ETH as its native/gas token, this is either undefined or the zero address In case of a chain that uses an ERC-20 token from the parent network as its native/gas token, this is the address of said token on the parent networkAssetBridger.nativeTokenassetBridger/assetBridger.ts:40

Accessors

nativeTokenIsEth
Get Signature
get protected nativeTokenIsEth(): boolean;

Defined in: assetBridger/assetBridger.ts:72

Whether the chain uses ETH as its native/gas token

Returns

boolean

Inherited from

AssetBridger.nativeTokenIsEth

Methods

approveGasToken()
approveGasToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>;

Defined in: assetBridger/erc20Bridger.ts:276

Approves the custom gas token to be spent by the relevant gateway on the parent network

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise<ContractTransaction>

approveToken()
approveToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>;

Defined in: assetBridger/erc20Bridger.ts:339

Approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise<ContractTransaction>

checkChildNetwork()
protected checkChildNetwork(sop: SignerOrProvider): Promise<void>;

Defined in: assetBridger/assetBridger.ts:61

Check the signer/provider matches the child network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise<void>

Inherited from

AssetBridger.checkChildNetwork

checkParentNetwork()
protected checkParentNetwork(sop: SignerOrProvider): Promise<void>;

Defined in: assetBridger/assetBridger.ts:50

Check the signer/provider matches the parent network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise<void>

Inherited from

AssetBridger.checkParentNetwork

deposit()
deposit(params: Erc20DepositParams | ParentToChildTxReqAndSignerProvider): Promise<ParentContractCallTransaction>;

Defined in: assetBridger/erc20Bridger.ts:769

Execute a token deposit from parent to child network

Parameters
ParameterTypeDescription
paramsErc20DepositParams | ParentToChildTxReqAndSignerProvider
Returns

Promise<ParentContractCallTransaction>

Overrides

AssetBridger.deposit

getApproveGasTokenRequest()
getApproveGasTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>;

Defined in: assetBridger/erc20Bridger.ts:260

Creates a transaction request for approving the custom gas token to be spent by the relevant gateway on the parent network

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>

getApproveTokenRequest()
getApproveTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>;

Defined in: assetBridger/erc20Bridger.ts:306

Get a tx request to approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

Promise<Required<Pick<TransactionRequest, "to" | "value" | "data">>>

getChildErc20Address()
getChildErc20Address(erc20ParentAddress: string, parentProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:491

Get the corresponding child network token address for the provided parent network token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise<string>

getChildGatewayAddress()
getChildGatewayAddress(erc20ParentAddress: string, childProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:244

Get the address of the child gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
childProviderProvider
Returns

Promise<string>

getChildTokenContract()
getChildTokenContract(childProvider: Provider, childTokenAddr: string): L2GatewayToken;

Defined in: assetBridger/erc20Bridger.ts:462

Get the child network token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesn't check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
childProviderProvider
childTokenAddrstring
Returns

L2GatewayToken

getDepositRequest()
getDepositRequest(params: DepositRequest): Promise<ParentToChildTransactionRequest>;

Defined in: assetBridger/erc20Bridger.ts:655

Get the arguments for calling the deposit function

Parameters
ParameterTypeDescription
paramsDepositRequest
Returns

Promise<ParentToChildTransactionRequest>

getParentErc20Address()
getParentErc20Address(erc20ChildChainAddress: string, childProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:514

Get the corresponding parent network address for the provided child network token Validates the returned address against the child network router to ensure it is correctly mapped to the provided erc20ChildChainAddress

Parameters
ParameterTypeDescription
erc20ChildChainAddressstring
childProviderProvider
Returns

Promise<string>

getParentGatewayAddress()
getParentGatewayAddress(erc20ParentAddress: string, parentProvider: Provider): Promise<string>;

Defined in: assetBridger/erc20Bridger.ts:226

Get the address of the parent gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise<string>

getParentTokenContract()
getParentTokenContract(parentProvider: Provider, parentTokenAddr: string): ERC20;

Defined in: assetBridger/erc20Bridger.ts:478

Get the parent token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesnt check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
parentProviderProvider
parentTokenAddrstring
Returns

ERC20

getWithdrawalEvents()
getWithdrawalEvents(
childProvider: Provider,
gatewayAddress: string,
filter: object,
parentTokenAddress?: string,
fromAddress?: string,
toAddress?: string): Promise<object & object[]>;

Defined in: assetBridger/erc20Bridger.ts:367

Get the child network events created by a withdrawal

Parameters
ParameterTypeDescription
childProviderProvider
gatewayAddressstring
filter{ fromBlock: BlockTag; toBlock: BlockTag; }
filter.fromBlockBlockTag-
filter.toBlock?BlockTag-
parentTokenAddress?string
fromAddress?string
toAddress?string-
Returns

Promise<object & object[]>

getWithdrawalRequest()
getWithdrawalRequest(params: Erc20WithdrawParams): Promise<ChildToParentTransactionRequest>;

Defined in: assetBridger/erc20Bridger.ts:826

Get the arguments for calling the token withdrawal function

Parameters
ParameterTypeDescription
paramsErc20WithdrawParams
Returns

Promise<ChildToParentTransactionRequest>

isDepositDisabled()
isDepositDisabled(parentTokenAddress: string, parentProvider: Provider): Promise<boolean>;

Defined in: assetBridger/erc20Bridger.ts:560

Whether the token has been disabled on the router

Parameters
ParameterTypeDescription
parentTokenAddressstring
parentProviderProvider
Returns

Promise<boolean>

isRegistered()
isRegistered(params: object): Promise<boolean>;

Defined in: assetBridger/erc20Bridger.ts:924

Checks if the token has been properly registered on both gateways. Mostly useful for tokens that use a custom gateway.

Parameters
ParameterTypeDescription
params{ childProvider: Provider; erc20ParentAddress: string; parentProvider: Provider; }
params.childProviderProvider
params.erc20ParentAddressstring
params.parentProviderProvider
Returns

Promise<boolean>

withdraw()
withdraw(params: 
| OmitTyped<Erc20WithdrawParams, "from"> & object
| ChildToParentTxReqAndSigner): Promise<ChildContractTransaction>;

Defined in: assetBridger/erc20Bridger.ts:889

Withdraw tokens from child to parent network

Parameters
ParameterTypeDescription
params| OmitTyped<Erc20WithdrawParams, "from"> & object | ChildToParentTxReqAndSigner
Returns

Promise<ChildContractTransaction>

Overrides

AssetBridger.withdraw

fromProvider()
static fromProvider(childProvider: Provider): Promise<Erc20Bridger>;

Defined in: assetBridger/erc20Bridger.ts:216

Instantiates a new Erc20Bridger from a child provider

Parameters
ParameterTypeDescription
childProviderProvider
Returns

Promise<Erc20Bridger>