ERC20 Messaging dApp

It is time to take your first steps with the Topos Testnet and get familiar with the mechanics of using and developing with Topos. To do so, you will use a basic dApp provided by Topos: the Topos ERC20 Messaging dApp. It is a sample application that allows you to experience Topos as a user transfering funds from one blockchain to another. Later, you can find out more about the actions that are triggered and executed on the public testnet during your test.

Visit the ERC20 Messaging dApp

Note

Please make sure you have installed MetaMask before continuing.

With MetaMask installed, you can navigate to ERC20 Messaging:

You are now going to complete a cross-subnet, fungible token transfer from the Topos Subnet to the Incal subnet.

1

First, you must connect MetaMask with the Topos ERC20 Messaging dApp:

If you have not already done so, you will have to connect the ERC20 Messaging dApp to MetaMask and add the Topos and Incal subnets to your MetaMask wallet. To do this, follow the steps in our How to add Topos and Incal to MetaMask guide.

If you had previously following that guide, but you had performed the manual procedure, then you will still need to connect the dApp to MetaMask. If the upper right corner of the ERC20 Messaging dApp page looks like this, with a 'Connect to MetaMask' button:

Then click the 'Connect to MetaMask' button and follow the instructions to connect the dApp to MetaMask.

Once the ERC20 Messaging dApp is displaying your address in the right top corner, the ERC20 dApp is connected to your wallet.

2

Additionally, you will want to have requested tokens from the Topos Faucet. If you have not done this yet, please follow the instructions in our How to use the Faucet to get Testnet Tokens guide to do this.

3

Your wallet is connected to the app, and you have some tokens to play with, so now you are ready to transfer some assets from one subnet to the other. To do this, first select the Incal Subnet in the dApp:

4

Register a token, here named testToken:

In order to register tokens on the subnets, you will need to pay fees on both subnets for the token registration (e.g. for the Incal subnet):

5

Repeat these steps for the Topos Subnet.

6

With both token setups done, you can try your first cross-subnet token transfer:

7

The ERC20 Messaging dApp will list the different steps involved in the cross-subnet transfer process:

First, approve the actions:

Note

A cross-subnet ERC20 token transfer involves you approving several actions:

  1. Make allowance for token burn by sending an approve transaction to the token contract you deployed during registration of a new token. This step is not always required (for example, if you did not hit the maximum you set in this step during the next step).
  2. Burn tokens on the Incal subnet and emit an event by sending a sendToken transaction to ERC20Messaging contract.

The ERC20 Messaging dApp will wait for the transaction to be executed:

It should give you a success message, like the following:

Congratulations! You have completed your first cross-subnet token transfer.

Troubleshooting

Under the hood

The following steps describe what actually happened:

  1. The ERC20 Messaging frontend deployed a token contract on each subnet for the token you registered on it.
  2. To make a cross-subnet transfer, the dApp submitted a transaction to the Incal subnet to burn the transferred tokens there.
  3. Next, the sending subnet (Incal) prepares the input data for the ZK proof and submits it to the prover cluster by way of the Sequencer (for the testnet the prover is not active)
  4. The sequencer prepares the Certificate and broadcasts it to the TCE network.
  5. In parallel, the ERC20 frontend made a request to the executor service containing a Merkle proof of the Incal transaction (proof of inclusion of its receipt in the receipt trie of the certified state transition) and the root of the transaction trie, which is used by the ERC20Messaging contract to retrieve the certificate from the ToposCore contract.
  6. Once the receiving side (the Topos Subnet in this case) has taken delivery of the Certificate from its dedicated TCE node and the context-specific information from the executor service, it can proceed to mint the transferred tokens.

Note: In the current iteration of the testnet, no ZK proofs are actually computed and TCE nodes are implemented as part of the Topos Subnet validators.

Up next

You have invoked your first cross-subnet token transfer with Topos. In the next section, you will use Topos Explorer to see the certificates that were created.

© 2024 All rights reserved zk FoundationBuild bd74f6332024-04-19T16:37:51.288Z