Skip to Content
X404 Protocol docs
Official documentation/ SOCIAL PROTOCOL
X404 · Official documentation v1

DID resolution and specification

DID identifiers, resolution and SDK integration.

DID capabilities#

The did:x404 method v1 gives X404 social profiles stable, onchain-resolvable identifiers. The TypeScript and Go SDKs provide DID Documents based on the W3C DID Core 1.0 data model, resolve and resolveRepresentation interfaces, and wallet-controller signature verification. Applications can integrate through either SDK or the standalone HTTP service described below.

The DID subject is an X404 social profile. The controller is the wallet recorded by the social contract. Multiple games can reuse that profile, but game roles, equipment, items, attributes and balances remain isolated. Resolving a DID never grants a game permission to act, accesses private keys, or adds a player approval transaction.

Application integration#

Applications can use the DID to link a profile across games, resolve its controlling wallet and check wallet signatures. Verification supports ECDSA accounts and EIP-1271 contract wallets. Identity reads are read-only and require no wallet signature; applications construct and validate challenges when verifying control.

Combine DID resolution with social and game queries to display profiles, relationships and game participation. Reuse the identity across applications while keeping each game's roles, inventory and balances scoped to that game.

For integration, configure a trusted deployment, resolve the identifier, inspect the returned document and observation metadata, and verify a single-use challenge when the application needs proof of wallet control. Application sessions and asset authorization remain explicit steps in the application's workflow.

Identifier syntax#

text
did:x404:eip155:<chainId>:<socialContract>:<profileId>

Example (syntax only, not a published deployment):
did:x404:eip155:56:0x1234567890123456789012345678901234567890:1

The method name is x404. The namespace eip155 denotes an EVM chain. chainId is a positive decimal integer of at most 32 digits, compatible with the CAIP-2 reference length. socialContract is a nonzero 20-byte address encoded as 0x followed by exactly 40 lowercase hexadecimal characters. profileId is a decimal integer from 1 through 2^256−1. Decimal fields MUST NOT contain leading zeros. The complete identifier is case-sensitive; resolvers MUST reject noncanonical spellings, percent escapes, whitespace, paths, queries and fragments. The formatter accepts a valid address and emits its lowercase canonical form; the parser does not silently rewrite an input DID.

The identity namespace is exactly (chainId, socialContract, profileId). A profile number or username alone is not a DID. Another chain or another social contract denotes a different identity. Chains that reuse a chain ID, including reset local development chains, require an explicitly selected trusted network and deployment; a DID is not a proof of network uniqueness.

Create, update and deactivate#

Create: the first supported social write by a wallet calls the existing profile allocation logic in X404SocialProtocol. A positive, monotonically increasing profileId is assigned and the wallet-to-profile and profile-to-wallet mappings are recorded. A valid identifier can be formatted before registration, but resolution MUST return notFound until the profile exists. No separate DID registration transaction or fee is introduced.

Read: use the resolution algorithm below. The current method only supports the latest observed chain state. The profile identity and wallet binding are immutable under the existing, non-upgradeable social contract.

Update: this method has no DID controller, verification method or service update operation. Profile names and metadata can change through existing wallet-authorized social operations, but they are not included in the DID Document. They therefore do not change the DID or its document. Key rotation, wallet migration and account recovery are not supported.

Deactivate: the current social contract has no profile deletion or DID deactivation operation. IDs are not recycled. Loss of the controlling key does not deactivate a DID; it can make the account unusable. A later method or contract with different lifecycle semantics requires a separately specified deployment/version, not a silent change to this method.

Resolver trust and read algorithm#

The resolver operator MUST configure an explicit list of trusted chain IDs, social contract addresses, RPC providers and independently verified deployed-runtime-bytecode Keccak-256 hashes. A caller cannot supply an RPC URL or add a registry through the HTTP API. A contract claiming PROTOCOL_NAME = X404 is not sufficient evidence of authenticity. Obtain the code hash from the verified deployment/build record; hashing arbitrary code supplied by an untrusted endpoint and then trusting that hash provides no independent check.

  1. Validate the canonical identifier and options. Reject unsupported methods, registries and historical options before RPC reads.
  2. Check that the configured RPC reports the expected chain ID. Read the latest block number and hash.
  3. At that block number, read the registry code and compare its hash with the trusted configuration. Require nonempty code, PROTOCOL_NAME = X404 and a PROTOCOL_VERSION supported by the configured SDK resolver.
  4. Read profileOwner(profileId). For a nonzero wallet, require profileIdOf(wallet) to equal profileId at the same block. A zero wallet denotes an unregistered profile; inconsistent mappings or failed RPC calls are errors, not missing profiles.
  5. Read that block again and require its hash to be unchanged. Return internalError on detected reorganization, code mismatch or RPC failure. Otherwise return the document, or notFound for an unregistered profile.

