Page cover

🎯Same-address tokens

Learn how to create ERC-20 tokens with the same address on different blockchains using 20lab.

What Are Same-Address Tokens?

If you want to have a cross-chain token (two separate token smart contracts connected by a bridge), it is sometimes important to keep the same addresses for both. This can have benefits such as:

  • Easier bridge setup

  • Proof to users that it is the same token across chains

  • Simplified integration for wallets and exchanges

How It Works

We've enabled this feature by using a hybrid contract initialization approach. Instead of only using the constructor in the token smart contract, we also include an initializer - a public function that can be run only once to set up the core functionality of the token.

Although this method isn't mandatory when users deploy tokens directly from their wallet, it's necessary in our case. We use the CREATE2 opcode to maintain the same token address even if some parameters are changed in the bytecode.

Prerequisites

Both tokens should ideally be generated using the same generator version, but this is not mandatory - in many cases, different generator versions can still produce the same addresses.

Step-by-Step Process

Step 1: Deploy Your First Token

Deploy the first token on 20lab.app by choosing your features, compiling it, and creating it on the first blockchain where you want it to exist.

Step 2: Modify Address (Optional)

After compilation, you can optionally change the address by modifying the salt or searching for a desired pattern in the token address.

Step 3: Get Creation Details

After successful deployment, go to your dashboard and you will see an info icon below your token address. Click on it to see the creation details.

Step 4: Copy the Salt

Copy and save the "Salt" value from the creation details. You'll need this for your second token.

Creating the Second Token

Step 1: Start Second Token Creation

Begin creating the second token on a different blockchain.

This is intentional behavior to prevent others from creating another token at the same address as yours. Because the parameters must be identical, no one can insert their own owner address or add a recipient - this would change the token address completely.

Step 2: Validate and Use Salt

Validate your token configuration and select the 'Modify by salt' option.

Paste the copied salt from your first token and check if your token address matches the first token's address.

If you haven't changed any parameters other than the allowed exceptions, your second token address should be exactly the same as the first one.

Step 3: Deploy the Second Token

Deploy your second token with the matching address.

Success! 👏

You now have both tokens with the same address on two different blockchains.

Example of successful same-address deployment:

Important Security Notes

  • Parameter Verification: Always double-check that your parameters match exactly (except for the allowed exceptions)

  • Address Validation: Always verify the address matches before deploying the second token

  • Bridge Setup: Having the same address simplifies bridge configuration but doesn't automatically create the bridge connection

Troubleshooting

If addresses don't match:

  1. Verify all parameters are identical (except allowed exceptions)

  2. Check that you're using the correct salt

  3. Ensure you're using generator v. 1.6.0 or higher

  4. Review that the token integration template for your Default Exchange is the same for both tokens

Last updated

Was this helpful?