Generic-custom Gateway
For token movement between Arbitrumn and dKargo, the Standard Gateway method is generally sufficient.
However, in the Standard Gateway model:
When depositing tokens, an ERC-20 token contract on dKargo Chain is automatically deployed.
This contract is enforced to use StandardArbERC20.sol, limiting customization.
For developers or project builders who want:
To add custom functionalities to their ERC-20 contract
To pair their own ERC-20 contract on dKargo Chain with a specific contract
Using the Generic-Custom Gateway provides greater flexibility in these cases.
Setting Up a Token with the Generic-Custom Gateway
To use the generic-custom gateway, the ERC-20 contract deployed on L2 must comply with the following rules:
1. Interface
The ERC-20 token contract on L2 must implement the ICustomToken interface.
The isArbitrumEnabled() method is called during the token registration process. To utilize the Generic-Custom Gateway, this method must return uint8(0xb1).
The ERC-20 token contract on L3 must implement the IArbToken interface.
The contract must include:
bridgeMintandbridgeBurnfunctions, which can only be called by the Generic-Custom Gateway contract (onlyL2Gateway).The
l1Addressvariable to store the corresponding L2 ERC-20 token contract address.
2. Approve
The next step is registering and pairing the L2 and L3 ERC-20 tokens through the Generic-Custom Gateway.
Since the two tokens are deployed on independent chains, the pairing process is conducted using retryable tickets, and the associated fees are paid in L2 ERC-20 DKA.
The registration process begins by calling a method on the L2 ERC-20 token contract. Before initiating this step, the L2 ERC-20 token contract must be approved to use L2 ERC-20 DKA for transaction fees.
3. Register
The L2 and L3 ERC-20 tokens must be registered with the Generic-Custom Gateway to complete the pairing process.
By referring to [L2 ERC-20 Example], it can be observed that the registerTokenOnL2 method calls both:
customGateway.registerTokenToL2customGateway.setGateway
These methods are executed on the L2 ERC-20 contract.
customGateway.registerTokenToL2Executes the pairing process within the L2 Generic-Custom Gateway.
Sends a cross-chain message to dKargo Chain, ensuring that the same pairing operation is executed on L3 Generic-Custom Gateway.
customGateway.setGatewayRegisters Generic-Custom Gateway as the designated gateway for the token in the L2 GatewayRouter.
Sends a cross-chain message to dKargo Chain, ensuring that the L3 GatewayRouter applies the same configuration.
Since the two tokens are registered on separate chains, pairing them requires some processing time.
The registration request status will initially be marked as "Pending".
After approximately 10 minutes, the process is finalized, and the token pairing is completed on dKargo Chain (L3).
The status of the registration request can be checked on dScanner’s [L2 ➔ L3 Transactions] page.
Depositing & Withdrawing Tokens
Now that the Generic-Custom Gateway is set up, deposits and withdrawals between Arbitrum Chain and dKargo Chain can now be performed. The deposit and withdrawal process functions exactly the same as the Standard Gateway method, so refer to its process for execution.
It is important to note that when using the Standard Gateway, the first deposit automatically deploys an ERC-20 token contract on dKargo Chain, enforcing the use of StandardArbERC20.sol.
However, when using the Generic-Custom Gateway, it is mandatory to complete the registration process before making the first deposit.
Last updated