This document details how to use the did:near method for decentralized identifiers on the NEAR blockchain, how it complies with W3C DID Core, and how it integrates with verifiable credentials (VCs), proof registries, and resolution tooling.
What is a DID?
A Decentralized Identifier (DID) is a persistent, unique identifier that does not require a centralized registry. On NEAR, DIDs are created based on either account names or raw public keys, and they are fully compatible with the W3C DID standard.
Built in collaboration with NTT DATA Innovation Center Web3
The did:near Method
This method supports two types of DIDs with different resolution strategies:
Example output from resolving a did:near:
This structure follows the W3C DID Core Spec, including:
- A DID identifier (
id)
- Key references (
verificationMethod)
- Authentication and assertion capabilities
- Base58-encoded Ed25519 public keys
⚙️ Repositories
How Resolution Works
The resolver uses different strategies based on DID format:
Named Account DIDs (did:near:alice.testnet)
- Parse the account ID from the DID (e.g.,
alice.testnet).
- Determine the network from the suffix (
.testnet → testnet, .near → mainnet).
- Query the NEAR RPC using
near-api-js to fetch account access keys.
- Filter for keys with
permission: "FullAccess".
- Construct the DID document with all FullAccess public keys as verification methods.
Registry DIDs (did:near:CF5RiJYh4EVmEt8UADTjoP3XaZo1NPWxv6w5TmkLqjpR)
- Identify the DID as Base58 format (44-50 character string matching
[1-9A-HJ-NP-Za-km-z]+).
- Call the
identity_owner view method on the configured registry contract.
- Retrieve the owner DID registered for that Base58 identifier.
- Construct the DID document with the public key from the registry.
How to Use
Create a DID
Named Account DID (Direct Resolution)
If using a NEAR wallet account, the DID is derived directly from the account name:
Registry DID (Contract-Based)
If using a Base58-encoded identifier registered in a smart contract:
Network-Specific DIDs
You can explicitly specify the network:
Issuing and Verifying Credentials
Step 1 – Hash the Credential
Step 2 – Issue on NEAR
This records the hash (cid) on-chain with the subject_did.
Step 3 – Verify On-chain
SDK Usage
Resolver SDK
Standalone Usage
Integration with did-resolver
ProofType SDK
Security & Compliance
- Each
(did, cid) pair can only be registered once.
- Issuer is linked to the signer account via NEAR transaction.
- DID resolution and structure is fully W3C-compliant.
cid is always a Base64-encoded SHA-256 hash of the VC content.
- Key Security: Only
FullAccess keys are included in the DID document’s verificationMethod array, ensuring that only keys with complete account authority are used for authentication.
- Public keys are handled securely via NEAR native accounts or custom registries.
- Multi-Network Support: The resolver automatically routes requests to the correct network (mainnet/testnet) based on the DID suffix.
Testnet Deployment
- Registry Contract:
neardidregistry.testnet
- ProofType Contract:
neardtiprooftype.testnet
- Network:
testnet
- Language: Rust (
near-sdk)
Conclusion
The did:near method enables full-stack decentralized identity flows on NEAR, including:
- Account- and key-based identifiers
- W3C-compliant DID documents
- Smart contract-backed credential proofs
- SDKs for resolution and attestation
Use this stack to build portable, verifiable, and secure Web3 identity solutions on NEAR.