All registry reads use one block number. The final hash comparison detects a reorganization during the read; it does not establish finality or protect against a dishonest RPC. The latest block can still be reorganized later. Resolution metadata records the observation under x404, including chainId, socialContract, profileId, controllerAccountId, blockNumber, blockHash and registryCodeHash. These values describe the observation, not a cryptographic proof or DID document version. Applications must apply their own finality policy before using a newly registered identity for valuable actions.

DID Document and control verification#

The JSON-LD representation contains only standard DID Core terms and the standard DID context. The JSON representation omits @context. The resolve function returns the abstract document map without @context or contentType; resolveRepresentation returns UTF-8 bytes plus contentType.

json
{
  "@context": "https://www.w3.org/ns/did/v1",
  "id": "did:x404:eip155:56:0x1234567890123456789012345678901234567890:1",
  "controller": "did:pkh:eip155:56:0x1111111111111111111111111111111111111111"
}

The controller uses the did:pkh account syntax with a CAIP-10 EVM account identifier. did:pkh is a separate community method; these SDKs do not expose a general did:pkh resolver. Its use here identifies the controlling wallet and does not prove that the wallet is an externally owned account or has a particular public key.

The document intentionally has no verificationMethod, authentication or assertionMethod entries. A wallet address is not a public key, and an EIP-1271 contract wallet cannot safely be represented as an ECDSA public key. This controller-only document is useful for resolving identity ownership; it is not sufficient input for a generic DID authentication or verifiable-credential proof verifier that requires a published verification method. No new, unregistered signature suite is invented.

For applications that explicitly accept wallet-controller proofs, the SDKs additionally provide verifyControllerSignature / VerifyControllerSignature. These helpers resolve the DID, then verify an application-supplied 32-byte digest against the resolved wallet at the observed block: canonical low-s ECDSA recovery for key-backed accounts (including compact EIP-2098 signatures), or an EIP-1271 isValidSignature call for contract wallets, requiring the 0x1626ba7e magic value. Contract verification is a gas-bounded read-only call; signatures are limited to 16 KiB. The block hash is checked again. Invalid signatures return false; resolution or RPC failures fail closed. This helper is an application-level controller proof, not a DID Core authentication relationship or an implementation of SIWE login.

A login application MUST construct and validate its own challenge with the expected domain, URI, chain, DID, unpredictable single-use nonce and expiry, then compute the digest from that validated challenge. For Ethereum personal-sign messages this is the EIP-191 message hash. It MUST consume the nonce once and MUST NOT accept an arbitrary client-supplied digest as a login request. Signature validity proves control under the wallet rules at the observed block, not real-world identity, one account per person, future control or permission to spend game assets.

Resolution results and errors#

Successful resolve returns didResolutionMetadata, didDocument and an empty didDocumentMetadata map. No creation time, document version, key material or service endpoint is inferred. resolveRepresentation supports application/did+json and application/did+ld+json; the latter is its default. On failure, didDocument is null or the representation byte stream is empty; document metadata is empty and resolution metadata contains error without contentType.

DID Core error keywords used here are invalidDid, notFound and representationNotSupported. This method also defines methodNotSupported for another method, networkNotSupported for an unconfigured chain/registry, invalidOptions for unsupported options, and internalError for RPC, code or state inconsistencies. Detailed upstream RPC errors are not exposed by the resolution endpoint. versionId, versionTime, DID URL dereferencing, historical resolution, key agreement and credential issuance are not implemented; unsupported options are rejected rather than ignored.

TypeScript and Node.js#

ts
import { JsonRpcProvider, hashMessage } from 'ethers';
import { DIDResolver, formatDID } from '@x404/sdk';

const provider = new JsonRpcProvider(process.env.RPC_URL);
const resolver = new DIDResolver([{
  chainId: BigInt(process.env.CHAIN_ID!),
  socialContract: process.env.X404_SOCIAL_ADDRESS!,
  codeHash: process.env.X404_SOCIAL_CODE_HASH!, // verified deployment value
  provider,
}]);
const did = formatDID(
  BigInt(process.env.CHAIN_ID!), process.env.X404_SOCIAL_ADDRESS!, 1n,
);
const result = await resolver.resolve(did);
if (result.didResolutionMetadata.error) throw new Error(result.didResolutionMetadata.error);
const representation = await resolver.resolveRepresentation(did, {
  accept: 'application/did+ld+json',
});
console.log(new TextDecoder().decode(representation.didDocumentStream));

