ERC-7513 · Draft · ERC · 2023-09-06
ERC-7513: Smart NFT - A Component for Intent-Centric
Proposes 'Smart NFTs': ERC-1155 tokens that each grant the right to execute a registered, verifier-audited piece of contract code, plus a proxy that batches several of them to fulfil a user's intent.
What problem does it solve?
The authors see three gaps. Users who want automation often hand their private keys to bots. Independent developers struggle to turn a useful contract into a product. And there is no standard on-chain way to transfer ownership of code itself.
ERC-7513 treats a piece of executable contract logic as an NFT. Holding the token is the permission to run the code, so no private key is shared. The code can be bought and sold like any other NFT, and several such modules can be chained to carry out a higher-level "intent".
How it works
There are three components:
- Smart-NFT: the executable module. It must implement
execute(bytes data), taking all its parameters as one encodedbytesblob, and must callvalidatePermission()inside it. That check asks the Smart-Manager whether the module is verified and whether the caller may use it. - Smart-Manager: a registry that should itself be an ERC-1155 contract. Developers
register(creationCode, totalSupply), which deploys the module, mints its token id, and marks itUNVERIFIED. Trusted verifiers callauditTo(tokenId, isValid)to move it toVERIFIEDorDENIED.isAccessible(caller, tokenId)must check both that the caller holds the token and that the module is verified. The possible states areUNREGISTERED,DEREGISTERED,UNVERIFIED,VERIFIEDandDENIED. - Intent-Proxy:
executeIntent(Action[])where eachActionis{tokenId, executeParam}. It lets a user run several Smart-NFTs in one call.
ERC-1155 was chosen because its "shares" model fits: owning at least one unit of a token id grants use of that module, and owning more adds nothing, much like owning two phones of the same model. It also means existing NFT marketplaces can trade the modules.
Sample code
Interfaces from the spec:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
interface ISmartNFT {
function execute(bytes memory data) external payable returns (bool);
function validatePermission() external view returns (bool);
}
interface ISmartManager {
enum VerificationStatus { UNREGISTERED, DEREGISTERED, UNVERIFIED, VERIFIED, DENIED }
function register(bytes calldata creationCode, uint256 totalSupply)
external returns (uint256 tokenId, address implAddr);
function auditTo(uint256 tokenId, bool isValid) external returns (bool);
function isAccessible(address caller, uint256 tokenId) external view returns (bool);
function verificationStatusOf(uint256 tokenId) external view returns (VerificationStatus);
}
interface IIntentProxy {
struct Action { uint256 tokenId; bytes executeParam; }
function executeIntent(Action[] calldata actions) external payable returns (bool);
}
Using it from a client (ethers v6):
const actions = [
{ tokenId: 1n, executeParam: swapParams }, // e.g. a swap module
{ tokenId: 2n, executeParam: stakeParams }, // then a staking module
];
await intentProxy.executeIntent(actions);
Things to know
- Status is Draft.
- Safety depends almost entirely on the verifiers who call
auditTo. The spec does not define who they are or how they are chosen, and it acknowledges risks from malicious or mistaken verifiers. - How
validatePermission()identifies the original caller when invoked via the Intent-Proxy is left to implementations. - The reference implementation is an external repository linked from the spec.