Gating Smart Contracts
Gate on-chain actions behind verified agent identity
1. Import the Registry Interface
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface ISelfAgentRegistry {
// Agent verification
function isVerifiedAgent(bytes32 agentKey) external view returns (bool);
function getAgentId(bytes32 agentKey) external view returns (uint256);
function getAgentCredentials(uint256 agentId) external view returns (AgentCredentials memory);
// Proof-of-human (IERC8004ProofOfHuman)
function hasHumanProof(uint256 agentId) external view returns (bool);
function isProofFresh(uint256 agentId) external view returns (bool);
function proofExpiresAt(uint256 agentId) external view returns (uint256);
function getProofProvider(uint256 agentId) external view returns (address);
// Sybil detection
function sameHuman(uint256 agentIdA, uint256 agentIdB) external view returns (bool);
function getAgentCountForHuman(uint256 nullifier) external view returns (uint256);
function getHumanNullifier(uint256 agentId) external view returns (uint256);
// ERC-8004 metadata
function setAgentURI(uint256 agentId, string calldata newURI) external;
function getMetadata(uint256 agentId, string memory key) external view returns (bytes memory);
function setMetadata(uint256 agentId, string calldata key, bytes calldata value) external;
struct AgentCredentials {
string issuingState;
string[] name;
string idNumber;
string nationality;
string dateOfBirth;
string gender;
string expiryDate;
uint256 olderThan;
bool[3] ofac;
}
}2. onlyVerifiedAgent Modifier
onlyVerifiedAgent Modifier3. Query Credentials On-Chain
4. Check Proof Freshness
5. Sybil Checks
6. EIP-712 Meta-Transaction Pattern
7. Reference Contracts
AgentDemoVerifier
AgentGate
8. Contract Addresses
Celo Mainnet (Chain ID: 42220)
Contract
Address
Celo Sepolia Testnet (Chain ID: 11142220)
Contract
Address
9. Foundry Setup
Next Steps
Last updated