sign_and_send()

Use agent.sign_and_send() to sign and broadcast blockchain transactions from your agent's wallet. Supports both Ethereum (EVM) and Solana networks. The transaction is signed by the agent's session wallet, broadcast to the network, and returns a transaction hash for tracking. Include an optional message parameter to help with debugging and observability in the Circuit UI.

Signature

agent.sign_and_send(
    request: {
        network: str,
        message: str | None,
        request: dict  # Structure varies based on EVM or Solana
    }
) -> SignAndSendResponse

Parameters

Param
Type
Description

request

dict

Transaction configuration object

request.network

str

Network type: 'ethereum:{chainId}' | 'solana'

request.message

str | None

Optional description for observability

request.request

dict

Transaction details (see below)

Ethereum Transactions

When request.network is 'ethereum:{chainId}'

( request.request )

Property
Type
Description

to_address

str

Recipient address

data

str

Transaction calldata (use "0x" for simple transfers)

value

str

ETH amount in wei (use "0" for no ETH)

gas

int | None

Gas limit for the transaction

max_fee_per_gas

str | None

Maximum fee per gas in wei

max_priority_fee_per_gas

str | None

Maximum priority fee per gas in wei (tip)

nonce

int | None

Transaction nonce (for custom ordering)

enforce_transaction_success

bool | None

Ignore failed transaction simulations

Solana Transactions

When request.network is 'solana'

( request.request )

Param
Type
Description

hexTransaction

str

Serialized transaction in hex format

Returns

  • SignAndSendResponse

class SignAndSendResponse:
    success: bool
    data: { # Only present on success
        internal_transaction_id: int,
        tx_hash: str,
        transaction_url: str | None
    } | None
    error: str | None
    error_message: str | None
    error_details: dict | None

Examples

EVM (native ETH transfer)

response = agent.sign_and_send({
    "network": "ethereum:1",
    "request": {
        "to_address": "0x742d35cc6634C0532925a3b8D65e95f32B6b5582",
        "data": "0x",
        "value": "1000000000000000000"  # 1 ETH in wei
    },
    "message": "Sending 1 ETH"
})

if response.success and response.data:
    agent.log(f"Sent! TX: {response.data.tx_hash}")
    if response.data.transaction_url:
        agent.log(f"View: {response.data.transaction_url}")
else:
    agent.log(f"Failed: {response.error_message}", error=True)

EVM (contract interaction)

response = agent.sign_and_send({
    "network": "ethereum:42161",  # Arbitrum
    "request": {
        "to_address": "0xTokenContract...",
        "data": "0xa9059cbb...",  # encoded transfer() call
        "value": "0"
    },
    "message": "Token transfer"
})

if response.success and response.data:
    agent.log(f"Contract call successful: {response.data.transaction_url}")

Solana

response = agent.sign_and_send({
    "network": "solana",
    "request": {
        "hex_transaction": "010001030a0b..."  # serialized VersionedTransaction
    },
    "message": "Solana swap"
})

if response.success and response.data:
    agent.log(f"Solana TX: {response.data.tx_hash}")

Common Errors

Error
Cause
Solution

"Transaction failed"

Insufficient balance for value or gas

Check currentPositions before sending

"Invalid address"

Malformed to_address

Validate address format (0x... for EVM)

"Invalid data"

Malformed calldata

Ensure data is valid hex (use "0x" for simple transfers)

"Network error"

RPC unavailable

Retry or check network status

Last updated