Documentation
¶
Index ¶
- Constants
- Variables
- func SponsoredRegister(ctx context.Context, signer *RemoteSigner, agentURI string, net NetworkConfig) (*big.Int, string, error)
- type AgentRegistration
- type Client
- func (c *Client) AgentWallet(ctx context.Context, agentID *big.Int) (common.Address, error)
- func (c *Client) ChainID() *big.Int
- func (c *Client) Close()
- func (c *Client) CurrentBlockNumber(ctx context.Context) (uint64, error)
- func (c *Client) ETH() *ethclient.Client
- func (c *Client) FindRegistrationByOwnerAndURI(ctx context.Context, owner common.Address, agentURI string, fromBlock uint64) (*big.Int, string, bool, error)
- func (c *Client) FindRegistrationByTxHash(ctx context.Context, txHash string) (*big.Int, string, bool, error)
- func (c *Client) GetMetadata(ctx context.Context, agentID *big.Int, k string) ([]byte, error)
- func (c *Client) Register(ctx context.Context, key *ecdsa.PrivateKey, agentURI string) (*big.Int, error)
- func (c *Client) RegisterDetailed(ctx context.Context, key *ecdsa.PrivateKey, agentURI string) (*big.Int, string, error)
- func (c *Client) RegisterWithOpts(ctx context.Context, opts *bind.TransactOpts, agentURI string) (*big.Int, error)
- func (c *Client) RegisterWithOptsDetailed(ctx context.Context, opts *bind.TransactOpts, agentURI string) (*big.Int, string, error)
- func (c *Client) SetAgentURI(ctx context.Context, key *ecdsa.PrivateKey, agentID *big.Int, uri string) error
- func (c *Client) SetMetadata(ctx context.Context, key *ecdsa.PrivateKey, agentID *big.Int, k string, ...) error
- func (c *Client) SetMetadataWithOpts(ctx context.Context, opts *bind.TransactOpts, agentID *big.Int, k string, ...) error
- func (c *Client) SubmitRegister(ctx context.Context, key *ecdsa.PrivateKey, agentURI string) (string, error)
- func (c *Client) TokenURI(ctx context.Context, agentID *big.Int) (string, error)
- func (c *Client) WaitForAgent(ctx context.Context, agentID *big.Int, timeout time.Duration) (common.Address, error)
- type EIP712Field
- type EIP712TypedData
- type NetworkConfig
- type OnChainReg
- type RemoteSigner
- func (s *RemoteSigner) GetAddress(ctx context.Context) (common.Address, error)
- func (s *RemoteSigner) RemoteTransactOpts(ctx context.Context, addr common.Address, chainID *big.Int) *bind.TransactOpts
- func (s *RemoteSigner) SignTransaction(ctx context.Context, addr common.Address, tx SignTxRequest) (string, error)
- func (s *RemoteSigner) SignTypedData(ctx context.Context, addr common.Address, data EIP712TypedData) (string, error)
- type ServiceDef
- type SignTxRequest
- type SponsorAuthorization
- type SponsoredRegisterRequest
- type SponsoredRegisterResponse
Constants ¶
const ( // IdentityRegistryBaseSepolia is the ERC-8004 Identity Registry on Base Sepolia. IdentityRegistryBaseSepolia = "0x8004A818BFB912233c491871b3d84c89A494BD9e" // ReputationRegistryBaseSepolia is the ERC-8004 Reputation Registry on Base Sepolia. ReputationRegistryBaseSepolia = "0x8004B663056A597Dffe9eCcC1965A193B7388713" // ValidationRegistryBaseSepolia is the ERC-8004 Validation Registry on Base Sepolia. ValidationRegistryBaseSepolia = "0x8004CB39f29c09145F24Ad9dDe2A108C1A2cdfC5" // DefaultRPCURL is the default JSON-RPC endpoint for Base Sepolia. DefaultRPCURL = "https://sepolia.base.org" // BaseSepoliaChainID is the EIP-155 chain ID for Base Sepolia. BaseSepoliaChainID = 84532 )
const RegistrationType = "https://eips.ethereum.org/EIPS/eip-8004#registration-v1"
RegistrationType is the canonical type URI for ERC-8004 registration v1.
Variables ¶
var ( BaseSepolia = NetworkConfig{ Name: "base-sepolia", ChainID: 84532, RegistryAddress: IdentityRegistryBaseSepolia, ERPCNetwork: "base-sepolia", } Base = NetworkConfig{ Name: "base", ChainID: 8453, RegistryAddress: IdentityRegistryBaseSepolia, ERPCNetwork: "base", } Ethereum = NetworkConfig{ Name: "ethereum", ChainID: 1, RegistryAddress: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432", SponsorURL: "https://sponsored.howto8004.com/api/register", DelegateAddress: "0x77fb3D2ff6dB9dcbF1b7E0693b3c746B30499eE8", ERPCNetwork: "mainnet", } )
Predefined network configurations.
Functions ¶
func SponsoredRegister ¶
func SponsoredRegister(ctx context.Context, signer *RemoteSigner, agentURI string, net NetworkConfig) (*big.Int, string, error)
SponsoredRegister performs a zero-gas registration via the sponsor API. It signs the required EIP-712 messages using the remote-signer, then submits them to the sponsor endpoint which broadcasts the transaction.
Types ¶
type AgentRegistration ¶
type AgentRegistration struct {
Type string `json:"type"` // REQUIRED
Name string `json:"name"` // REQUIRED
Description string `json:"description,omitempty"` // REQUIRED (omitempty for parsing)
Image string `json:"image,omitempty"` // REQUIRED (omitempty for parsing)
Services []ServiceDef `json:"services"` // REQUIRED (>=1)
X402Support bool `json:"x402Support"` // REQUIRED
Active bool `json:"active"` // REQUIRED
Registrations []OnChainReg `json:"registrations,omitempty"` // REQUIRED (>=1, omitempty for parsing)
SupportedTrust []string `json:"supportedTrust,omitempty"` // OPTIONAL
Metadata map[string]string `json:"metadata,omitempty"` // OPTIONAL
Provenance map[string]string `json:"provenance,omitempty"` // OPTIONAL
}
AgentRegistration is the JSON schema for the agent registration document served at agentURI (e.g., /.well-known/agent-registration.json). Conforms to ERC-8004 "Trustless Agents" registration format.
REQUIRED fields per spec: type, name, description, image, services (>=1), x402Support, active, registrations (>=1). OPTIONAL: supportedTrust.
Note: Description and Image use omitempty for parsing flexibility but MUST be populated when producing registration documents.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client interacts with the ERC-8004 Identity Registry.
func NewClient ¶
NewClient connects to rpcURL and binds to the Identity Registry on Base Sepolia. For multi-network support, use NewClientForNetwork instead.
func NewClientForNetwork ¶
func NewClientForNetwork(ctx context.Context, rpcBaseURL string, net NetworkConfig) (*Client, error)
NewClientForNetwork connects to the eRPC base URL and binds to the Identity Registry on the given network. The RPC URL is constructed as rpcBaseURL + "/" + net.ERPCNetwork.
func (*Client) AgentWallet ¶
AgentWallet returns the registered wallet for an agent id via the ERC-8004 `getAgentWallet` view, or an error if the READER reports a revert (the pre-mint case appears as ERC721NonexistentToken). Used by WaitForAgent to confirm the chain READER has caught up to a recent register tx before follow-up calls (setMetadata, setAgentURI) try to estimate gas against a state where the token id is still unknown.
func (*Client) CurrentBlockNumber ¶
CurrentBlockNumber returns the current tip height for the connected chain.
func (*Client) FindRegistrationByOwnerAndURI ¶
func (c *Client) FindRegistrationByOwnerAndURI(ctx context.Context, owner common.Address, agentURI string, fromBlock uint64) (*big.Int, string, bool, error)
FindRegistrationByOwnerAndURI recovers a registration by scanning recent Registered events for the controller wallet and published URI.
func (*Client) FindRegistrationByTxHash ¶
func (c *Client) FindRegistrationByTxHash(ctx context.Context, txHash string) (*big.Int, string, bool, error)
FindRegistrationByTxHash resolves a previously submitted registration transaction once it has been mined.
func (*Client) GetMetadata ¶
GetMetadata reads metadata for the given key from the agent NFT.
func (*Client) Register ¶
func (c *Client) Register(ctx context.Context, key *ecdsa.PrivateKey, agentURI string) (*big.Int, error)
Register mints a new agent NFT with the given agentURI using a raw private key. Returns the minted agentId (token ID).
func (*Client) RegisterDetailed ¶
func (c *Client) RegisterDetailed(ctx context.Context, key *ecdsa.PrivateKey, agentURI string) (*big.Int, string, error)
RegisterDetailed mints a new agent NFT with the given agentURI and returns both the minted agentId and transaction hash.
func (*Client) RegisterWithOpts ¶
func (c *Client) RegisterWithOpts(ctx context.Context, opts *bind.TransactOpts, agentURI string) (*big.Int, error)
RegisterWithOpts mints a new agent NFT using the provided TransactOpts. This allows callers to supply a custom Signer (e.g. remote-signer).
func (*Client) RegisterWithOptsDetailed ¶
func (c *Client) RegisterWithOptsDetailed(ctx context.Context, opts *bind.TransactOpts, agentURI string) (*big.Int, string, error)
RegisterWithOptsDetailed mints a new agent NFT using the provided TransactOpts and returns both the minted agentId and transaction hash.
func (*Client) SetAgentURI ¶
func (c *Client) SetAgentURI(ctx context.Context, key *ecdsa.PrivateKey, agentID *big.Int, uri string) error
SetAgentURI updates the agentURI for an existing agent NFT.
func (*Client) SetMetadata ¶
func (c *Client) SetMetadata(ctx context.Context, key *ecdsa.PrivateKey, agentID *big.Int, k string, v []byte) error
SetMetadata stores arbitrary key-value metadata on the agent NFT.
func (*Client) SetMetadataWithOpts ¶
func (c *Client) SetMetadataWithOpts(ctx context.Context, opts *bind.TransactOpts, agentID *big.Int, k string, v []byte) error
SetMetadataWithOpts stores key-value metadata using the provided TransactOpts.
func (*Client) SubmitRegister ¶
func (c *Client) SubmitRegister(ctx context.Context, key *ecdsa.PrivateKey, agentURI string) (string, error)
SubmitRegister submits a registration transaction and returns its hash without waiting for the receipt.
func (*Client) WaitForAgent ¶
func (c *Client) WaitForAgent(ctx context.Context, agentID *big.Int, timeout time.Duration) (common.Address, error)
WaitForAgent polls AgentWallet until the chain READER reports the agent id as owned (any address). Returns when it does, or err on timeout. This closes the read-side staleness window after Register: the Register tx confirms via WaitMined on the WRITE upstream, but a subsequent setMetadata estimateGas goes through the READ upstream which may still be a block or two behind (we hit this in production when a stale eRPC route was pinned to a parallel Anvil fork — the simulation reverted with ERC721NonexistentToken).
type EIP712Field ¶
EIP712Field describes a single field in an EIP-712 type.
type EIP712TypedData ¶
type EIP712TypedData struct {
Types map[string][]EIP712Field `json:"types"`
PrimaryType string `json:"primaryType"`
Domain map[string]interface{} `json:"domain"`
Message map[string]interface{} `json:"message"`
}
EIP712TypedData represents a full EIP-712 typed data structure for signing.
type NetworkConfig ¶
type NetworkConfig struct {
// Name is the canonical network name (e.g. "base-sepolia", "base", "ethereum").
Name string
// ChainID is the EIP-155 chain identifier.
ChainID int64
// RegistryAddress is the ERC-8004 Identity Registry contract address on this chain.
RegistryAddress string
// SponsorURL is the sponsored registration API endpoint (empty if not available).
SponsorURL string
// DelegateAddress is the EIP-7702 delegation contract used by the sponsor.
DelegateAddress string
// ERPCNetwork is the path segment used by eRPC to route to this chain
// (e.g. "base-sepolia", "base", "mainnet").
ERPCNetwork string
}
NetworkConfig describes an ERC-8004 registration network.
func ResolveNetwork ¶
func ResolveNetwork(name string) (NetworkConfig, error)
ResolveNetwork maps a network name to its configuration.
func ResolveNetworks ¶
func ResolveNetworks(csv string) ([]NetworkConfig, error)
ResolveNetworks parses a comma-separated list of network names.
func SupportedNetworks ¶
func SupportedNetworks() []NetworkConfig
SupportedNetworks returns all supported registration networks.
func (NetworkConfig) CAIP10Registry ¶
func (n NetworkConfig) CAIP10Registry() string
CAIP10Registry returns the CAIP-10 formatted registry identifier.
func (NetworkConfig) HasSponsor ¶
func (n NetworkConfig) HasSponsor() bool
HasSponsor returns true if this network supports sponsored (zero-gas) registration.
type OnChainReg ¶
type OnChainReg struct {
AgentID int64 `json:"agentId"` // ERC-721 tokenId
AgentRegistry string `json:"agentRegistry"` // CAIP-10 format: "eip155:84532:0x8004A818..."
}
OnChainReg links the registration to its on-chain record.
type RemoteSigner ¶
type RemoteSigner struct {
// contains filtered or unexported fields
}
RemoteSigner wraps the remote-signer REST API for signing operations. It communicates with the signer over HTTP (typically via a port-forward).
func NewRemoteSigner ¶
func NewRemoteSigner(baseURL string) *RemoteSigner
NewRemoteSigner creates a client for the remote-signer API at the given base URL.
func (*RemoteSigner) GetAddress ¶
GetAddress returns the first loaded signing address from the remote-signer.
func (*RemoteSigner) RemoteTransactOpts ¶
func (s *RemoteSigner) RemoteTransactOpts(ctx context.Context, addr common.Address, chainID *big.Int) *bind.TransactOpts
RemoteTransactOpts creates a bind.TransactOpts that delegates signing to the remote-signer. The returned opts can be used with Client.RegisterWithOpts and Client.SetMetadataWithOpts.
func (*RemoteSigner) SignTransaction ¶
func (s *RemoteSigner) SignTransaction(ctx context.Context, addr common.Address, tx SignTxRequest) (string, error)
SignTransaction signs an EIP-1559 transaction via the remote-signer. Returns the RLP-encoded signed transaction bytes (hex-encoded with 0x prefix).
func (*RemoteSigner) SignTypedData ¶
func (s *RemoteSigner) SignTypedData(ctx context.Context, addr common.Address, data EIP712TypedData) (string, error)
SignTypedData signs EIP-712 typed data via the remote-signer. Returns the 65-byte signature as a hex string with 0x prefix.
type ServiceDef ¶
type ServiceDef struct {
Name string `json:"name"` // e.g., "web", "A2A", "MCP", "OASF"
Endpoint string `json:"endpoint,omitempty"` // full URL (omitempty for OASF entries)
Version string `json:"version,omitempty"` // protocol version (SHOULD per spec)
Skills []string `json:"skills,omitempty"` // OASF skill taxonomy paths
Domains []string `json:"domains,omitempty"` // OASF domain taxonomy paths
}
ServiceDef describes an endpoint the agent exposes. For OASF entries (name="OASF"), Skills and Domains provide machine-readable taxonomy for agent discovery. See https://schema.oasf.outshift.com/
type SignTxRequest ¶
type SignTxRequest struct {
ChainID string `json:"chain_id"`
To string `json:"to"`
Nonce string `json:"nonce"`
GasLimit string `json:"gas_limit"`
MaxFeePerGas string `json:"max_fee_per_gas"`
MaxPriorityFeePerGas string `json:"max_priority_fee_per_gas"`
Value string `json:"value"`
Data string `json:"data"`
}
SignTxRequest contains the canonical request body for remote-signer EIP-1559 transaction signing. The canonical wire contract is published in ObolNetwork/remote-signer at schema/sign-transaction-request.canonical.schema.json.
type SponsorAuthorization ¶
type SponsorAuthorization struct {
Address string `json:"address"`
ChainID int64 `json:"chainId"`
Nonce int64 `json:"nonce"`
R string `json:"r"`
S string `json:"s"`
YParity int `json:"yParity"`
}
SponsorAuthorization is the EIP-7702 authorization included in sponsored registration.
type SponsoredRegisterRequest ¶
type SponsoredRegisterRequest struct {
AgentAddress string `json:"agentAddress"`
AgentURI string `json:"agentURI"`
Deadline int64 `json:"deadline"`
IntentSignature string `json:"intentSignature"`
Authorization SponsorAuthorization `json:"authorization"`
}
SponsoredRegisterRequest is the request body for the sponsored registration API.