erc20Bridger
Classes
AdminErc20Bridger
Admin functionality for the token bridge
Extends
Constructors
new AdminErc20Bridger()
new AdminErc20Bridger(childChain: ArbitrumNetwork): AdminErc20Bridger
Bridger for moving ERC20 tokens back and forth between parent-to-child
Parameters
Parameter | Type |
---|---|
childChain | ArbitrumNetwork |
Returns
Inherited from
Source
assetBridger/erc20Bridger.ts:199
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
nativeToken? | readonly | string | In case of a chain that uses ETH as its native/gas token, this is either undefined or the zero addressIn case of a chain that uses an ERC-20 token from the parent chain as its native/gas token, this is the address of said token on the parent chain | Erc20Bridger .nativeToken |
Accessors
nativeTokenIsEth
get protected nativeTokenIsEth(): boolean
Whether the chain uses ETH as its native/gas token
Returns
boolean
Source
assetBridger/assetBridger.ts:68
Methods
approveGasToken()
approveGasToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>
Approves the custom gas token to be spent by the relevant gateway on the parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
Returns
Promise
<ContractTransaction
>
Inherited from
Erc20Bridger
. approveGasToken
Source
assetBridger/erc20Bridger.ts:270
approveToken()
approveToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>
Approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.
Parameters
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
Returns
Promise
<ContractTransaction
>
Inherited from
Source
assetBridger/erc20Bridger.ts:333
checkChildChain()
protected checkChildChain(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the childChain, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
Erc20Bridger
. checkChildChain
Source
assetBridger/assetBridger.ts:60
checkParentChain()
protected checkParentChain(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the parentChain, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
Erc20Bridger
. checkParentChain
Source
assetBridger/assetBridger.ts:49
deposit()
deposit(params: Erc20DepositParams | ParentToChildTxReqAndSignerProvider): Promise<ParentContractCallTransaction>
Execute a token deposit from parent to child chain
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20DepositParams | ParentToChildTxReqAndSignerProvider |
Returns
Promise
<ParentContractCallTransaction
>
Inherited from
Source
assetBridger/erc20Bridger.ts:752
getApproveGasTokenRequest()
getApproveGasTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "data" | "value" | "to">>>
Creates a transaction request for approving the custom gas token to be spent by the relevant gateway on the parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
Returns
Promise
<Required
<Pick
<TransactionRequest
, "data"
| "value"
| "to"
>>>
Inherited from
Erc20Bridger
. getApproveGasTokenRequest
Source
assetBridger/erc20Bridger.ts:254
getApproveTokenRequest()
getApproveTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "data" | "value" | "to">>>
Get a tx request to approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.
Parameters
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
Returns
Promise
<Required
<Pick
<TransactionRequest
, "data"
| "value"
| "to"
>>>
Inherited from
Erc20Bridger
. getApproveTokenRequest
Source
assetBridger/erc20Bridger.ts:300
getChildErc20Address()
getChildErc20Address(erc20ParentAddress: string, parentProvider: Provider): Promise<string>
Get the corresponding child chain token address for the provided parent chain token
Parameters
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getChildErc20Address
Source
assetBridger/erc20Bridger.ts:485
getChildGatewayAddress()
getChildGatewayAddress(erc20ParentAddress: string, childProvider: Provider): Promise<string>
Get the address of the child gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
childProvider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getChildGatewayAddress
Source
assetBridger/erc20Bridger.ts:238
getChildGatewaySetEvents()
getChildGatewaySetEvents(
childProvider: Provider,
filter: object,
customNetworkL2GatewayRouter?: string): Promise<object[]>
Get all the gateway set events on the L2 gateway router
Parameters
Parameter | Type |
---|---|
childProvider | Provider |
filter | object |
filter.fromBlock | BlockTag |
filter.toBlock ? | BlockTag |
customNetworkL2GatewayRouter ? | string |
Returns
Promise
<object
[]>
Source
assetBridger/erc20Bridger.ts:1170
getChildTokenContract()
getChildTokenContract(childProvider: Provider, childTokenAddr: string): L2GatewayToken
Get the child chain 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
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
childTokenAddr | string |
Returns
L2GatewayToken
Inherited from
Erc20Bridger
. getChildTokenContract
Source
assetBridger/erc20Bridger.ts:456
getDepositRequest()
getDepositRequest(params: DepositRequest): Promise<ParentToChildTransactionRequest>
Get the arguments for calling the deposit function
Parameters
Parameter | Type | Description |
---|---|---|
params | DepositRequest |
Returns
Promise
<ParentToChildTransactionRequest
>
Inherited from
Erc20Bridger
. getDepositRequest
Source
assetBridger/erc20Bridger.ts:645
getParentErc20Address()
getParentErc20Address(erc20ChildChainAddress: string, childProvider: Provider): Promise<string>
Get the corresponding parent chain address for the provided child chain token Validates the returned address against the child chain router to ensure it is correctly mapped to the provided erc20ChildChainAddress
Parameters
Parameter | Type | Description |
---|---|---|
erc20ChildChainAddress | string | |
childProvider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getParentErc20Address
Source
assetBridger/erc20Bridger.ts:508
getParentGatewayAddress()
getParentGatewayAddress(erc20ParentAddress: string, parentProvider: Provider): Promise<string>
Get the address of the parent gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getParentGatewayAddress
Source
assetBridger/erc20Bridger.ts:220
getParentGatewaySetEvents()
getParentGatewaySetEvents(parentProvider: Provider, filter: object): Promise<object[]>
Get all the gateway set events on the Parent gateway router
Parameters
Parameter | Type | Description |
---|---|---|
parentProvider | Provider | |
filter | object | - |
filter.fromBlock | BlockTag | - |
filter.toBlock | BlockTag | - |
Returns
Promise
<object
[]>
Source
assetBridger/erc20Bridger.ts:1146
getParentTokenContract()
getParentTokenContract(parentProvider: Provider, parentTokenAddr: string): ERC20
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
Parameter | Type | Description |
---|---|---|
parentProvider | Provider | |
parentTokenAddr | string |
Returns
ERC20
Inherited from
Erc20Bridger
. getParentTokenContract
Source
assetBridger/erc20Bridger.ts:472
getWithdrawalEvents()
getWithdrawalEvents(
childProvider: Provider,
gatewayAddress: string,
filter: object,
parentTokenAddress?: string,
fromAddress?: string,
toAddress?: string): Promise<object & object[]>
Get the child chain events created by a withdrawal
Parameters
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
gatewayAddress | string | |
filter | object | |
filter.fromBlock | BlockTag | - |
filter.toBlock ? | BlockTag | - |
parentTokenAddress ? | string | |
fromAddress ? | string | |
toAddress ? | string | - |
Returns
Promise
<object
& object
[]>
Inherited from
Erc20Bridger
. getWithdrawalEvents
Source
assetBridger/erc20Bridger.ts:361
getWithdrawalRequest()
getWithdrawalRequest(params: Erc20WithdrawParams): Promise<ChildToParentTransactionRequest>
Get the arguments for calling the token withdrawal function
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20WithdrawParams |
Returns
Promise
<ChildToParentTransactionRequest
>
Inherited from
Erc20Bridger
. getWithdrawalRequest
Source
assetBridger/erc20Bridger.ts:791
isDepositDisabled()
isDepositDisabled(parentTokenAddress: string, parentProvider: Provider): Promise<boolean>
Whether the token has been disabled on the router
Parameters
Parameter | Type | Description |
---|---|---|
parentTokenAddress | string | |
parentProvider | Provider |
Returns
Promise
<boolean
>
Inherited from
Erc20Bridger
. isDepositDisabled
Source
assetBridger/erc20Bridger.ts:554
isRegistered()
isRegistered(__namedParameters: object): Promise<boolean>
Checks if the token has been properly registered on both gateways. Mostly useful for tokens that use a custom gateway.
Parameters
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.erc20L1Address | string |
__namedParameters.l1Provider | Provider |
__namedParameters.l2Provider | Provider |
Returns
Promise
<boolean
>
Inherited from
Source
assetBridger/erc20Bridger.ts:887
registerCustomToken()
registerCustomToken(
parentTokenAddress: string,
childTokenAddress: string,
parentSigner: Signer,
childProvider: Provider): Promise<ParentContractTransaction<ParentTransactionReceipt>>
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
Parameter | Type | Description |
---|---|---|
parentTokenAddress | string | Address 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. |
childTokenAddress | string | Address 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. |
parentSigner | Signer | The signer with the rights to call registerTokenOnL2 on the parent token |
childProvider | Provider | Arbitrum rpc provider |
Returns
Promise
<ParentContractTransaction
<ParentTransactionReceipt
>>
Source
assetBridger/erc20Bridger.ts:987
setGateways()
setGateways(
parentSigner: Signer,
childProvider: Provider,
tokenGateways: TokenAndGateway[],
options?: GasOverrides): Promise<ParentContractCallTransaction>
Register the provided token addresses against the provided gateways
Parameters
Parameter | Type | Description |
---|---|---|
parentSigner | Signer | |
childProvider | Provider | |
tokenGateways | TokenAndGateway [] | |
options ? | GasOverrides | - |
Returns
Promise
<ParentContractCallTransaction
>
Source
assetBridger/erc20Bridger.ts:1203
withdraw()
withdraw(params: ChildToParentTxReqAndSigner | OmitTyped<Erc20WithdrawParams, "from"> & object): Promise<ChildContractTransaction>
Withdraw tokens from child to parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ChildToParentTxReqAndSigner | OmitTyped <Erc20WithdrawParams , "from" > & object |
Returns
Promise
<ChildContractTransaction
>
Inherited from
Source
assetBridger/erc20Bridger.ts:854
fromProvider()
static fromProvider(childProvider: Provider): Promise<Erc20Bridger>
Instantiates a new Erc20Bridger from a child provider
Parameters
Parameter | Type | Description |
---|---|---|
childProvider | Provider |
Returns
Promise
<Erc20Bridger
>
Inherited from
Source
assetBridger/erc20Bridger.ts:210
Erc20Bridger
Bridger for moving ERC20 tokens back and forth between parent-to-child
Extends
AssetBridger
<Erc20DepositParams
|ParentToChildTxReqAndSignerProvider
,OmitTyped
<Erc20WithdrawParams
,"from"
> |ChildToParentTransactionRequest
>
Extended by
Constructors
new Erc20Bridger()
new Erc20Bridger(childChain: ArbitrumNetwork): Erc20Bridger
Bridger for moving ERC20 tokens back and forth between parent-to-child
Parameters
Parameter | Type |
---|---|
childChain | ArbitrumNetwork |
Returns
Overrides
AssetBridger< Erc20DepositParams | ParentToChildTxReqAndSignerProvider, OmitTyped<Erc20WithdrawParams, 'from'> | ChildToParentTransactionRequest >.constructor
Source
assetBridger/erc20Bridger.ts:199
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
nativeToken? | readonly | string | In case of a chain that uses ETH as its native/gas token, this is either undefined or the zero addressIn case of a chain that uses an ERC-20 token from the parent chain as its native/gas token, this is the address of said token on the parent chain | AssetBridger .nativeToken |
Accessors
nativeTokenIsEth
get protected nativeTokenIsEth(): boolean
Whether the chain uses ETH as its native/gas token
Returns
boolean
Source
assetBridger/assetBridger.ts:68
Methods
approveGasToken()
approveGasToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>
Approves the custom gas token to be spent by the relevant gateway on the parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
Returns
Promise
<ContractTransaction
>
Source
assetBridger/erc20Bridger.ts:270
approveToken()
approveToken(params: ApproveParamsOrTxRequest): Promise<ContractTransaction>
Approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.
Parameters
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
Returns
Promise
<ContractTransaction
>
Source
assetBridger/erc20Bridger.ts:333
checkChildChain()
protected checkChildChain(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the childChain, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
AssetBridger
. checkChildChain
Source
assetBridger/assetBridger.ts:60
checkParentChain()
protected checkParentChain(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the parentChain, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
AssetBridger
. checkParentChain
Source
assetBridger/assetBridger.ts:49
deposit()
deposit(params: Erc20DepositParams | ParentToChildTxReqAndSignerProvider): Promise<ParentContractCallTransaction>
Execute a token deposit from parent to child chain
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20DepositParams | ParentToChildTxReqAndSignerProvider |
Returns
Promise
<ParentContractCallTransaction
>
Overrides
Source
assetBridger/erc20Bridger.ts:752
getApproveGasTokenRequest()
getApproveGasTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "data" | "value" | "to">>>
Creates a transaction request for approving the custom gas token to be spent by the relevant gateway on the parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
Returns
Promise
<Required
<Pick
<TransactionRequest
, "data"
| "value"
| "to"
>>>
Source
assetBridger/erc20Bridger.ts:254
getApproveTokenRequest()
getApproveTokenRequest(params: ProviderTokenApproveParams): Promise<Required<Pick<TransactionRequest, "data" | "value" | "to">>>
Get a tx request to approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.
Parameters
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
Returns
Promise
<Required
<Pick
<TransactionRequest
, "data"
| "value"
| "to"
>>>
Source
assetBridger/erc20Bridger.ts:300
getChildErc20Address()
getChildErc20Address(erc20ParentAddress: string, parentProvider: Provider): Promise<string>
Get the corresponding child chain token address for the provided parent chain token
Parameters
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:485
getChildGatewayAddress()
getChildGatewayAddress(erc20ParentAddress: string, childProvider: Provider): Promise<string>
Get the address of the child gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
childProvider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:238
getChildTokenContract()
getChildTokenContract(childProvider: Provider, childTokenAddr: string): L2GatewayToken
Get the child chain 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
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
childTokenAddr | string |
Returns
L2GatewayToken
Source
assetBridger/erc20Bridger.ts:456
getDepositRequest()
getDepositRequest(params: DepositRequest): Promise<ParentToChildTransactionRequest>
Get the arguments for calling the deposit function
Parameters
Parameter | Type | Description |
---|---|---|
params | DepositRequest |
Returns
Promise
<ParentToChildTransactionRequest
>
Source
assetBridger/erc20Bridger.ts:645
getDepositRequestCallValue()
private getDepositRequestCallValue(depositParams: OmitTyped<ParentToChildMessageGasParams, "deposit">): BigNumber | BigNumber
Get the call value for the deposit transaction request
Parameters
Parameter | Type | Description |
---|---|---|
depositParams | OmitTyped <ParentToChildMessageGasParams , "deposit" > |
Returns
BigNumber
| BigNumber
Source
assetBridger/erc20Bridger.ts:587
getDepositRequestOutboundTransferInnerData()
private getDepositRequestOutboundTransferInnerData(depositParams: OmitTyped<ParentToChildMessageGasParams, "deposit">): string
Get the data
param for call to outboundTransfer
Parameters
Parameter | Type | Description |
---|---|---|
depositParams | OmitTyped <ParentToChildMessageGasParams , "deposit" > |
Returns
string
Source
assetBridger/erc20Bridger.ts:610
getParentErc20Address()
getParentErc20Address(erc20ChildChainAddress: string, childProvider: Provider): Promise<string>
Get the corresponding parent chain address for the provided child chain token Validates the returned address against the child chain router to ensure it is correctly mapped to the provided erc20ChildChainAddress
Parameters
Parameter | Type | Description |
---|---|---|
erc20ChildChainAddress | string | |
childProvider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:508
getParentGatewayAddress()
getParentGatewayAddress(erc20ParentAddress: string, parentProvider: Provider): Promise<string>
Get the address of the parent gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:220
getParentTokenContract()
getParentTokenContract(parentProvider: Provider, parentTokenAddr: string): ERC20
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
Parameter | Type | Description |
---|---|---|
parentProvider | Provider | |
parentTokenAddr | string |
Returns
ERC20
Source
assetBridger/erc20Bridger.ts:472
getWithdrawalEvents()
getWithdrawalEvents(
childProvider: Provider,
gatewayAddress: string,
filter: object,
parentTokenAddress?: string,
fromAddress?: string,
toAddress?: string): Promise<object & object[]>
Get the child chain events created by a withdrawal
Parameters
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
gatewayAddress | string | |
filter | object | |
filter.fromBlock | BlockTag | - |
filter.toBlock ? | BlockTag | - |
parentTokenAddress ? | string | |
fromAddress ? | string | |
toAddress ? | string | - |
Returns
Promise
<object
& object
[]>
Source
assetBridger/erc20Bridger.ts:361
getWithdrawalRequest()
getWithdrawalRequest(params: Erc20WithdrawParams): Promise<ChildToParentTransactionRequest>
Get the arguments for calling the token withdrawal function
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20WithdrawParams |
Returns
Promise
<ChildToParentTransactionRequest
>
Source
assetBridger/erc20Bridger.ts:791
isDepositDisabled()
isDepositDisabled(parentTokenAddress: string, parentProvider: Provider): Promise<boolean>
Whether the token has been disabled on the router
Parameters
Parameter | Type | Description |
---|---|---|
parentTokenAddress | string | |
parentProvider | Provider |
Returns
Promise
<boolean
>
Source
assetBridger/erc20Bridger.ts:554
isRegistered()
isRegistered(__namedParameters: object): Promise<boolean>
Checks if the token has been properly registered on both gateways. Mostly useful for tokens that use a custom gateway.
Parameters
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.erc20L1Address | string |
__namedParameters.l1Provider | Provider |
__namedParameters.l2Provider | Provider |
Returns
Promise
<boolean
>
Source
assetBridger/erc20Bridger.ts:887
isWethGateway()
private isWethGateway(gatewayAddress: string, parentProvider: Provider): Promise<boolean>
Is this a known or unknown WETH gateway
Parameters
Parameter | Type | Description |
---|---|---|
gatewayAddress | string | |
parentProvider | Provider |
Returns
Promise
<boolean
>
Source
assetBridger/erc20Bridger.ts:430
looksLikeWethGateway()
private looksLikeWethGateway(potentialWethGatewayAddress: string, parentProvider: Provider): Promise<boolean>
Does the provided address look like a weth gateway
Parameters
Parameter | Type | Description |
---|---|---|
potentialWethGatewayAddress | string | |
parentProvider | Provider |
Returns
Promise
<boolean
>
Source
assetBridger/erc20Bridger.ts:400
withdraw()
withdraw(params: ChildToParentTxReqAndSigner | OmitTyped<Erc20WithdrawParams, "from"> & object): Promise<ChildContractTransaction>
Withdraw tokens from child to parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ChildToParentTxReqAndSigner | OmitTyped <Erc20WithdrawParams , "from" > & object |
Returns
Promise
<ChildContractTransaction
>
Overrides
Source
assetBridger/erc20Bridger.ts:854
fromProvider()
static fromProvider(childProvider: Provider): Promise<Erc20Bridger>
Instantiates a new Erc20Bridger from a child provider
Parameters
Parameter | Type | Description |
---|---|---|
childProvider | Provider |
Returns
Promise
<Erc20Bridger
>