This example generates a new entity secret, registers it with Circle, saves the
recovery file locally, and writes CIRCLE_ENTITY_SECRET to .env.
Use this script only for first-time setup. If .env already contains
CIRCLE_ENTITY_SECRET, the script exits without making changes.
When you run the script, it:
- Reads
CIRCLE_API_KEYfrom.envor your shell environment. - Generates a new 32-byte entity secret.
- Registers the entity secret with Circle.
- Saves the recovery file to
./output/recovery-file.dat. - Writes
CIRCLE_ENTITY_SECRETto./.env.
Before you run the script:
- Create an API key in Circle Console.
- Install Node.js 22 or later.
- Create a
.envfile withCIRCLE_API_KEY=or export it in your shell. - Do not add
CIRCLE_ENTITY_SECRETmanually. The script writes it to.env. - Make sure
.envdoes not already containCIRCLE_ENTITY_SECRET.
npm installnpx tsx index.ts- Store the entity secret securely. Do not commit it to version control.
- Store the recovery file separately from the entity secret.
- If you lose both the entity secret and the recovery file, you permanently lose access to your developer-controlled wallets.
- This script is for first-time registration only. Do not use it for rotation or recovery flows.
For the full entity secret lifecycle, see: