Guide: How to set up Polygon ID State Replication
In this guide, we'll set up the cross-chain identity state replication for Polygon ID. It enables the usage of Polygon ID zero-knowledge proofs on any chain supported by Rarimo.
For more information about how the Polygon ID identity state transfer works, visit rarimo-core docs.
Pre-requisites
Before getting started, please contact us in discord to ensure that the issuer is added to the allowlist and that a lightweight state contract is already deployed to the destination chain;
Other pre-requisites:
- Postgres DB 13+ instance for the relayer service;
- Docker and docker-compose (optional)
Setting up relayer
The Relayer service is responsible for replicating the Polygon ID state on demand. It exposes a REST endpoint for the DApps that performs the state replication to the target chain.
Build
You can pull the pre-build docker image:
docker pull ghcr.io/rarimo/identity-relayer-svc:v1.0.4
Or clone the repository and build it from the source:
git clone [email protected]:rarimo/identity-relayer-svc.git
CGO_ENABLED=1 go build .
Configuration
Service configuration consists of two parts:
Environment
export KV_VIPER_FILE=/config.yaml
Config file
log:
disable_sentry: true
level: debug
# The port to run on
listener:
addr: :8000
# PostgreSQL DB connect
db:
url: 'postgres://relayer:relayer@relayer-db:5432/relayer?sslmode=disable'
# Rarimo core RPCs
core:
addr: tcp://core-api.mainnet-beta.rarimo.com:26657
cosmos:
addr: core-api.node1.mainnet-beta.rarimo.com:443
enable_tls: true
evm:
chains:
- name: 'Ethereum'
## Address of the modified state contract on target chain
contract_address: ''
## Private key HEX (without leading 0x) that will pay the tx fee
submitter_private_key: ''
## RPC address. Example https://mainnet.infura.io/v3/11111
rpc:
## Target chain id
chain_id: 1
relay:
# Flag the indicates should service iterate over all existing transfer operation and fill the database
catchup_disabled: true
Run
Binary built from source
# apply DB migrations and run the service
./relayer-svc migrate up && ./relayer-svc run all
Using docker-compose
-
Put the config at
./config.yaml
-
Create
./docker-compose.yml
:version: '3.7'
services:
relayer-db:
image: postgres:13
restart: unless-stopped
environment:
- POSTGRES_USER=relayer
- POSTGRES_PASSWORD=relayer
- POSTGRES_DB=relayer
- PGDATA=/pgdata
volumes:
- relayer-data:/pgdata
relayer:
image: ghcr.io/rarimo/identity-relayer-svc:v1.0.3
restart: on-failure
ports:
- '8000:8000'
depends_on:
- relayer-db
volumes:
- ./config.yaml:/config.yaml
environment:
- KV_VIPER_FILE=/config.yaml
entrypoint: sh -c "relayer-svc migrate up && relayer-svc run all"
volumes:
relayer-data: -
Run the service:
docker-compose up
Using service
Execute the POST /integrations/relayer/relay
request with the following body to fetch state publishing:
{
"chain": "Sepolia",
"state": "0x24d76fbb1ba771df400f4d61d161a4a761675f14a2f35faf6d6d67e6d8be5fe6"
}
The response will be:
200
– successful relay, tx hash in the response body;404
– the state wasn't ingested by Rarimo Core yet; wait a little and repeat the request;400
– the state has been relayed before;