ERC-8004 Rust SDK for identity, reputation, and validation, with optional x402 payment flows, middleware, and optional Stripe/Coinbase adapters.
erc8004-rust-sdk is an early-stage Rust project in the AI payments / x402 ecosystem, focused on coinbase-wallet, erc8004, ethereum, rust. It currently has 0 GitHub stars and 0 forks, and sits alongside related tools like sdk, tdm-integration-kit, tdm-sdk, TDM-Agent-Integration-Kit, afara, x402-openai-python.
Production-ready ERC-8004 Rust SDK for identity, reputation, and validation, with optional x402 payment flows and middleware, plus optional Stripe and Coinbase adapters.
402 challenge/response, verification, replay protection, policy, observability)SDK_USAGE_GUIDE.mdQuick Start (SDK) section belowOptional x402 Payments Extension section belowLive Sandbox Tests (Optional) section below| Crate | Purpose |
|---|---|
crates/erc8004-core |
ABI bindings, canonical ERC-8004 types, adapter traits/ports, tx helpers |
crates/erc8004-sdk |
High-level Identity/Reputation/Validation clients, network presets, multichain helpers, off-chain fetch |
crates/erc8004-payments-x402 |
Optional x402 extension: protocol validation, pay-and-retry client flow, spend policy, observability |
crates/erc8004-payments-x402-middleware |
Optional Axum middleware for paid endpoints + /.well-known/x402 discovery |
crates/erc8004-payments-x402-stripe |
Optional Stripe adapter: PaymentIntent mapping, webhook signature + settlement parsing |
crates/erc8004-payments-x402-coinbase |
Optional Coinbase adapter: wallet profile parsing + x402 requirements mapping |
crates/erc8004-agent-framework |
Agent runtime loop, dispatcher, storage abstractions |
crates/erc8004-verifiable |
Prover abstractions and verifiable pipeline components |
tests/integration |
Anvil-backed end-to-end integration tests, including x402 payment flow |
erc-8004/erc-8004-contracts commit 29e1ccb7ae9038950f6949d6348e2d1b866ee7e3use alloy::network::EthereumWallet;
use alloy::providers::ProviderBuilder;
use alloy::signers::local::PrivateKeySigner;
use erc8004_sdk::adapters::alloy::AlloyTransport;
use erc8004_sdk::client::Erc8004Client;
use erc8004_sdk::config::{Erc8004Addresses, Erc8004Config};
# fn main() -> Result<(), Box<dyn std::error::Error>> {
let signer: PrivateKeySigner =
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".parse()?;
let wallet = EthereumWallet::new(signer.clone());
let provider = ProviderBuilder::new()
.wallet(wallet)
.connect_http("http://127.0.0.1:8545".parse()?);
let adapter = AlloyTransport::new(provider, signer);
let addresses = Erc8004Addresses::new(
"0x8004A818BFB912233c491871b3d84c89A494BD9e",
"0x8004B663056A597Dffe9eCcC1965A193B7388713",
"0x0000000000000000000000000000000000000001",
11_155_111,
);
let config = Erc8004Config::new(adapter, addresses)
.with_signer_address("0x1111111111111111111111111111111111111111")?;
let client = Erc8004Client::new(config);
assert_eq!(client.get_chain_id(), 11_155_111);
# Ok(())
# }
Enable x402 in the SDK without changing baseline behavior:
erc8004-sdk = { path = "crates/erc8004-sdk", features = ["payments-x402"] }
# #[cfg(feature = "payments-x402")]
# {
use erc8004_sdk::payments::x402::{
InMemoryPaymentEventSink, PaymentPayload, PaymentPayloadBuilder,
PaymentRequiredChallenge, SessionSpendPolicy, X402Error, X402HttpClient,
X402SecurityPolicy,
};
use std::sync::Arc;
struct StaticBuilder;
impl PaymentPayloadBuilder for StaticBuilder {
fn build_payment_payload(
&self,
_challenge: &PaymentRequiredChallenge,
) -> Result<PaymentPayload, X402Error> {
unimplemented!("attach signer/facilitator-specific payment payload")
}
}
let policy = X402SecurityPolicy::default();
let spend_policy = SessionSpendPolicy::new()
.with_max_total_amount(5_000_000)
.with_max_per_payment_amount(1_000_000)
.with_allowed_networks(["eip155:8453", "eip155:84532"]);
let events = InMemoryPaymentEventSink::default();
let _client = X402HttpClient::with_policy(reqwest::Client::new(), StaticBuilder, policy)
.with_spend_policy(Arc::new(spend_policy))
.with_event_sink(Arc::new(events));
# }
Default security posture includes:
PAYMENT-REQUIRED header sizeFor local development only, use explicit overrides such as X402SecurityPolicy::permissive_for_local_dev().
Use erc8004-payments-x402-middleware to gate paid endpoints:
use std::sync::Arc;
use async_trait::async_trait;
use axum::{middleware, routing::get, Router};
use erc8004_payments_x402_middleware::{
x402_gate_middleware, ChallengeProvider, PaidServiceDescriptor, PaymentProofVerifier,
RequestMetadata, X402GateState,
};
# #[derive(Clone)]
# struct Challenge;
# #[derive(Clone)]
# struct Verifier;
# #[async_trait]
# impl ChallengeProvider for Challenge {
# async fn challenge_for(
# &self,
# _request: &RequestMetadata,
# ) -> Result<erc8004_payments_x402::PaymentRequiredChallenge, erc8004_payments_x402_middleware::GateError> {
# unimplemented!()
# }
# }
# #[async_trait]
# impl PaymentProofVerifier for Verifier {
# async fn verify_payload(
# &self,
# _payload: &erc8004_payments_x402::PaymentPayload,
# ) -> Result<erc8004_payments_x402::VerifyResponse, erc8004_payments_x402_middleware::GateError> {
# unimplemented!()
# }
# }
let gate_state = Arc::new(X402GateState::new(Challenge, Verifier));
let _app = Router::new()
.route("/premium", get(|| async { "paid response" }))
.route(
"/.well-known/x402",
get(erc8004_payments_x402_middleware::discovery_handler),
)
.with_state(Arc::new(PaidServiceDescriptor {
service_name: "example".to_string(),
service_version: "1.0.0".to_string(),
resources: vec![],
}))
.layer(middleware::from_fn_with_state(
gate_state,
x402_gate_middleware::<Challenge, Verifier>,
));
erc8004-payments-x402-stripe: map PaymentIntent metadata to x402 routing and verify webhook signatures before settlement handling.erc8004-payments-x402-coinbase: parse wallet profile payloads and derive x402 PaymentRequirements for agent wallet flows.The Stripe and Coinbase adapter crates include ignored integration tests that call real sandbox/API endpoints.
Use sandbox credentials only:
export STRIPE_TEST_SECRET_KEY=sk_test_xxx
export STRIPE_TEST_PAY_TO=0x209693Bc6afc0C5328bA36FaF03C514EF312287C # optional
export STRIPE_TEST_API_BASE=https://api.stripe.com # optional
cargo test -p erc8004-payments-x402-stripe --test live_sandbox -- --ignored
export COINBASE_TEST_WALLET_PROFILE_URL=https://...
export COINBASE_TEST_BEARER_TOKEN=... # optional (or COINBASE_TEST_API_KEY)
export COINBASE_TEST_API_KEY=... # optional (used if bearer token is absent)
export COINBASE_TEST_AMOUNT=1000 # optional
export COINBASE_TEST_ASSET=0x036CbD53842c5426634e7929541eC2318f3dCF7e # optional
cargo test -p erc8004-payments-x402-coinbase --test live_sandbox -- --ignored
cargo run -p erc8004-sdk --example config_from_network
cargo run -p erc8004-agent-framework --example basic_bot
cargo run -p erc8004-verifiable --example auditor_agent
These match CI checks on main:
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
cargo test -p erc8004-sdk --no-default-features
cargo test -p erc8004-sdk --features payments-x402
cargo test -p erc8004-payments-x402
cargo test -p erc8004-sdk --doc
cargo test -p erc8004-sdk --doc --features payments-x402
Integration tests require anvil (Foundry):
cargo test -p erc8004-integration
scripts/fetch_upstream_abis.sh
UPSTREAM_REPO and UPSTREAM_COMMIT can be overridden via environment variables.
MIT (LICENSE)
CommandLayer SDKs for TypeScript and Python to call ENS-addressed agent verbs and verify signed receipts against canonical schemas, IPFS mirrors, and release checksums.
Developer integration tools for adding TDM payments to AI agents, apps, and workflows. CLI, MCP server, and copy-paste examples
Open contract-facing SDK for payable routes and gateway-backed integrations. Thin public surface for authorize, checkout, and session flows.
Developer integration tools for adding TDM payments to AI agents, apps, and workflows. CLI, MCP server, and copy-paste examples
the onramp for pay-as-you-go decentralized storage on IPFS — SOL, USDFC, USDC, and x402 agent payments
Drop-in OpenAI Python client with transparent x402 payment support.
A payments protocol for the internet. Built on HTTP.
Self-healing infrastructure for AI agent payments. 90.3% auto-recovery.
Daydreams is a set of tools for building agents for commerce
The best way to monetize AI applications & MCP, using x402, CDP Smart Wallets & Paymaster
URL shortener
AWS payment demo of x402 using Bedrock AgentCore, Strands SDK, and CloudFront.