// Only after validating an application-issued, unexpired, unused challenge:
// const valid = await resolver.verifyControllerSignature(did, hashMessage(challenge), signature);

Browser applications can use the same resolver with their own provider and trusted deployment configuration. No platform backend or wallet signature is needed to read identity. The resolver performs no profile-URI or remote JSON-LD context fetches.

Go and standalone HTTP service#

go
resolver, err := x404.NewDIDResolver([]x404.DIDRegistry{{
    ChainID: chainID, SocialContract: socialAddress,
    Backend: rpcClient, CodeHash: verifiedRuntimeCodeHash,
}})
if err != nil { return err }
result := resolver.Resolve(ctx, did, nil)
// Inspect result.DIDResolutionMetadata.Error before using DIDDocument.
handler := x404.DIDHTTPHandler(resolver)

The Go SDK download includes examples/did/main.go. From the SDK directory, configure the RPC URL, decimal chain ID, social contract address and independently verified runtime code hash, then run:

sh
export RPC_URL=http://127.0.0.1:8545
export CHAIN_ID=1337
export X404_SOCIAL_ADDRESS=0xYOUR_DEPLOYED_SOCIAL_ADDRESS
export X404_SOCIAL_CODE_HASH=0xYOUR_VERIFIED_RUNTIME_CODE_HASH
export DID_ADDR=127.0.0.1:8091
go run ./examples/did

GET /1.0/identifiers/did:x404:eip155:56:0x1234567890123456789012345678901234567890:1 Accept: application/did+ld+json

text

An absent Accept header or application/json returns the resolution envelope. application/did+json and application/did+ld+json return the document directly. Content negotiation honors quality values and wildcard exclusions. Errors always return a JSON resolution envelope: 400 for invalid input/options, 404 for a missing profile, 406 for an unsupported representation, 501 for an unsupported method/registry, and 503 for upstream failure or a full concurrency limit. Non-GET methods return 405. Query options are rejected. Responses use Cache-Control: no-store and Vary: Accept. The handler limits concurrent resolution requests to 16 and each request to 10 seconds. It does not accept signatures or perform login.

The example binds to loopback by default. Public deployments should put it behind HTTPS, enforce deployment-specific rate limits, and use a trusted RPC with request deadlines. The endpoint is a replaceable read-only service; applications can independently resolve the same DID using the SDK and their own RPC.

## Security, privacy and compatibility

DIDs, wallet controllers and their activity correlations are public. This method does not provide pseudonym rotation, unlinkability or proof of personhood. No profile metadata, external website, avatar, game inventory, balance or credential is copied into the DID Document. This avoids interpreting user-authored URLs as identity verification keys or services.

A trusted deployment code hash protects against registry lookalikes, but not a compromised RPC, network fork, incorrect trusted configuration or stolen wallet key. EIP-1271 authorization can change under a contract wallet's own governance even though the social profile's wallet address is fixed. No resolver operator can change that address through this API. Historical local deployments and new contracts remain separate identities.

Existing X404 contracts are unchanged. This implementation is an experimental method and a DID Core 1.0-shaped interoperability layer with tested SDK parity, not independent certification. Applications and universal resolvers must explicitly add support for did:x404. Authentication and credential products must not assume that the presence of a controller alone supplies the verification relationships they require.

## Normative references

- [W3C DID Core 1.0 Recommendation, 19 July 2022](https://www.w3.org/TR/2022/REC-did-core-20220719/)
- [DID Core 1.0 resolution interfaces](https://www.w3.org/TR/did-core/#did-resolution)
- [CAIP-2 blockchain identifiers](https://chainagnostic.org/CAIPs/caip-2)
- [CAIP-10 account identifiers](https://chainagnostic.org/CAIPs/caip-10)
- [did:pkh community method draft](https://github.com/w3c-ccg/did-pkh/blob/main/did-pkh-method-draft.md)
- [ERC-1271 contract signature validation](https://eips.ethereum.org/EIPS/eip-1271)
- [ERC-191 signed data](https://eips.ethereum.org/EIPS/eip-191)
- [ERC-2098 compact signatures](https://eips.ethereum.org/EIPS/eip-2098)