Quickstart
Clone, build, test, and deploy the ERC-8004 Identity Adapter.
Prerequisites#
- Foundry (
forge,cast,anvil) - An ERC-8004
IdentityRegistrydeployment to point the adapter at
Clone#
git clone https://github.com/idchain-world/erc8004-identity-adapter.git
cd erc8004-identity-adapter
Build + test#
forge build
forge test
forge fmt
The test suite includes unit tests, adversarial tests against malicious token contracts, and fuzz tests covering every controller invariant. Expect all tests to pass on a clean clone.
Deploy the proxy#
Copy .env.example to .env and fill in the three values:
cp .env.example .env
# edit .env
IDENTITY_REGISTRY_ADDRESS=0x... # ERC-8004 registry to forward into
PRIVATE_KEY=0x... # deployer — automatically becomes admin
RPC_URL=https://... # target chain RPC
Then source it and run the deploy script:
source .env
forge script script/DeployAdapter.s.sol --rpc-url $RPC_URL --broadcast
DeployAdapter.s.sol deploys the implementation, wraps it in an ERC1967
proxy, and initializes the proxy with your registry address. The deployer
becomes the adapter admin — it controls future UUPS upgrades and can
repoint identityRegistry.
Register your first binding#
Once deployed, any account that controls an external token can register an ERC-8004 identity bound to that token:
// Pseudocode — exact types depend on the interface revision in your repo
adapter.register(
TokenStandard.ERC721, // standard
address(myNftCollection),
tokenId,
"ipfs://agent-metadata.json",
metadata
);
The call returns the newly-minted ERC-8004 agentId. From that point on,
whoever controls the underlying token can forward writes through the adapter:
adapter.setAgentURI(agentId, "ipfs://new-metadata.json");
adapter.setMetadata(agentId, "description", bytes("..."));
adapter.setAgentWallet(agentId, runtimeWallet, deadline, signature);
See the API reference for the full function list.
Running the audit test suite#
The repo ships with a three-file security test layout under test/security/:
# fast run
forge test --match-path "test/security/*"
# coverage
forge coverage --no-match-coverage "test/|script/"
Coverage of src/Adapter8004.sol should be 100% on lines,
statements, branches, and functions.