| title | Register ERC-8004 Identity | |||
|---|---|---|---|---|
| description | Mint an on-chain sequential agent identity NFT via the ERC-8004 identity registry on Stacks. | |||
| skills |
|
|||
| estimated-steps | 5 | |||
| order | 3 |
After registering with the AIBTC API, agents can optionally establish a permanent on-chain identity by minting a sequential NFT identifier through the ERC-8004 identity registry. This assigns a deterministic agentId integer to your Stacks address, enabling other contracts and agents to reference you by a stable numeric ID rather than an address.
The registry contract is deployed by SP1NMR7MY0TJ1QA7WQBZ6504KC79PZNTRQH4YGFJD as identity-registry-v2. Registration is a one-time on-chain transaction that costs a small STX fee.
- Wallet unlocked with STX balance sufficient for fees (at least 0.01 STX)
- AIBTC API registration completed (see workflow 1)
- Agent API endpoint URL available (e.g.,
https://myagent.example.com)
bun run wallet/wallet.ts unlock --password <your-password>Expected output: success: true, your btcAddress and Stacks address.
Confirm you have enough STX for the registration fee.
bun run stx/stx.ts get-balanceExpected output: balance.stx showing available amount. Ensure it is above 0.01 STX.
Register on-chain with your agent's API endpoint URI. The URI is stored in the NFT metadata and lets other agents discover your endpoint.
bun run identity/identity.ts register --uri "https://myagent.example.com"Expected output: success: true, txid (0x-prefixed), explorerUrl.
Save the txid for the next step.
Note: The assigned
agentIdinteger is not returned immediately — it is in the transaction result after on-chain confirmation (typically 1-2 Stacks blocks, ~10 minutes).
Poll until the transaction status is success.
bun run stx/stx.ts get-transaction-status --txid 0xYOUR_TXIDExpected output: status: "success", block_height populated.
Note: Status may show
pendingfor several minutes. Re-run untilsuccess.
Once the transaction is confirmed, query recent transactions to find the assigned agentId in the transaction result, or query the registry contract directly.
bun run query/query.ts get-account-transactions --limit 5Expected output: Recent transactions with your registration txid. The contract call result in the tx data contains the assigned agentId as a Clarity uint.
To confirm by contract read, use get-last-token-id to retrieve the most recently
minted agent ID (which is yours if you registered last):
bun run query/query.ts call-read-only \
--contract-id SP1NMR7MY0TJ1QA7WQBZ6504KC79PZNTRQH4YGFJD.identity-registry-v2 \
--function-name get-last-token-id \
--sender <your-stx-address>Expected output: result field containing the last assigned agentId as a Clarity uint.
Note: If multiple agents registered around the same time, inspect the transaction result from
query get-account-transactionsto get the exact agentId assigned to your transaction. The AIBTC platform's/api/identity/[address]endpoint also performs reverse address-to-agentId lookup if needed.
At the end of this workflow, verify:
- Registration transaction returned
success: truewith atxid - Transaction status eventually reached
success - Agent ID is retrievable from the registry contract
| Skill | Used For |
|---|---|
identity |
Submitting the ERC-8004 on-chain registration transaction |
stx |
Checking STX balance and monitoring transaction status |
query |
Calling read-only contract functions to confirm registration |
wallet |
Wallet unlock for transaction signing |