{"id":18268,"library":"dcl-crypto","title":"Decentraland Crypto","description":"Decentraland Crypto (dcl-crypto) is a TypeScript library for authentication and cryptographic operations within the Decentraland ecosystem, currently available in versions 2.3.0 (stable) through 3.6.0. It provides utilities for signing messages, verifying identities, and interacting with Ethereum-based authentication schemes. The library is designed specifically for Decentraland's authentication protocol and is maintained by the Decentraland core team with regular releases (~monthly). Key differentiators include built-in support for Decentraland's identity model and provider abstractions.","status":"active","version":"2.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/decentraland/decentraland-crypto","tags":["javascript","decentraland","typescript"],"install":[{"cmd":"npm install dcl-crypto","lang":"bash","label":"npm"},{"cmd":"yarn add dcl-crypto","lang":"bash","label":"yarn"},{"cmd":"pnpm add dcl-crypto","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for cryptographic operations like signing and key management.","package":"eth-crypto","optional":false},{"reason":"Provides Ethereum provider interface for blockchain interactions.","package":"eth-connect","optional":false}],"imports":[{"note":"Identity is a named export, not a default one. Common mistake when migrating from CommonJS.","wrong":"import Identity from '@dcl/crypto'","symbol":"Identity","correct":"import { Identity } from '@dcl/crypto'"},{"note":"Use the scoped @dcl/crypto package for ESM compatibility. The unscoped 'dcl-crypto' is deprecated.","wrong":"const { Authenticator } = require('dcl-crypto')","symbol":"Authenticator","correct":"import { Authenticator } from '@dcl/crypto'"},{"note":"Correct package name is '@dcl/crypto'. The full name 'decentraland-crypto' is a common alias but may not resolve correctly.","wrong":"import { createIdentity } from 'decentraland-crypto'","symbol":"createIdentity","correct":"import { createIdentity } from '@dcl/crypto'"},{"note":"Use 'import type' for type-only imports to avoid runtime bundling issues.","wrong":"","symbol":"AuthLink","correct":"import type { AuthLink } from '@dcl/crypto'"}],"quickstart":{"code":"import { Authenticator, createIdentity } from '@dcl/crypto';\nimport { ethers } from 'ethers';\n\nasync function authenticate() {\n  const provider = new ethers.providers.Web3Provider(window.ethereum);\n  const signer = provider.getSigner();\n  const address = await signer.getAddress();\n  \n  const identity = await createIdentity(address, signer);\n  console.log('Identity created:', identity);\n  \n  const message = 'Hello, Decentraland!';\n  const authChain = await Authenticator.initializeMessage(identity, message);\n  const isValid = await Authenticator.validateSignature(identity.authChain, authChain, message);\n  console.log('Signature valid:', isValid);\n}\n\nauthenticate().catch(console.error);","lang":"typescript","description":"Demonstrates creating an identity and signing/verifying a message using browser Ethereum provider."},"warnings":[{"fix":"Change 'import ... from \"dcl-crypto\"' to 'import ... from \"@dcl/crypto\"'.","message":"In v3.0.0, package was renamed from 'dcl-crypto' to '@dcl/crypto'. All imports must be updated.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update to new signature: `Authenticator.validateSignature(authChain, authLink, message)`.","message":"In v3.0.0, the 'Authenticator' class was rewritten. The 'validateSignature' method signature changed.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use eth-connect provider and pass it as second argument to 'createIdentity'.","message":"The 'createIdentity' function accepts an optional third parameter (provider) that is deprecated in favor of using eth-connect providers.","severity":"deprecated","affected_versions":"<3.0.0"},{"fix":"Run `npm install ethers` to use the wallet functionality.","message":"When using Node.js, 'ethers' must be installed separately as a peer dependency, but it is not listed in package.json.","severity":"gotcha","affected_versions":"*"},{"fix":"Use `JSON.parse(JSON.stringify(identity))` to serialize.","message":"The 'Identity' type uses an array for 'authChain' which may be non-serializable if containing functions. Ensure serialization before sending over network.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change import to '@dcl/crypto' and run `npm install @dcl/crypto`.","cause":"Importing from the deprecated unscoped package name after upgrading to v3.","error":"Module not found: Error: Can't resolve 'dcl-crypto' in '/path/to/file'"},{"fix":"Check docs for new signature: `Authenticator.validateSignature(authChain, authLink, message)`.","cause":"Calling old method signature after upgrading to v3 where the API changed.","error":"TypeError: Authenticator.validateSignature is not a function"},{"fix":"Ensure you pass a valid provider (e.g., from ethers or eth-connect) as the second argument.","cause":"Trying to use createIdentity without providing a valid provider.","error":"MissingProviderError: No provider found. Please inject an Ethereum provider."},{"fix":"Shorten the message or split it into chunks that are individually signed.","cause":"Signing a message that exceeds the maximum allowed length.","error":"Error: The message is too long (max 10000 characters)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}