Skip to main content

Radius AI Agent SDK Web3 wallet implementation

Project description

Radius AI Agent SDK - Web3 Wallet

The Radius Web3 Wallet package provides a simple, unified interface for interacting with Radius from AI agents using Web3.py. It offers a Python implementation of wallet operations that integrate seamlessly with AI agent frameworks.

This package is part of the Radius AI Agent Toolkit, which provides tools for integrating AI agents with the Radius platform.

Installation

pip install radius-ai-agent-sdk-wallet-web3

Prerequisites

  • Python >=3.10
  • Access to a Radius RPC endpoint
  • A funded private key for the Radius network
  • web3 >=6.20.3
  • radius-ai-agent-sdk >=0.1.0
  • radius-ai-agent-sdk-wallet-evm >=0.1.0

Usage

from web3 import Web3
from radius_wallets.web3 import web3
from radius_wallets.evm import send_eth

# Create a Web3 instance
w3 = Web3(Web3.HTTPProvider(RPC_PROVIDER_URL))
w3.eth.default_account = w3.eth.account.from_key(WALLET_PRIVATE_KEY).address
w3.eth.default_local_account = w3.eth.account.from_key(WALLET_PRIVATE_KEY)

# Create a Radius wallet
wallet = web3(w3)

# Get wallet address
address = wallet.get_address()
print(f"Wallet address: {address}")

# Check wallet balance
balance = wallet.balance_of(address)
print(f"Balance: {balance['value']} {balance['symbol']}")

# Create sendETH function
send_eth_tool = send_eth.send_eth()

# Use the send_eth tool
transaction = await send_eth_tool(
    wallet=wallet,
    to="0xRecipientAddress",
    amount="0.01",
    wait_for_receipt=True
)

API Reference

web3(client, options=None)

Creates a new Web3EVMWalletClient instance.

Parameters:

  • client (Web3): Configured Web3.py client instance
  • options (Web3Options, optional): Configuration options

Returns:

  • A Web3EVMWalletClient instance that can be used with AI agent tools

send_eth.send_eth()

Creates a function that enables ETH transfer functionality for AI agents.

Returns:

  • A tool function that can be used to send ETH

Wallet Methods

wallet.get_address()

Returns the wallet's address.

wallet.balance_of(address)

Returns the balance info for the specified address, including value, symbol, and other details.

wallet.send_transaction(transaction)

Sends a transaction to the network.

Parameters:

  • transaction (EVMTransaction): Transaction parameters including to, value, and optional contract interaction details

wallet.read(request)

Reads data from a smart contract without modifying state.

Parameters:

  • request (EVMReadRequest): Request parameters including address, functionName, abi, and optional args

wallet.sign_message(message)

Signs a given message using the wallet's private key.

wallet.sign_typed_data(data)

Signs EIP-712 typed data.

Advanced Usage

Smart Contract Interactions

# Read from a contract
result = wallet.read({
    "address": "0xContractAddress",
    "functionName": "balanceOf",
    "args": ["0xUserAddress"],
    "abi": [...] # Contract ABI
})

# Write to a contract
tx = wallet.send_transaction({
    "to": "0xContractAddress",
    "functionName": "transfer",
    "args": ["0xRecipient", 1000000000000000000],  # 1 ETH in wei
    "abi": [...] # Contract ABI
})

ENS Resolution

# Resolve ENS name to address
address = wallet.resolve_address("vitalik.eth")
print(f"Resolved address: {address}")

Integration Examples

For a complete example integrating this package with AI frameworks, see:

Development Setup

1. Clone the Repository

git clone git@github.com:radiustechsystems/ai-agent-toolkit.git
cd ai-agent-toolkit/python/src/wallets/web3

2. Install Development Dependencies

pip install -e ".[dev]"

3. Run Tests

pytest

Related Packages

Resources

Contributing

Please see the Contributing Guide for detailed information about contributing to this toolkit.

License

This project is licensed under the MIT License

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

radius_ai_agent_sdk_wallet_web3-1.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file radius_ai_agent_sdk_wallet_web3-1.0.0.tar.gz.

File metadata

File hashes

Hashes for radius_ai_agent_sdk_wallet_web3-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7c46a1e9cfd070bcca3fbd1e730b538c3f7e8ecd4d0ca594ea48506e4af9c442
MD5 d309b1a965662944cc348d0f164d6def
BLAKE2b-256 b05a89bb150ef9207f1958e235b8a37a4c7607f3a06d6efd8bafcb775371efb1

See more details on using hashes here.

File details

Details for the file radius_ai_agent_sdk_wallet_web3-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for radius_ai_agent_sdk_wallet_web3-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74d27e42ad84191c542ca9334f43c0341fb270d9bda4cdb12c18e0a8df56074c
MD5 31b768e2070b29432fdd6fe4cfc593dd
BLAKE2b-256 a466fa1b7b5e0f055e0608a35d046a83d5c993e7280979a7511efd5e8fd60354

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