# Contract reference

The entry points, grouped by what they do. The audited source is the source of truth; this page is the map.

> Full signatures, natspec and errors: [unruggable-labs/adapter](https://github.com/unruggable-labs/adapter), `src/AdapterImplementation.sol` and the interfaces under `src/interfaces/`. Use proxy addresses for integrations - see [Deployments](https://docs.adapterscan.com/deployments.md).

## Read

```solidity
hashBinding(uint8 standard, address boundAddress, uint256 tokenId) view returns (bytes32 ubid)
bindingOf(uint256 agentId) view returns (Binding)            // the coordinates a registered agent is bound to
bindingHashOf(uint256 agentId) view returns (bytes32 ubid)   // its UBID; reverts UnknownAgent
isController(uint256 agentId, address account) view returns (bool)
identityRegistry() view returns (address)                    // an immutable; there is no setter
```

## Counterfactual writes

Authority-checked, emit-only. See [Counterfactual registration](https://docs.adapterscan.com/counterfactual.md) for the list and the indexing rules.

## Full registration and registry writes

```solidity
register(uint8 standard, address boundAddress, uint256 tokenId, string agentURI) returns (uint256 agentId)
register(..., MetadataEntry[] metadata) returns (uint256 agentId)
setAgentURI(uint256 agentId, string newURI)
setMetadata(uint256 agentId, string key, bytes value)
setMetadataBatch(uint256 agentId, MetadataEntry[] metadata)   // one MetadataSet event per entry
setAgentWallet(uint256 agentId, address newWallet, ...)         // forwarded to the registry; its wallet-proof rule applies
unsetAgentWallet(uint256 agentId)
```

The adapter registers the ERC-8004 agent itself and keeps custody of it, so the registry records the adapter as the owner. Control is decided by the binding, re-read on every write. The reserved metadata key `agent-binding` holds the adapter's address; a reader verifies a binding by following it to `bindingOf`.

## Wallet designation

```solidity
setWalletUBID(uint8 standard, address boundAddress, uint256 tokenId) returns (bytes32)   // "I work for this identity"
clearWalletUBID()                                                                           // withdraw it
```

The caller is always the wallet itself. There is no acting-for path here: a wallet's half of the link has to come from that wallet.

## Attestations

```solidity
attest(uint8 attestationType, bytes32 ubid, bytes32 variant, bytes data)
confirmAdditionalAccount(bytes32 ubid)     // = attest(CONFIRM_ACCOUNT, ubid, 0, "")
revoke(bytes32 attestationId)
```

## Events an indexer subscribes to

```solidity
// full registration
AgentBound, AgentURISet, MetadataSet, AgentWalletSet, AgentWalletUnset
// counterfactual
CounterfactualAgentRegistered, CounterfactualAgentURISet, CounterfactualMetadataSet,
CounterfactualMetadataBatchSet, CounterfactualAgentWalletSet, CounterfactualAgentWalletUnset
// wallet designation
WalletUBIDSet, WalletUBIDCleared
// attestations
Attested, AttestationRevoked
```

## Admin

`upgradeToAndCall`, owner-only (a Safe). There is no `setIdentityRegistry`: the registry is an immutable baked into the implementation. An upgrade could still ship an implementation with a different one; the code does not guard against that, so it is an operator rule. See [Trust and security](https://docs.adapterscan.com/trust.md).
