Skip to main content

Dynamic dids

How to use custom did methods or networks with js-sdk

  1. Deploy contracts on custom chain.

    StateV2.sol - mandatory contract to transit identities states and getting global identity state root (GIST) during the authentication.

    IdentityTreeStore.sol - optional, this contract is responsible for storing revocation tree nodes and tree roots of Identity. Only needed in case onchain RHS ( Iden3OnchainSparseMerkleTreeProof2023 credential status) will be used for issuing credentials.

    Onchain Validators - optional, only in case you work on use cases with onchain verification. repository

  2. Register you network for PolygonID did method in the following way:

import { core } from "@0xpolygonid/js-sdk";

core.registerDidMethodNetwork({
method: core.DidMethod.PolygonId,
blockchain: "linea",
chainId: 59140,
network: "testnet",
networkFlag: 0b0100_0000 | 0b0000_0001,
});

Also, eth provider must be defined for given network.

  const conf: EthConnectionConfig = defaultEthConnectionConfig;
conf.contractAddress = contractAddress;
conf.url = rpcUrl;

Where networkFlag is two bytes which will be used for generation of type of identity. It must be different from existing network flags. ChainId is identifier of network in ethereum ecosystem

info
  1. Extend the setup of the verifier in the same way - by registering the supported did.
npm i @iden3/js-iden3-auth --save
const { core } = require("@iden3/js-iden3-auth");

core.registerDidMethodNetwork({
method: core.DidMethod.PolygonId,
blockchain: "linea",
chainId: 59140,
network: "testnet",
networkFlag: 0b0100_0000 | 0b0000_0001,
});
danger

Custom Did methods / network registration is supported on core library level, js-sdk and verification libraries.

Not yet supported on issuer-node and mobile.