Skip to main content

Python SDK for TBUSD gasless transfers

Project description

TBUSD Python SDK

Gasless TBUSD transfers on Base L2. No ETH required.

Installation

pip install tbusd

Quick Start

from tbusd import Client

# Initialize with your API key and wallet
client = Client(
    api_key="tbusd_your_api_key",      # Get one at https://tbusd.io/developers
    private_key="0x..."                 # Your wallet's private key
)

# Send TBUSD - no gas needed!
tx = client.transfer(to="0xRecipient...", amount=10.0)
print(f"Sent! TX: {tx['txHash']}")

# Check balance
balance = client.balance()
print(f"Balance: {balance} TBUSD")

# Check API usage
usage = client.usage()
print(f"Today: {usage['today']['used']}/{usage['today']['limit']} transactions")

Features

  • Gasless transfers - We pay the gas, you just need TBUSD
  • Simple API - No Web3 complexity, just transfer(to, amount)
  • EIP-712 signing - Secure, standard meta-transactions
  • Rate limited - 20 transactions/day per API key

API Reference

Client(api_key, private_key, rpc_url=None)

Create a new TBUSD client.

Parameter Type Description
api_key str Your TBUSD API key
private_key str Your wallet's private key (0x...)
rpc_url str Optional custom RPC URL (defaults to Base public RPC)

client.transfer(to, amount) -> dict

Send TBUSD to an address.

Parameter Type Description
to str Recipient address (0x...)
amount float Amount of TBUSD to send

Returns: {"success": True, "txHash": "0x...", "gasUsed": "85000"}

client.balance(address=None) -> float

Get TBUSD balance. Defaults to your wallet if no address provided.

client.usage() -> dict

Check your API usage and remaining daily limit.

Returns:

{
    "email": "you@example.com",
    "total_transactions": 142,
    "today": {
        "used": 5,
        "remaining": 15,
        "limit": 20
    }
}

client.health() -> bool

Check if the relayer service is operational.

Exceptions

from tbusd import TBUSDError, RateLimitError, InsufficientBalanceError

try:
    tx = client.transfer(to="0x...", amount=100)
except RateLimitError:
    print("Daily limit reached, try again tomorrow")
except InsufficientBalanceError:
    print("Not enough TBUSD in wallet")
except TBUSDError as e:
    print(f"Error: {e}")

Example: AI Agent Wallet

import os
from tbusd import Client

# Agent's petty cash wallet
agent = Client(
    api_key=os.environ["TBUSD_API_KEY"],
    private_key=os.environ["AGENT_PRIVATE_KEY"]
)

def pay_for_service(service_address: str, amount: float) -> str:
    """Pay for an API call or service"""
    tx = agent.transfer(to=service_address, amount=amount)
    return tx["txHash"]

# Pay 5 cents for a search query
tx_hash = pay_for_service("0xSearchProvider...", 0.05)

Rate Limits

Limit Value
Transactions per day 20
Minimum transfer $1 TBUSD
Reset time Midnight UTC

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tbusd-0.1.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tbusd-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file tbusd-0.1.1.tar.gz.

File metadata

  • Download URL: tbusd-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for tbusd-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e9d8362ea1f181a8ed26324e30b3f8ca4152678540211608d5820c33412f68e8
MD5 094baedf0299155cd333b53c901db591
BLAKE2b-256 3201a4175df4507dcea8f67b0bbb0568e7a6fcee2948f0beaabcd7c513d11d79

See more details on using hashes here.

File details

Details for the file tbusd-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tbusd-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for tbusd-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1dcc0b2dc8a8dc17940cba3f2ef376a10303b5a9f4fc1946fd5ca3b5a050476d
MD5 75b8b54c3ac477898f8f2119843ce7b3
BLAKE2b-256 2750659e2f7794d2261fecd11b6dc86ff3152ca5c0bbb0f1b6692376e97a6034

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page