Dynamic dids
How to use custom did methods or networks with js-sdk
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
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
Check an extension demo. or sdk examples.
- Extend the setup of the verifier in the same way - by registering the supported did.
- Javascript
- Golang
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,
});
go get "github.com/iden3/go-iden3-core/v2"
import (
core "github.com/iden3/go-iden3-core/v2"
)
func registerDIDMethods() error {
var err error
params := core.DIDMethodNetworkParams{
Method: core.DIDMethodPolygonID,
Blockchain: "linea",
Network: "testnet",
NetworkFlag: 0b0100_0000 | 0b0000_0001,
}
err = core.RegisterDIDMethodNetwork(params, core.WithChainID(59140))
return err
}
Custom Did methods / network registration is supported on core library level, js-sdk and verification libraries.
Not yet supported on issuer-node and mobile.