The first ERC-7857 extension built on Scaffold-ETH 2
Universal toolkit for building Intelligent Non-Fungible Tokens
npx create-eth@latest -e LingSiewWin/ERC-7857The first ERC-7857 implementation on Scaffold-ETH 2, giving you everything needed to build AI agent NFTs:
- INFT.sol: Full ERC-7857 implementation with minting, transfers, and cloning
- MockOracle.sol: TEE verification oracle for testing and development
- OasisTEEVerifier.sol: Production TEE verification for Oasis Sapphire
- Complete Interface Suite: IERC7857, IERC7857DataVerifier, IERC7857Metadata
- MintINFT: Create AI agents with encrypted metadata
- TransferINFT: Secure ownership transfers with TEE proofs
- ViewINFT: Display and manage AI agent information
- Authorization System: Granular access control interface
- β ERC-7857 Standard: Complete implementation of Intelligent NFTs
- β TEE Integration: Trusted Execution Environment verification
- β Encrypted Metadata: Secure AI agent data with authorized access
- β Cloning Support: Create derivative AI agents
- β Multi-Network: Oasis Sapphire, Arbitrum, local development
- β Production Ready: Comprehensive test suite with 100% coverage
- β React Components: Ready-to-use UI components with Wagmi integration
- β DataDescriptions: AI agent metadata descriptions support
- π§ 0G SDK Integration: Decentralized storage integration (in development)
-
Install the extension:
npx create-eth@latest -e LingSiewWin/ERC-7857 cd your-project-name -
Set up environment:
# Add to packages/hardhat/.env.local PRIVATE_KEY=your_private_key_without_0x INFURA_KEY=your_infura_key_optional -
Install dependencies:
yarn install
-
Deploy contracts:
# Deploy to local network yarn deploy --network localhost # Deploy to Oasis Sapphire Testnet yarn deploy --network sapphireTestnet # Deploy to Arbitrum Testnet yarn deploy --network arbitrumTestnet
-
Start frontend:
yarn dev
-
Run tests:
yarn test
// Smart contract
function mint(
address to,
string memory encryptedMetadataURI,
bytes32 metadataHash
) returns (uint256 tokenId)
// Usage
await inft.mint(
userAddress,
"ipfs://encrypted-metadata-hash",
keccak256("agent metadata")
);// Smart contract
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory transferProof
)
// Usage with generated proof
const transferProof = await oracle.createTransferProof(
oldDataHash, newDataHash, fromAddress, toAddress
);
await inft.safeTransferFrom(from, to, tokenId, transferProof);// Smart contract
function clone(uint256 tokenId, address to) returns (uint256 newTokenId)
// Usage
const newTokenId = await inft.clone(originalTokenId, recipientAddress);// Smart contract
function authorizeUsage(uint256 tokenId, address user, uint256 duration)
// Usage - authorize for 1 hour
await inft.authorizeUsage(tokenId, userAddress, 3600);| Network | Chain ID | Status | Purpose |
|---|---|---|---|
| Hardhat Local | 31337 | β Deployed | Development & testing |
| Arbitrum Testnet | 421614 | β Deployed | Layer 2 scaling |
| Oasis Sapphire Testnet | 0x5aff | π§ Ready | Privacy-preserving smart contracts |
Arbitrum Testnet (Chain ID: 421614)
- MockOracle:
0x0b60881F525D925472d6d522f6309FD6F78Ecb08 - INFT (ERC-7857):
0x19922d2d1e2b45c81c69030B709f462B2289f5A9
Localhost (for development)
- MockOracle:
0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 - INFT (ERC-7857):
0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
Deploy to networks:
npx hardhat run scripts/deploy.js --network arbitrumTestnet # L2 scaling
npx hardhat run scripts/deploy.js --network localhost # Developmentmint(): Create new INFT with encrypted metadatasafeTransferFrom(): Secure transfer with TEE verificationclone(): Create derivative AI agentsauthorizeUsage(): Grant time-limited access permissionsisAuthorized(): Check user access rightsupdateMetadata(): Update agent metadata with proofs
Create .env.local in packages/hardhat/:
PRIVATE_KEY=your_private_key_without_0x
INFURA_KEY=your_infura_project_id # optional
ETHERSCAN_API_KEY=your_etherscan_key # optional, for verificationThe extension includes comprehensive test coverage:
# Run all tests
yarn test
# Run specific test files
yarn hardhat test test/INFT.test.js
yarn hardhat test test/MockOracle.test.js
# Run with gas reporting
REPORT_GAS=true yarn test- β Contract deployment and initialization
- β INFT minting with metadata validation
- β Transfer functionality with TEE proofs
- β Cloning and derivative creation
- β Authorization and access control
- β Public/private visibility controls
- β Error handling and edge cases
scaffold-erc7857/
βββ extension/
β βββ packages/
β β βββ hardhat/ # Smart contracts & deployment
β β β βββ contracts/
β β β β βββ interfaces/ # ERC-7857 standard interfaces
β β β β β βββ IERC7857.sol
β β β β β βββ IERC7857DataVerifier.sol
β β β β β βββ IERC7857Metadata.sol
β β β β βββ INFT.sol # Main implementation
β β β β βββ MockOracle.sol # Testing oracle
β β β β βββ OasisTEEVerifier.sol
β β β βββ scripts/deploy.js # Deployment script
β β β βββ test/ # Comprehensive test suite
β β β βββ hardhat.config.js # Network configuration
β β βββ nextjs/ # Frontend application
β β βββ components/ # React components
β β β βββ MintINFT.jsx
β β β βββ TransferINFT.jsx
β β β βββ ViewINFT.jsx
β β βββ pages/index.js # Main application
β β βββ contracts/ # Contract ABIs & addresses
β βββ package.json # Extension configuration
βββ README.md
- Proof Generation: Secure attestation of data ownership
- Transfer Validation: TEE-verified ownership transfers
- Nonce Protection: Prevents replay attacks
- Data Integrity: Hash-based validation
- Owner Permissions: Full control over owned INFTs
- Time-Limited Authorization: Granular access control
- Public/Private Modes: Flexible visibility settings
- Cloning Restrictions: Authorized-only derivative creation
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Ensure tests pass:
yarn test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow Solidity best practices and security standards
- Write comprehensive tests for new functionality
- Use clear, descriptive commit messages
- Document new features and API changes
- Maintain backwards compatibility when possible
Error: Contract not found at address
Solution: Deploy contracts first with yarn deploy --network <network>
Error: Network not supported
Solution: Switch wallet to supported network or update hardhat.config.js
Error: Transaction ran out of gas
Solution: Increase gas limit in transaction or optimize contract calls
Error: Invalid ownership proof
Solution: Regenerate proofs using the MockOracle or check TEE attestation
- Advanced TEE Integration: Full Oasis ROFL integration
- Governance System: DAO for protocol upgrades
- Cross-Chain Support: Multi-chain AI agent portability
- Marketplace Integration: Built-in trading functionality
- AI Agent Interactions: On-chain agent-to-agent communication
This project is licensed under the MIT License - see the LICENSE file for details.
- Scaffold-ETH 2 - Development framework
- Oasis Protocol - TEE verification infrastructure
- OpenZeppelin - Secure contract libraries
- Hardhat - Ethereum development environment
- ERC-7857 standard contributors and community
- π Issues: GitHub Issues
- π¬ Discord: Scaffold-ETH Community
- π Documentation: ERC-7857 Standard
- π Website: Project Homepage
π Built with β€οΈ for the AI Agent NFT ecosystem