### SDK Installation and Setup Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Provides the command-line instructions for cloning the repository, installing required dependencies, and importing the SDK into a project. ```bash git clone https://github.com/ChaosChain/chaoschain-genesis-studio.git pip install -r requirements.txt ``` ```python from agents.chaoschain_agent_sdk import create_server_agent, create_client_agent ``` -------------------------------- ### Setup and Initialize ChaosChain Genesis Studio Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Instructions for cloning the repository, installing the ChaosChain SDK and dependencies, and executing the demo script to verify the development environment. ```bash # Fork and clone the repository git clone https://github.com/your-username/chaoschain-genesis-studio.git cd chaoschain-genesis-studio # Install the ChaosChain SDK pip install chaoschain-sdk # Install development dependencies (if any) pip install -r requirements-dev.txt # Run the demo to test your setup python genesis_studio.py ``` -------------------------------- ### Installing and Running Genesis Studio Demos Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Provides CLI commands to install the ChaosChain SDK and run demonstration scripts. Includes both the base installation for quick prototyping and the full stack installation with 0G and CrewAI dependencies. ```bash # Base Install pip install chaoschain-sdk git clone https://github.com/ChaosChain/chaoschain-genesis-studio.git cd chaoschain-genesis-studio python demo_base_install.py # Full Stack Install pip install chaoschain-sdk[0g] pip install crewai crewai-tools export NETWORK=0g-testnet export ZEROG_TESTNET_RPC_URL=https://rpc-testnet.0g.ai export ZEROG_TESTNET_PRIVATE_KEY=your_private_key python genesis_studio.py ``` -------------------------------- ### Set Up 0G gRPC Sidecar for Storage and Compute Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Guides through setting up the 0G gRPC sidecar, a crucial component for enabling decentralized storage and compute. This involves navigating to the sidecar directory, installing Node.js dependencies, configuring environment variables with 0G private keys and RPC URLs, and starting the gRPC server. ```bash cd sdk/sidecar-specs/typescript-server npm install cp .env.example .env # Edit .env with your 0G private key and RPC URLs: # ZEROG_PRIVATE_KEY=your_private_key # ZEROG_EVM_RPC=https://evmrpc-testnet.0g.ai # ZEROG_INDEXER_RPC=https://indexer-storage-testnet-turbo.0g.ai npm start ``` -------------------------------- ### Install ChaosChain SDK with 0G Provider Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Installs the ChaosChain SDK, including the '0g' extra which bundles '0g-storage' and '0g-compute' for decentralized storage and computation capabilities. ```bash pip install chaoschain-sdk[0g] ``` -------------------------------- ### Install ChaosChain SDK Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Commands to install the ChaosChain SDK via pip, supporting various configurations including base, 0G integration, or full provider support. ```bash # Basic installation (ERC-8004 + x402 + Local IPFS) pip install chaoschain-sdk # Or with 0G integration (Storage + Compute) pip install chaoschain-sdk[0g] # Or everything (all providers) pip install chaoschain-sdk[all] ``` -------------------------------- ### Install ChaosChain SDK Compute Providers Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Installs the ChaosChain SDK with support for different compute providers, including 0G Compute for TEE-verified AI. This enables verifiable computation for AI agents. ```bash pip install chaoschain-sdk[0g-compute] # 0G Compute (TEE-verified AI) pip install chaoschain-sdk[compute-all] # All compute providers ``` -------------------------------- ### Install and Run Demos Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Provides CLI commands to set up the environment for the base SDK demo and the advanced Genesis Studio demo with 0G network support. ```bash # Base Install pip install chaoschain-sdk python demo_base_install.py # Advanced 0G Install pip install chaoschain-sdk[0g] crewai crewai-tools python genesis_studio.py ``` -------------------------------- ### Install ChaosChain SDK Base Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Installs the core ChaosChain SDK, enabling features like ERC-8004, x402 payments, local IPFS storage, and process integrity. This is the recommended starting point for new users. ```bash pip install chaoschain-sdk git clone https://github.com/ChaosChain/chaoschain-genesis-studio.git cd chaoschain-genesis-studio python demo_base_install.py ``` -------------------------------- ### Install ChaosChain SDK with 0G Providers Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Installs the ChaosChain SDK with support for 0G providers, including storage, compute, and inference. This option is for advanced users exploring the full triple-verified stack and multi-agent systems. ```bash pip install chaoschain-sdk[0g] pip install crewai crewai-tools git clone https://github.com/ChaosChain/chaoschain-genesis-studio.git cd chaoschain-genesis-studio # Set up 0G credentials in .env # ZEROG_TESTNET_RPC_URL=https://rpc-testnet.0g.ai # ZEROG_TESTNET_PRIVATE_KEY=your_key python genesis_studio.py ``` -------------------------------- ### Install ChaosChain SDK Development Dependencies Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Installs the ChaosChain SDK along with development tools such as pytest, black, and mypy. This is useful for developers contributing to the project or running tests. ```bash pip install chaoschain-sdk[dev] ``` -------------------------------- ### Install ChaosChain SDK Storage Providers Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Installs the ChaosChain SDK with various optional storage provider integrations, such as 0G Storage, Pinata, and Irys. This allows for decentralized or cloud-based IPFS storage solutions. ```bash pip install chaoschain-sdk[0g-storage] # 0G Storage (decentralized) pip install chaoschain-sdk[pinata] # Pinata (cloud IPFS) pip install chaoschain-sdk[irys] # Irys (Arweave permanent) pip install chaoschain-sdk[storage-all] # All storage providers ``` -------------------------------- ### Clone Genesis Studio Repository Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Command to clone the ChaosChain Genesis Studio example repository to a local machine. ```bash git clone https://github.com/ChaosChain/chaoschain-genesis-studio.git cd chaoschain-genesis-studio ``` -------------------------------- ### Create Evidence Package for Audit Trails Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Initializes the ChaosChainAgentSDK as a server to create comprehensive evidence packages. This example sets up the SDK with process integrity enabled and defines sample work data, which would typically be part of a larger evidence package. ```python from datetime import datetime from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig from chaoschain_sdk.types import AgentRole, PaymentProof, PaymentMethod sdk = ChaosChainAgentSDK( agent_name="Alice", agent_domain="alice.example.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_process_integrity=True ) # Work proof data work_data = { "analysis_storage_uri": "ipfs://QmAnalysis123", "validation_score": 95, "analysis_confidence": 0.92, "triple_verified_stack": { "layer_1_ap2_intent": True, "layer_2_process_integrity": "proof_abc123", "layer_3_x402_settlement": True, "verification_layers_completed": 3 } } ``` -------------------------------- ### Install Optional Google AP2 Integration Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/requirements.txt Provides the command to manually install the Google AP2 integration from the source repository. This is an optional dependency for specific agentic commerce features. ```bash pip install git+https://github.com/google-agentic-commerce/AP2.git@main ``` -------------------------------- ### Test ChaosChain SDK with Python Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md This snippet demonstrates how to quickly test the ChaosChain Agent SDK by creating a client agent and printing its wallet address. It requires the 'chaoschain_sdk' library to be installed. ```bash # Quick SDK test python -c " from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig, AgentRole # Create a test agent agent = ChaosChainAgentSDK( agent_name='TestAgent', agent_domain='test.example.com', agent_role=AgentRole.CLIENT, network=NetworkConfig.BASE_SEPOLIA ) print(f'✅ SDK working! Agent wallet: {agent.wallet_address}') " ``` -------------------------------- ### Payment Method Discovery for Checkout (Python) Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md An example for payment gateways demonstrating how to discover available payment methods and structure them into checkout options. It maps generic method identifiers to user-friendly names and types, supporting dynamic checkout UI generation. ```python # Payment method discovery for checkout available_methods = agent.get_supported_payment_methods() checkout_options = [] for method in available_methods: if method == "basic-card": checkout_options.append({ "id": "cards", "name": "Credit/Debit Cards", "types": ["visa", "mastercard", "amex", "discover"] }) elif "google.com/pay" in method: checkout_options.append({ "id": "googlepay", "name": "Google Pay", "instant": True }) # ... handle other methods ``` -------------------------------- ### Set up Multi-Agent Workflow with Python Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md This Python code illustrates the setup of a multi-agent workflow by creating three distinct agents: Alice (Server), Bob (Validator), and Charlie (Client). Each agent is configured with specific roles and network settings, enabling them to interact within the ChaosChain ecosystem. ```python # Create three agents for a complete workflow alice = ChaosChainAgentSDK( agent_name="Alice", agent_domain="alice.myapp.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_process_integrity=True ) bob = ChaosChainAgentSDK( agent_name="Bob", agent_domain="bob.myapp.com", agent_role=AgentRole.VALIDATOR, network=NetworkConfig.BASE_SEPOLIA, enable_process_integrity=True ) charlie = ChaosChainAgentSDK( agent_name="Charlie", agent_domain="charlie.myapp.com", agent_role=AgentRole.CLIENT, network=NetworkConfig.BASE_SEPOLIA ) # Agents can now interact, make payments, and verify work ``` -------------------------------- ### Install Project Dependencies via pip Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/requirements.txt Lists the core requirements for the ChaosChain Genesis Studio. These packages enable SDK functionality and AI agent orchestration. ```text chaoschain-sdk>=0.1.2 crewai>=0.201.0 ``` -------------------------------- ### Get Supported Payment Methods Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Retrieves a list of all payment methods supported by the agent. This is useful for dynamically populating checkout options or validating payment method selections. The output is a list of strings representing the payment method identifiers. ```python # Get all supported payment methods payment_methods = agent.get_supported_payment_methods() print(f"Supported methods: {payment_methods}") ``` -------------------------------- ### Initialize and Operate GenesisServerAgentSDK Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Initializes a server agent with CrewAI integration for smart shopping analysis. It utilizes 0G Compute for TEE-verified AI inference and stores the resulting evidence on-chain. ```python alice = GenesisServerAgentSDK( agent_name="Alice", agent_domain="alice.chaoschain-studio.com", agent_role=AgentRole.SERVER, network=NetworkConfig.ZEROG_TESTNET, enable_ap2=True, enable_process_integrity=True, use_0g_inference=True ) agent_id = alice.register_identity() result = alice.generate_smart_shopping_analysis( item_type="winter_jacket", color="green", budget=150.0, premium_tolerance=0.20 ) cid = alice.store_analysis_evidence(result["analysis"], filename_prefix="shopping_analysis") ``` -------------------------------- ### Triple-Verified Stack SDK Workflow Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Demonstrates the initialization of client and server agents using the ChaosChain SDK and the execution of a complete Triple-Verified Stack workflow, including identity registration and service request processing. ```python from agents.chaoschain_agent_sdk import ChaosChainAgentSDK alice = ChaosChainAgentSDK(agent_name="Alice", agent_domain="alice.example.com", role="server", enable_ap2=True, enable_process_integrity=True) charlie = ChaosChainAgentSDK(agent_name="Charlie", agent_domain="charlie.example.com", role="client", enable_ap2=True) alice_id, tx_hash = alice.register_identity() charlie_id, tx_hash = charlie.register_identity() result = await alice.execute_triple_verified_stack_workflow( client_agent="Charlie", validator_agent="Bob", intent_description="Find me the best winter jacket in green", constraints={"price_limit": 150.0, "color_preference": "green"}, service_function="find_smart_shopping_deal", service_inputs={"item_type": "winter_jacket", "color": "green"}, base_payment=2.0 ) ``` -------------------------------- ### Create and Package Evidence with Triple-Verified Stack Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Demonstrates how to construct payment proofs and bundle them into an evidence package. It includes metadata for the Triple-Verified Stack to ensure process integrity and outcome adjudication. ```python payment_proofs = [ PaymentProof( payment_id="pay_001", from_agent="Charlie", to_agent="Alice", amount=10.0, currency="USDC", payment_method=PaymentMethod.A2A_X402, transaction_hash="0x123abc...", timestamp=datetime.now(), receipt_data={"service": "smart_shopping"} ) ] evidence_package = sdk.create_evidence_package( work_proof=work_data, payment_proofs=payment_proofs ) evidence_package.triple_verified_stack = { "intent_verification": "AP2", "process_integrity_verification": "ChaosChain", "outcome_adjudication": "ChaosChain", "chaoschain_layers_owned": 2, "total_verification_layers": 3 } ``` -------------------------------- ### Initialize ChaosChain Agent Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Demonstrates how to instantiate a ChaosChain agent with specific roles and network configurations, including optional Pinata storage integration. ```python from chaoschain_sdk import ChaosChainAgentSDK, AgentRole, NetworkConfig # With Pinata (enhanced features) agent_with_storage = ChaosChainAgentSDK( agent_name="StorageAgent", agent_domain="storage.myapp.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_process_integrity=True ) # Vendor-free mode (no external dependencies) agent_vendor_free = ChaosChainAgentSDK( agent_name="FreeAgent", agent_domain="free.myapp.com", agent_role=AgentRole.CLIENT, network=NetworkConfig.BASE_SEPOLIA ) ``` -------------------------------- ### Initialize ChaosChain Agent SDK with Multi-Payment Support (Python) Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md This Python code snippet demonstrates how to initialize the ChaosChain Agent SDK with multi-payment support enabled. The SDK allows agents to integrate with the Triple-Verified Stack and a multi-payment system, supporting 5 W3C-compliant payment methods. The `enable_ap2` parameter, when set to `True`, activates all payment methods. ```python from agents.chaoschain_agent_sdk import ChaosChainAgentSDK # Initialize SDK with multi-payment support agent = ChaosChainAgentSDK( agent_name="MyAgent", agent_domain="myagent.com", agent_role="server", network="base-sepolia", enable_ap2=True # Enables all payment methods ) ``` -------------------------------- ### Create a Server Agent with Python Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md This Python code demonstrates the creation of a server agent using the ChaosChain SDK. It configures the agent with a name, domain, role, network, and enables process integrity for verifiable execution. The agent's wallet address is then printed. ```python from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig, AgentRole # Create a server agent server = ChaosChainAgentSDK( agent_name="MyServerAgent", agent_domain="server.myapp.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_process_integrity=True # Enable verifiable execution ) print(f"Server agent created: {server.wallet_address}") ``` -------------------------------- ### Requesting Services and Retrieving Payment Summaries Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Demonstrates how to interact with agent services using the ChaosChain SDK. It covers requesting shopping and validation services with payment amounts and retrieving the aggregate payment history. ```python service_result = charlie.request_shopping_service( server_agent_domain="alice.chaoschain-studio.com", intent_data=intent_data, payment_amount=2.0 ) print(f"Payment TX: {service_result['payment_proof'].transaction_hash}") validation_result = charlie.request_validation_service( validator_agent_domain="bob.chaoschain-studio.com", analysis_cid="ipfs://QmAnalysis123", payment_amount=1.0 ) summary = charlie.get_payment_summary() print(f"Total payments: {summary['total_payments']}") print(f"Total spent: ${summary['total_amount']} USDC") ``` -------------------------------- ### Initialize ChaosChainAgentSDK Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Configures and initializes AI agents with specific roles, network settings, and verification features. It supports multiple network configurations including Base Sepolia and 0G Testnet. ```python from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig from chaoschain_sdk.types import AgentRole # Create a server agent with full capabilities server_agent = ChaosChainAgentSDK( agent_name="Alice", agent_domain="alice.example.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_process_integrity=True, # Enable cryptographic execution proofs enable_ap2=True # Enable Google AP2 intent verification ) print(f"Agent wallet: {server_agent.wallet_address}") print(f"Network: Base Sepolia (Chain ID: 84532)") # Create a client agent (typically doesn't need process integrity) client_agent = ChaosChainAgentSDK( agent_name="Charlie", agent_domain="charlie.example.com", agent_role=AgentRole.CLIENT, network=NetworkConfig.BASE_SEPOLIA, enable_ap2=True, enable_process_integrity=False ) # For 0G Testnet with native A0GI tokens zerog_agent = ChaosChainAgentSDK( agent_name="MyAgent", agent_domain="myagent.0g.ai", agent_role=AgentRole.SERVER, network=NetworkConfig.ZEROG_TESTNET, enable_process_integrity=True ) ``` -------------------------------- ### Configure Environment Variables for Production Payments (Bash) Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Provides bash commands to set essential environment variables for production payment processing. This includes API keys and secrets for traditional processors like Stripe and PayPal, merchant IDs for Google/Apple Pay, and RPC URLs for crypto networks. ```bash # For production payment processing, configure these environment variables: # Traditional Payment Processors export STRIPE_SECRET_KEY="sk_live_..." # For card processing export STRIPE_PUBLISHABLE_KEY="pk_live_..." # For frontend integration export PAYPAL_CLIENT_ID="your_paypal_client" # For PayPal integration export PAYPAL_CLIENT_SECRET="your_paypal_secret" # Google/Apple Pay (Production) export GOOGLE_PAY_MERCHANT_ID="your_merchant_id" export APPLE_PAY_MERCHANT_ID="merchant.your.app" # Crypto Networks export BASE_SEPOLIA_RPC_URL="https://sepolia.base.org/..." export ETHEREUM_RPC_URL="https://mainnet.infura.io/v3/... ``` -------------------------------- ### Initialize and Use 0G Compute for AI Inference Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Initializes a gRPC connection to 0G Compute, submits an AI inference task, monitors its status, and retrieves the result. It requires the 'ZeroGComputeGRPC' class and uses a predefined task structure. ```python from chaoschain_sdk.providers.compute import ZeroGComputeGRPC, VerificationMethod import time # Initialize 0G Compute via gRPC sidecar zg_compute = ZeroGComputeGRPC(grpc_url="localhost:50051") if zg_compute.is_available: # Submit AI inference task task = { "agent_id": "Alice", "role": "server", "task_type": "smart_shopping_analysis", "model": "gpt-oss-120b", "prompt": """Analyze this shopping request:\n Item: winter jacket, Color: green, Budget: $150\n\n Provide recommendation in JSON format with:\n product_name, price, color, quality_score, confidence""", "max_tokens": 600, "temperature": 0.4 } job_id = zg_compute.submit( task=task, verification=VerificationMethod.TEE_ML, idempotency_key=f"shopping_{int(time.time())}" ) print(f"Job submitted: {job_id}") # Wait for completion for _ in range(30): status = zg_compute.status(job_id) if status.get("state") == "completed": break time.sleep(3) # Get result with TEE attestation result = zg_compute.result(job_id) if result.success: print(f"AI Output: {result.output}") print(f"Execution Hash: {result.execution_hash}") print(f"TEE Verified: {result.verification_method}") ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Commands to initialize and configure the environment file for the ChaosChain project, including network and RPC settings. ```bash # Create environment file (optional - works without it) cp .env.example .env # Edit .env to add your configuration: NETWORK=base-sepolia BASE_SEPOLIA_RPC_URL=https://base-sepolia.g.alchemy.com/v2/your-key ``` -------------------------------- ### Initialize and Operate GenesisClientAgent Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Configures a client agent to manage shopping intents and carts. This agent acts as the service consumer within the ChaosChain ecosystem. ```python charlie = GenesisClientAgent( agent_name="Charlie", agent_domain="charlie.chaoschain-studio.com", agent_role=AgentRole.CLIENT, network=NetworkConfig.ZEROG_TESTNET, enable_ap2=True, enable_process_integrity=False ) agent_id = charlie.register_identity() intent_data = charlie.create_shopping_intent( item_type="winter_jacket", color="green", budget=150.0, premium_tolerance=0.20 ) cart_data = charlie.create_shopping_cart( intent_data=intent_data, estimated_price=2.0 ) ``` -------------------------------- ### Configure Blockchain Network Connection Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Sets up the necessary environment variables for connecting to a specific blockchain network, such as Base Sepolia. Requires specifying the network name and the RPC URL for the chosen network. ```bash # Blockchain connectivity NETWORK=base-sepolia BASE_SEPOLIA_RPC_URL=https://base-sepolia.g.alchemy.com/v2/your-key ``` -------------------------------- ### Execute Traditional Payments (Python) Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Demonstrates how to execute traditional payment methods such as credit cards, Google Pay, and Apple Pay using the agent. It requires specifying the payment method, amount, currency, and relevant payment data. The result includes the transaction status and ID. ```python # Process a credit card payment card_result = agent.execute_traditional_payment( payment_method="basic-card", amount=10.0, currency="USD", payment_data={ "cardType": "visa", "cardNumber": "4111111111111111", "expiryMonth": "12", "expiryYear": "2025", "cardSecurityCode": "123" } ) print(f"Card payment: {card_result.status} - {card_result.transaction_id}") # Process a Google Pay payment gpay_result = agent.execute_traditional_payment( payment_method="https://google.com/pay", amount=10.0, currency="USD", payment_data={ "googleTransactionId": "gpay_transaction_123", "paymentMethodType": "CARD" } ) print(f"Google Pay: {gpay_result.status} - {gpay_result.transaction_id}") # Process an Apple Pay payment apay_result = agent.execute_traditional_payment( payment_method="https://apple.com/apple-pay", amount=10.0, currency="USD", payment_data={ "transactionIdentifier": "apay_transaction_123", "paymentMethod": {"type": "credit"} } ) print(f"Apple Pay: {apay_result.status} - {apay_result.transaction_id}") ``` -------------------------------- ### Retrieve Supported Payment Methods Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Fetches a list of payment gateways and methods supported by the ChaosChain client. Returns a list of strings representing provider identifiers or URLs. ```python methods = client.get_supported_payment_methods() ``` -------------------------------- ### Initialize and Operate GenesisValidatorAgentSDK Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Sets up a validator agent to perform quality assessments on analysis data. It uses CrewAI for validation and submits the final proof on-chain using a SHA256 hash. ```python bob = GenesisValidatorAgentSDK( agent_name="Bob", agent_domain="bob.chaoschain-studio.com", agent_role=AgentRole.VALIDATOR, network=NetworkConfig.ZEROG_TESTNET, enable_ap2=True, enable_process_integrity=True, use_0g_inference=True ) validation_result = bob.validate_analysis_with_crewai(analysis_data) cid = bob.store_validation_evidence(validation_result["validation"], filename_prefix="validation") import hashlib data_hash = "0x" + hashlib.sha256(cid.encode()).hexdigest() tx_hash = bob.submit_validation_response(data_hash, validation_result["validation"]["overall_score"], cid) ``` -------------------------------- ### Store Data on 0G Storage Network Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Initializes a gRPC connection to 0G Storage and stores provided evidence data. It returns a success status, root hash, transaction hash, and a URI for the stored data. Requires the 'ZeroGStorageGRPC' class. ```python from chaoschain_sdk.providers.storage import ZeroGStorageGRPC import time # Initialize 0G Storage via gRPC sidecar zg_storage = ZeroGStorageGRPC(grpc_url="localhost:50051") if zg_storage.is_available: # Store evidence on 0G Storage evidence = { "type": "genesis_studio_evidence", "agent": "Alice", "service": "smart_shopping_analysis", "timestamp": "2024-01-15T10:30:00Z", "analysis": {"product": "Winter Jacket", "price": 127.50} } result = zg_storage.put( blob=str(evidence).encode(), mime="application/json", idempotency_key=f"evidence_{int(time.time())}" ) if result.success: print(f"Stored on 0G Storage!") print(f"Root Hash: {result.metadata.get('root_hash')}") print(f"TX Hash: {result.metadata.get('tx_hash')}") print(f"URI: {result.uri}") ``` -------------------------------- ### Select Optimal Payment Method Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Determines the best payment gateway based on user preferences, currency, and availability. It prioritizes low-fee crypto options and mobile-friendly gateways before falling back to default methods. ```python def select_optimal_payment_method(user_preference, amount, currency): available_methods = agent.get_supported_payment_methods() # Priority order based on fees and speed if user_preference == "crypto" and "https://chaoschain.com/crypto-pay" in available_methods: return "https://chaoschain.com/crypto-pay" # Lowest fees elif user_preference == "instant" and "https://google.com/pay" in available_methods: return "https://google.com/pay" # Fastest for mobile elif currency == "USD" and "basic-card" in available_methods: return "basic-card" # Most universal else: return available_methods[0] # Fallback to first available ``` -------------------------------- ### Run Genesis Studio Python Script Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Executes the main Genesis Studio Python script. This script automatically detects and utilizes the running 0G sidecar for storage and compute. If the sidecar is unavailable, it gracefully falls back to using IPFS/Pinata and local execution. ```bash cd ../../../ python3 genesis_studio.py ``` -------------------------------- ### Execute Payments via x402 Protocol Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Facilitates agent-to-agent financial transactions using the x402 protocol. The SDK handles payment requests, fee collection, and transaction execution across supported networks. ```python from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig from chaoschain_sdk.types import AgentRole # Initialize client agent for making payments client = ChaosChainAgentSDK( agent_name="Charlie", agent_domain="charlie.example.com", agent_role=AgentRole.CLIENT, network=NetworkConfig.BASE_SEPOLIA ) # Create x402 payment request payment_request = client.create_x402_payment_request( cart_id="service_001", total_amount=10.0, currency="USDC", items=[{"name": "AI Analysis Service", "price": 10.0}], settlement_address="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7" ) # Execute payment to another agent payment_result = client.execute_payment( to_agent="Alice", amount=0.00005, # Amount in USDC or A0GI depending on network service_type="smart_shopping" ) print(f"Payment successful!") print(f"Transaction hash: {payment_result.transaction_hash}") print(f"Amount: {payment_result.amount} {payment_result.currency}") print(f"Payment ID: {payment_result.payment_id}") ``` -------------------------------- ### Configure Pinata IPFS Storage Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Enables enhanced IPFS storage using Pinata by providing the necessary JWT token and gateway URL. These credentials allow Genesis Studio to interact with Pinata's IPFS services for decentralized storage. ```bash # Enhanced IPFS storage PINATA_JWT=your-pinata-jwt PINATA_GATEWAY=https://gateway.pinata.cloud ``` -------------------------------- ### Manage Evidence Storage with IPFS and 0G Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Utilizes the Storage Manager to persist evidence data to decentralized storage providers like IPFS. It supports both raw byte storage and helper methods for structured evidence logging. ```python import json from datetime import datetime from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig sdk = ChaosChainAgentSDK(agent_name="Alice", agent_domain="alice.example.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA) evidence_data = {"message": "Smart shopping analysis completed", "timestamp": datetime.now().isoformat()} result = sdk.storage_manager.put(json.dumps(evidence_data).encode()) if result.success: retrieved = sdk.storage_manager.get(result.uri) cid = sdk.store_evidence(evidence_data, filename_prefix="analysis") ``` -------------------------------- ### Create x402 Payment Request with Python Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md This Python snippet shows how a client agent can create an x402 payment request. It specifies the cart ID, total amount, currency, item details, and the settlement address of the server. This is part of the crypto payment functionality within the ChaosChain SDK. ```python # Client creates payment request payment_request = client.create_x402_payment_request( cart_id="service_001", total_amount=10.0, currency="USDC", items=[{"name": "AI Analysis Service", "price": 10.0}], settlement_address=server.wallet_address ) print(f"Payment request created: {payment_request['cart_id']}") ``` -------------------------------- ### Retrieve Agent Wallet Addresses Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md A utility script to programmatically generate and print the wallet addresses for a list of agents to facilitate funding on testnets. ```python from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig, AgentRole agents = ['Alice', 'Bob', 'Charlie'] for name in agents: agent = ChaosChainAgentSDK(name, f'{name.lower()}.test.com', AgentRole.CLIENT, NetworkConfig.BASE_SEPOLIA) print(f'{name}: {agent.wallet_address}') ``` -------------------------------- ### Create ERC-8004 Feedback with Payment Proof Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Generates ERC-8004 v1.0 compliant feedback, including a payment proof for on-chain reputation. It requires setting up the ChaosChainAgentSDK, executing a payment, generating feedback authorization, and then creating and submitting the feedback. ```python import time from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig from chaoschain_sdk.types import AgentRole, PaymentProof sdk = ChaosChainAgentSDK( agent_name="Charlie", agent_domain="charlie.example.com", agent_role=AgentRole.CLIENT, network=NetworkConfig.BASE_SEPOLIA, enable_ap2=True ) # Execute payment first payment_proof = sdk.x402_manager.execute_agent_payment( from_agent="Charlie", to_agent="Alice", amount_usdc=10.0, service_description="Smart shopping analysis" ) # Generate feedback authorization server_agent_id = 1 # Alice's agent ID feedback_auth = sdk.chaos_agent.generate_feedback_authorization( agent_id=server_agent_id, client_address=sdk.wallet_address, index_limit=1, expiry=int(time.time()) + 3600 ) # Create feedback with payment proof (ERC-8004 v1.0 compliant) uri, hash_value = sdk.chaos_agent.create_feedback_with_payment( agent_id=server_agent_id, score=95, feedback_auth=feedback_auth, payment_proof=payment_proof, skill="smart-shopping", task="winter-jacket-search", tag1="quality", tag2="speed" ) # Submit feedback to on-chain reputation registry tx_hash = sdk.chaos_agent.give_feedback( agent_id=server_agent_id, score=95, feedback_auth=feedback_auth, file_uri=uri, file_hash=hash_value ) print(f"Feedback submitted: {tx_hash}") ``` -------------------------------- ### Configure Agent Process Integrity and AP2 Integration Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Enables or disables specific agent capabilities. 'ENABLE_PROCESS_INTEGRITY' ensures verifiable execution with cryptographic proofs, while 'ENABLE_AP2' controls the optional integration with Google AP2. ```bash # Agent configuration ENABLE_PROCESS_INTEGRITY=true ENABLE_AP2=false # Optional Google AP2 integration ``` -------------------------------- ### Execute Crypto Payment (A2A-x402) (Python) Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Handles cryptocurrency payments using the A2A-x402 protocol. This involves creating a payment request with cart details and then executing the payment with payer information. The output includes the transaction status and hash. ```python # Create crypto payment request payment_request = agent.create_x402_payment_request( cart_id="cart_123", total_amount=5.0, currency="USDC", items=[{"name": "AI Service", "price": 5.0}], settlement_address="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7" ) # Execute crypto payment crypto_result = agent.execute_x402_crypto_payment( payment_request=payment_request, payer_agent="PayerAgent", service_description="AI Analysis Service" ) print(f"Crypto payment: {crypto_result.status} - {crypto_result.transaction_hash}") ``` -------------------------------- ### Create AP2 Intent and Cart Mandates Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Initializes a ChaosChain agent with AP2 support to create intent and cart mandates for secure transactions. It includes RSA256 JWT signing and verification for Google AP2 compliance. ```python from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig from chaoschain_sdk.types import AgentRole sdk = ChaosChainAgentSDK( agent_name="Alice", agent_domain="alice.chaoschain-studio.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_ap2=True ) intent_mandate = sdk.create_intent_mandate( user_description="Find me the best winter jacket in green, willing to pay up to 20% premium", merchants=None, skus=None, requires_refundability=True, expiry_minutes=60 ) cart_mandate = sdk.create_cart_mandate( cart_id="cart_winter_jacket_001", items=[{"service": "smart_shopping_agent", "description": "Find best winter jacket deal with color preference", "price": 2.0}], total_amount=2.0, currency="USDC", merchant_name="Alice Smart Shopping Agent", expiry_minutes=15 ) if hasattr(cart_mandate, 'merchant_authorization'): jwt_payload = sdk.google_ap2_integration.verify_jwt_token(cart_mandate.merchant_authorization) print(f"JWT verified: {bool(jwt_payload)}") ``` -------------------------------- ### Implement Process Integrity Verification Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Registers functions to generate cryptographic execution proofs, ensuring that logic is executed as intended. This provides verifiable proof of computation for sensitive agent operations. ```python import asyncio from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig from chaoschain_sdk.types import AgentRole sdk = ChaosChainAgentSDK( agent_name="Alice", agent_domain="alice.example.com", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_process_integrity=True ) def analyze_shopping_request(item_type: str, budget: float, color: str) -> dict: return {"item_type": item_type, "recommended_price": budget * 0.85, "color_match": color, "confidence": 0.92} code_hash = sdk.register_integrity_checked_function(analyze_shopping_request, "analyze_shopping_request") result, integrity_proof = asyncio.run(sdk.execute_with_integrity_proof( "analyze_shopping_request", {"item_type": "winter_jacket", "budget": 150.0, "color": "green"} )) ``` -------------------------------- ### Configure Custom Treasury Address Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Allows specifying a custom treasury address for fee collection. If not set, the system will use a default treasury address. This is part of the payment layer configuration. ```bash # Custom treasury (uses default if not set) TREASURY_ADDRESS=0x20E7B2A2c8969725b88Dd3EF3a11Bc3353C83F70 ``` -------------------------------- ### Robust Payment Processing with Fallback Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md Executes payment transactions with error handling and automatic fallback mechanisms. If a primary payment method fails, the function recursively attempts to process the transaction using alternative supported methods. ```python def robust_payment_processing(payment_method, amount, currency, payment_data): try: if payment_method == "https://chaoschain.com/crypto-pay": result = agent.execute_x402_crypto_payment(...) else: result = agent.execute_traditional_payment( payment_method, amount, currency, payment_data ) if result.status == "completed": return {"success": True, "transaction_id": result.transaction_id} else: return {"success": False, "error": "Payment processing failed"} except Exception as e: fallback_methods = [m for m in agent.get_supported_payment_methods() if m != payment_method] if fallback_methods: return robust_payment_processing(fallback_methods[0], amount, currency, payment_data) else: return {"success": False, "error": str(e)} ``` -------------------------------- ### Universal Payment Processor Function (Python) Source: https://github.com/chaoschain/chaoschain-genesis-studio/blob/main/README.md A Python function designed for e-commerce platforms to process various payment methods. It intelligently routes payments to either the crypto payment handler or the traditional payment handler based on the provided payment method. ```python # Universal payment processor - handles any payment method def process_customer_payment(payment_method, amount, currency, payment_data): if payment_method == "https://chaoschain.com/crypto-pay": # Handle crypto payments via A2A-x402 return agent.execute_x402_crypto_payment(...) else: # Handle traditional payments (cards, wallets) return agent.execute_traditional_payment( payment_method, amount, currency, payment_data ) ``` -------------------------------- ### Register Agent Identity via ERC-8004 Source: https://context7.com/chaoschain/chaoschain-genesis-studio/llms.txt Registers an agent on the blockchain using the ERC-8004 standard to mint an identity NFT. This enables reputation tracking and allows for the storage and retrieval of on-chain metadata. ```python from chaoschain_sdk import ChaosChainAgentSDK, NetworkConfig from chaoschain_sdk.types import AgentRole sdk = ChaosChainAgentSDK( agent_name="DemoAgent", agent_domain="demo.chaoschain.io", agent_role=AgentRole.SERVER, network=NetworkConfig.BASE_SEPOLIA, enable_ap2=False ) # Register agent with on-chain metadata (ERC-8004 v1.0) metadata = { "agentName": sdk.agent_name.encode('utf-8'), "agentDomain": sdk.agent_domain.encode('utf-8') } agent_id, tx_hash = sdk.chaos_agent.register_agent( token_uri="ipfs://QmYourMetadataHash", metadata=metadata ) print(f"Agent registered with ID: {agent_id}") print(f"Transaction: {tx_hash}") # Set additional metadata after registration sdk.chaos_agent.set_agent_metadata("version", b"1.0.0") # Read metadata back (free operation) name = sdk.chaos_agent.get_agent_metadata("agentName") print(f"Agent name: {name.decode('utf-8')}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.