Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test CI

on:
push:
branches: [main]
branches: [main, v3]
tags: ["*"]
pull_request:
types: [opened, reopened, synchronize]
Expand Down
6 changes: 3 additions & 3 deletions docs/AgentNFTs.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ When holders can write, a seller can change their token's records up to the mome

### Reference policy

`src/lib/MetadataWriterPolicy.sol` is a small policy contract to set as the metadata authority. The contract doesn't need it, and it shows what a policy can do. Its owner (the admin) can allow several writer addresses with `setWriter`, such as a hot wallet that runs a metadata job. A writer can write records and nothing else. A token's current holder can delegate their token's writes to one address with `setDelegate`, such as their agent's wallet. A delegation counts only while the holder who set it still holds the token, so it lapses on transfer. It counts again if the token comes back to that holder.
`src/lib/MetadataWriterPolicy.sol` is a small policy contract to set as the metadata authority. The contract doesn't need it, and it shows what a policy can do. Its owner (the admin) can allow several writer addresses with `setWriter`, such as a hot wallet that runs a metadata job. A writer can write records and nothing else. A token's current holder can delegate their token's writes to one address with `setDelegate`, such as their agent's wallet. A delegation applies only while the holder who set it still holds the token. It stops applying on transfer and applies again if the token comes back to that holder. The current holder can clear it with `setDelegate(tokenId, address(0))`.

Writers and delegates call the policy's `setMetadata` and `setMetadataBatch`, which check the caller and forward the write to the token. The admin can also call `setCollectionAuthority` through the policy, for example to hand the authority to a new policy.

Expand All @@ -93,7 +93,7 @@ The admin can unmark a key, and the owner can replace an unlocked policy. For a

### Batches

`setMetadataBatch` writes many records in one transaction. If the caller can't write any one entry, the whole batch reverts. A set authority, or the owner while the authority is blank, can write every entry.
`setMetadataBatch` writes many records in one transaction. If the caller can't write any one entry, the whole batch reverts. A set authority can write every entry. With a blank authority, the owner can write every entry only while `ownerCannotWrite` is off. Holders can write entries only for tokens they currently hold, and only while `holderCanWrite` is on.

### Events and keys

Expand All @@ -116,6 +116,6 @@ Token id 0 is not special. Put collection-level data in the contract URI.

- The NFT's page shows that the token is bound to an agent, from the adapter's `AgentBound` event.
- The agent card shows on the agent's identity item in the ERC-8004 registry, read from the agent URI.
- OpenSea doesn't read ERC-8048 records. Anything OpenSea should show, such as the name, image and traits, goes in the `tokenURI` JSON. Don't copy agent keys such as `context` or `endpoint[mcp]` into that JSON: ERC-8495, the draft standard for `tokenURI` JSON, asks for field names of lowercase letters, digits and underscores that won't collide with future extensions.
- OpenSea does not automatically interpret arbitrary ERC-8048 agent records. The token's name, image and traits come from its `tokenURI` metadata. Explicit ERC-8493 `onchain:` URIs in that metadata, or returned by `tokenURI`, can resolve values stored through ERC-8048; see [Metadata storage](https://docs.opensea.io/docs/metadata-storage). Don't copy agent keys such as `context` or `endpoint[mcp]` into that JSON: ERC-8495, the draft standard for `tokenURI` JSON, asks for field names of lowercase letters, digits and underscores that won't collide with future extensions.
- OpenSea refreshes a token's metadata when it sees an ERC-4906 event, and every record write to a minted token emits one.
- Agents created with the adapter's `counterfactualRegister` are not indexed.
2 changes: 1 addition & 1 deletion docs/v3/AuditScope.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Token events: a clone's initialization emits `OwnershipTransferred(address(0), o

- Foundry, with solc 0.8.38 targeting Cancun and 1,000,000 optimizer runs, without via-IR. Every network we deploy to supports Cancun's opcodes.
- Build with `forge build`, and run the v3 tests with `forge test --match-path 'test/v3/*'`.
- CI runs both v1 and v3 tests, including agent metadata, registration and storage-slot coverage and distinct payer/wallet/recipient event assertions. The migration's validated commit has 605 passing tests and two skipped fork tests across 43 suites. Refresh these counts at code freeze. There are no invariant tests yet; add payment-accounting, wallet-limit and stage-cap invariants before freeze.
- CI runs both v1 and v3 tests, including agent metadata, registration and storage-slot coverage and distinct payer/wallet/recipient event assertions. The migration's validated commit has 605 passing tests and two skipped fork tests across 43 suites. Refresh these counts at code freeze. The stateful suite in `test/v3/SeaDropMinterInvariant.t.sol` checks native/ERC-20 conservation, exact payout liabilities, failed withdrawals, unsolicited surplus, cross-stage wallet and supply accounting, and rejected payment and authorization paths. It seeds successful mints and withdrawals, then fuzzes action sequences with unexpected reverts treated as failures.
- A public mint through a clone costs 144k to 169k gas, against 129k for v1 and 202k for v2. About 2.85k of that is the clone's `DELEGATECALL` (see "Token deployment"). Every paid mint writes the wallet's count, even in a stage with no wallet limit. That costs about 23k on a wallet's first mint of a token and id, and about 5k on later ones. Skipping it in unlimited stages would save the write, but a later limited stage couldn't see those mints. A stage cap adds about 1.1k to every mint in the stage, for the view call that reads the token's total. It writes nothing, so the first mint costs the same as later ones. The minter's runtime bytecode is 22,242 bytes, 2,334 under the EIP-170 limit. The ERC-721 implementation is 11,065 bytes and the ERC-1155 11,258. The factory's runtime is 2,287 bytes, and its init code, which carries both implementations, is 26,159 bytes, 22,993 under EIP-3860's limit. The mint adapter's runtime is 5,099 bytes and the transfer adapter's 7,201.

## Deployment
Expand Down
5 changes: 5 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ ignored_warnings_from = ['script']
additional_compiler_profiles = []
compilation_restrictions = []

[profile.default.invariant]
runs = 128
depth = 64
fail_on_revert = true

[profile.ir_inspect]
test = 'src'

Expand Down
Loading
Loading