Skip to main content

Get Your First Agent Payment Running in 5 Minutes

This guide walks you through creating an AI agent, provisioning a wallet, and executing your first policy-enforced payment.
1

Get Your API Key

Sign up at sardis.sh and create an API key:
  1. Go to SettingsAPI Keys
  2. Click Create API Key
  3. Copy your key — it starts with sk_live_... (production) or sk_test_... (sandbox)
Keep your API key secret! Never commit it to version control. Use environment variables:
export SARDIS_API_KEY=sk_live_...
2

Install the SDK

pip install sardis
Requires Python 3.11+
3

Create an Agent and Wallet

from sardis import SardisClient
from decimal import Decimal

# Initialize the client
sardis = SardisClient(api_key="sk_live_...")

# Create an AI agent
agent = sardis.agents.create(
    name="my-first-agent",
    description="My first Sardis agent",
)

print(f"Agent created: {agent.agent_id}")

# Create a wallet with spending policies
wallet = sardis.wallets.create(
    agent_id=agent.agent_id,
    chain="base",
    currency="USDC",
    limit_per_tx=Decimal("100.00"),  # Max $100 per transaction
    limit_total=Decimal("500.00"),   # Max $500 total
)

print(f"Wallet created: {wallet.wallet_id}")
print(f"Wallet address: {wallet.address}")
The wallet is non-custodial — keys are managed by Turnkey MPC. You never see or handle private keys.
4

Fund Your Wallet

Before you can make payments, fund your wallet with USDC:
Sandbox wallets come pre-funded with test USDC. No action needed!
5

Execute Your First Payment

Now execute a payment with automatic policy validation:
from sardis import SardisClient
from decimal import Decimal

sardis = SardisClient(api_key="sk_live_...")

# Execute a payment
result = sardis.wallets.transfer(
    wallet.wallet_id,
    destination="merchant@example.com",  # Or wallet address
    amount=Decimal("25.00"),
    token="USDC",
    chain="base",
    domain="openai.com",  # Merchant domain for policy checks
    memo="OpenAI API credits",
)

print(f"Payment status: {result.status}")
print(f"Transaction hash: {result.tx_hash}")
print(f"Amount: {result.amount} {result.token}")
print(f"From: {result.from_address}")
print(f"To: {result.to_address}")
print(f"Chain: {result.chain}")
The payment is automatically validated against your wallet’s spending policies:
  • ✅ Amount (25)isunderpertransactionlimit(25) is under per-transaction limit (100)
  • ✅ Total spending is under daily limit ($500)
  • ✅ Merchant domain is not blocked
6

Verify the Transaction

Check the transaction in the Sardis dashboard or query the ledger:
# Get transaction details
transaction = sardis.transactions.get(result.tx_hash)

print(f"Status: {transaction.status}")
print(f"Confirmations: {transaction.confirmations}")
print(f"Block: {transaction.block_number}")
print(f"Gas used: {transaction.gas_used}")

# View in block explorer
print(f"Block explorer: https://basescan.org/tx/{result.tx_hash}")

Complete Working Example

Here’s a complete example from our examples directory:
#!/usr/bin/env python3
"""
Simple Payment Demo
===================

This example shows how to create a wallet and execute a payment
using the Sardis payment protocol.
"""

from sardis import Wallet, Transaction

def main():
    # Create a wallet with initial balance
    print("1. Creating wallet with $50 USDC...")
    wallet = Wallet(initial_balance=50, currency="USDC")
    print(f"   Wallet ID: {wallet.wallet_id}")
    print(f"   Balance: ${wallet.balance} {wallet.currency}")
    
    # Create and execute a transaction
    print("2. Executing payment of $2 to OpenAI API...")
    tx = Transaction(
        from_wallet=wallet,
        to="openai:api",
        amount=2,
        purpose="GPT-4 API call"
    )
    
    result = tx.execute()
    print(f"   Transaction ID: {result.tx_id}")
    print(f"   Status: {result.status.value}")
    print(f"   TX Hash: {result.tx_hash}")
    
    # Check new balance
    print("3. Checking wallet balance...")
    print(f"   New Balance: ${wallet.balance} {wallet.currency}")
    print(f"   Total Spent: ${wallet.spent_total}")
    
    print("✓ Demo completed successfully!")

if __name__ == "__main__":
    main()

What’s Next?

Framework Integrations

Use Sardis with LangChain, OpenAI, CrewAI, Vercel AI, and more

Spending Policies

Learn how to write natural language spending policies

Multi-Agent Teams

Create agent teams with shared budgets and group governance

API Reference

Explore the complete API documentation

Common Issues

Fund your wallet with USDC on the target chain (e.g., Base, Polygon). In sandbox mode, test wallets are pre-funded.
Check your wallet’s spending limits with sardis.wallets.get(wallet_id). The payment may exceed per-transaction or daily limits.
The merchant domain may be on your blocklist or flagged by compliance checks. Review your policy settings.
Blockchain transactions can take 1-5 minutes depending on network congestion. Check the block explorer for real-time status.
Need help? Join our Discord or email support@sardis.sh

Build docs developers (and LLMs) love