{"id":13566869,"url":"https://github.com/decentralized-identity/ethr-did-resolver","last_synced_at":"2025-05-15T03:07:29.775Z","repository":{"id":36039817,"uuid":"127560664","full_name":"decentralized-identity/ethr-did-resolver","owner":"decentralized-identity","description":"DID resolver for Ethereum Addresses with support for key management","archived":false,"fork":false,"pushed_at":"2025-05-12T12:31:33.000Z","size":4430,"stargazers_count":223,"open_issues_count":6,"forks_count":78,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-12T13:40:31.975Z","etag":null,"topics":["decentralized-identity","did-ethr","erc1056","ethereum","ssi","web3","wg-id"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decentralized-identity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"Contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-03-31T18:40:19.000Z","updated_at":"2025-04-08T20:32:51.000Z","dependencies_parsed_at":"2023-09-26T00:55:21.600Z","dependency_job_id":"b431c6da-cb82-4fb5-a788-60f15b593a72","html_url":"https://github.com/decentralized-identity/ethr-did-resolver","commit_stats":{"total_commits":467,"total_committers":28,"mean_commits":"16.678571428571427","dds":0.6937901498929336,"last_synced_commit":"1150d14a9033ac0fabb79f99b368fb6ba2d5b871"},"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentralized-identity%2Fethr-did-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentralized-identity%2Fethr-did-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentralized-identity%2Fethr-did-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentralized-identity%2Fethr-did-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decentralized-identity","download_url":"https://codeload.github.com/decentralized-identity/ethr-did-resolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253753228,"owners_count":21958829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decentralized-identity","did-ethr","erc1056","ethereum","ssi","web3","wg-id"],"created_at":"2024-08-01T13:02:18.432Z","updated_at":"2025-05-15T03:07:24.748Z","avatar_url":"https://github.com/decentralized-identity.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","🛠 Tools \u0026 Technologies"],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/dt/ethr-did-resolver.svg)](https://www.npmjs.com/package/ethr-did-resolver)\n[![npm](https://img.shields.io/npm/v/ethr-did-resolver.svg)](https://www.npmjs.com/package/ethr-did-resolver)\n[![codecov](https://codecov.io/gh/decentralized-identity/ethr-did-resolver/branch/develop/graph/badge.svg)](https://codecov.io/gh/decentralized-identity/ethr-did-resolver)\n\n# ethr DID Resolver\n\nThis library is intended to use ethereum addresses or secp256k1 publicKeys as fully self-managed\n[Decentralized Identifiers](https://w3c.github.io/did-core/#identifier) and wrap them in a\n[DID Document](https://w3c.github.io/did-core/#did-document-properties)\n\nIt supports the proposed [Decentralized Identifiers](https://w3c.github.io/did-core/#identifier) spec from the\n[W3C Credentials Community Group](https://w3c-ccg.github.io).\n\nIt requires the `did-resolver` library, which is the primary interface for resolving DIDs.\n\nThis DID method relies on the [ethr-did-registry](https://github.com/uport-project/ethr-did-registry).\n\n## DID method\n\nTo encode a DID for an Ethereum address on the ethereum mainnet, simply prepend `did:ethr:`\n\neg:\n\n`did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74`\n\nMulti-network DIDs are also supported, if the proper configuration is provided during setup.\n\nFor example:\n`did:ethr:0x5:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` gets resolved on the goerli testnet (chainID=0x5), and\nrepresents a distinct identifier than the generic one, with different DID documents and different key rotation history.\n\n## DID Document\n\nThe did resolver takes the ethereum address, looks at contract events and builds a DID document based on the ERC1056\nEvents corresponding to the address. When an identifier is a full `publicKey`, the corresponding `ethereumAddress` is\ncomputed and checked in the same manner.\n\nThe minimal DID document for an ethereum address `0xb9c5714089478a327f09197987f16f9e5d936e8a` with no transactions to\nthe registry looks like this:\n\n```json\n{\n  \"@context\": [\n    \"https://www.w3.org/ns/did/v1\",\n    \"https://w3id.org/security/suites/secp256k1recovery-2020/v2\"\n  ],\n  \"id\": \"did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a\",\n  \"verificationMethod\": [\n    {\n      \"id\": \"did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller\",\n      \"type\": \"EcdsaSecp256k1RecoveryMethod2020\",\n      \"controller\": \"did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a\",\n      \"blockchainAccountId\": \"eip155:1:0xb9c5714089478a327f09197987f16f9e5d936e8a\"\n    }\n  ],\n  \"authentication\": [\n    \"did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller\"\n  ],\n  \"assertionMethod\": [\n    \"did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller\"\n  ]\n}\n```\n\nNote this resolver uses the `EcdsaSecp256k1RecoveryMethod2020` type and an `blockchainAccountId` to represent the\ndefault\n`verificationMethod`, `assertionMethod`, and `authentication` entry. Any value from the registry that returns an\nethereum address will be added to the `verificationMethod` array of the DID document with\ntype `EcdsaSecp256k1RecoveryMethod2020` and an `blockchainAccountId` attribute containing the address.\n\n## Building a DID document\n\nThe DID document is not stored as a file, but is built by using read only functions and contract events on\nthe [ethr-did-registry](https://github.com/uport-project/ethr-did-registry) Ethereum smart contract.\n\nPlease see the [spec](doc/did-method-spec.md) for details of how the DID document and corresponding metadata are\ncomputed.\n\n## Resolving a DID document\n\nThe library presents a `resolve()` function that returns a `Promise` returning the DID document. It is not meant to be\nused directly but through the [`did-resolver`](https://github.com/decentralized-identity/did-resolver) aggregator.\n\nYou can use the `getResolver(config)` method to produce an entry that can be used with the `Resolver`\nconstructor:\n\n```javascript\nimport { Resolver } from 'did-resolver'\nimport { getResolver } from 'ethr-did-resolver'\n\nconst providerConfig = {\n// While experimenting, you can set a rpc endpoint to be used by the web3 provider\n  rpcUrl: 'http://localhost:7545', \n// You can also set the address for your own ethr-did-registry (ERC1056) contract\n  registry: registry.address,\n  name: 'development' // this becomes did:ethr:development:0x...\n}\n// It's recommended to use the multi-network configuration when using this in production\n// since that allows you to resolve on multiple public and private networks at the same time.\n\n// getResolver will return an object with a key/value pair of { \"ethr\": resolver } where resolver is a function used by the generic did resolver.\nconst ethrDidResolver = getResolver(providerConfig)\nconst didResolver = new Resolver(ethrDidResolver)\n\ndidResolver\n  .resolve('did:ethr:development:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74')\n  .then((result) =\u003e console.dir(result, { depth: 3 }))\n```\n\n## Multi-network configuration\n\nIn production, you will most likely want the ability to resolve DIDs that are based in different ethereum networks. To\ndo this, you need a configuration that sets the network name or chain ID (and even the registry address) for each\nnetwork. An example configuration for multi-network DID resolving would look like this:\n\n```javascript\nconst providerConfig = {\n  networks: [\n    { name: \"mainnet\", provider: web3.currentProvider },\n    { name: \"0x5\", rpcUrl: \"https://goerli.infura.io/v3/\u003cYOUR PROJECT ID\u003e\" },\n    { name: \"rsk:testnet\", chainId: \"0x1f\", rpcUrl: \"https://did.testnet.rsk.co:4444\" },\n    { name: \"development\", rpcUrl: \"http://localhost:7545\", registry: \"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b\" },\n    { name: \"myprivatenet\", chainId: 123456, rpcUrl: \"https://my.private.net.json.rpc.url\" }\n  ]\n}\n\nconst ethrDidResolver = getResolver(providerConfig)\n```\n\nThe configuration from above allows you to resolve ethr-did's of the following formats:\n\n- `did:ethr:mainnet:0xabcabc03e98e0dc2b855be647c39abe984193675`\n- `did:ethr:0xabcabc03e98e0dc2b855be647c39abe984193675` (defaults to mainnet configuration)\n- `did:ethr:0x5:0xabcabc03e98e0dc2b855be647c39abe984193675` (refer to the goerli network by chainID)\n- `did:ethr:rsk:testnet:0xabcabc03e98e0dc2b855be647c39abe984193675`\n- `did:ethr:0x1f:0xabcabc03e98e0dc2b855be647c39abe984193675` (refer to the rsk:testnet by chainID)\n- `did:ethr:development:0xabcabc03e98e0dc2b855be647c39abe984193675`\n- `did:ethr:myprivatenet:0xabcabc03e98e0dc2b855be647c39abe984193675`\n- `did:ethr:0x1e240:0xabcabc03e98e0dc2b855be647c39abe984193675` (refer to `myprivatenet` by chainID)\n\nFor each network you can specify either an `rpcUrl`, a `provider` or a `web3` instance that can be used to access that\nparticular network. At least one of `name` or `chainId` must be specified per network.\n\nThese providers will have to support `eth_call` and `eth_getLogs` to be able to resolve DIDs specific to that network.\n\nYou can also override the default registry address by specifying a `registry` attribute per network.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecentralized-identity%2Fethr-did-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecentralized-identity%2Fethr-did-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecentralized-identity%2Fethr-did-resolver/lists"}