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 instanceoptions(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 includingto,value, and optional contract interaction details
wallet.read(request)
Reads data from a smart contract without modifying state.
Parameters:
request(EVMReadRequest): Request parameters includingaddress,functionName,abi, and optionalargs
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
- radius-ai-agent-sdk: Core abstractions and base classes
- radius-ai-agent-sdk-wallet-evm: EVM wallet base implementation
- radius-ai-agent-sdk-plugin-erc20: ERC20 token operations
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file radius_ai_agent_sdk_wallet_web3-1.0.0.tar.gz.
File metadata
- Download URL: radius_ai_agent_sdk_wallet_web3-1.0.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c46a1e9cfd070bcca3fbd1e730b538c3f7e8ecd4d0ca594ea48506e4af9c442
|
|
| MD5 |
d309b1a965662944cc348d0f164d6def
|
|
| BLAKE2b-256 |
b05a89bb150ef9207f1958e235b8a37a4c7607f3a06d6efd8bafcb775371efb1
|
File details
Details for the file radius_ai_agent_sdk_wallet_web3-1.0.0-py3-none-any.whl.
File metadata
- Download URL: radius_ai_agent_sdk_wallet_web3-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74d27e42ad84191c542ca9334f43c0341fb270d9bda4cdb12c18e0a8df56074c
|
|
| MD5 |
31b768e2070b29432fdd6fe4cfc593dd
|
|
| BLAKE2b-256 |
a466fa1b7b5e0f055e0608a35d046a83d5c993e7280979a7511efd5e8fd60354
|