Guide: Setting up cross-chain replication for ZK Passport
Native state transfer to Ethereum L1 is currently under construction.
This guide walks you through the process of setting up cross-chain replication for ZK Passport Registry state. By the end of this tutorial, you will have:
- Deployed the RegistrationSMTReplicator contract on the target chain.
- Set up your relayer or front-end submission flow.
Step 1: Deploy the RegistrationSMTReplicator
The RegistrationSMTReplicator handles the replication of state from the ZK Registry onto your chain. This ensures your chain is kept up to date with changes to passport registrations.
-
Obtain the contract code for
RegistrationSMTReplicator
(contact the provider of the ZK Registry or check their repository for the contract source). -
Deploy the
RegistrationSMTReplicator
to your chain:// Example snippet (pseudo-code)
RegistrationSMTReplicator replicator = new RegistrationSMTReplicator(
registryRoot,
allowedUpdaterAddress
);
Step 2: Set up the relayer or front-end submission flow to replicate the states
To keep the state of the ZK Registry in sync with your chain, you need to set up a relayer or front-end submission flow. This will ensure that any changes in the ZK Registry are reflected in the RegistrationSMTReplicator
contract.
You have two options:
-
Option A: Set up a relayer service that listens for events from the ZK Registry and submits state updates to your
RegistrationSMTReplicator
instance.- This relayer will listen for events such as new passport registrations or updates to existing registrations.
- When an event is detected, the relayer will call the
updateState(...)
function on theRegistrationSMTReplicator
contract. - This option is more user-friendly but requires you to pay the gas for the state updates on your chain.
-
Option B: Send the updates the state update transactions on-demand from your front-end:
- This option is more cost-effective but requires the user to pay the gas for the state updates on your chain.
- You can use the
updateState(...)
function on theRegistrationSMTReplicator
contract to submit state updates.
To set up a relayer for the Option A, follow the instructions in proof-verification-relayer README.
The Option B is more more complex to set up, so we recommended reaching out to Rarimo contributors for help.