When using Privy’s server-side SDKs to sign transactions, you can use the authorization context to
automatically sign requests. Learn more about signing on the
server.
- React
- React Native
- Swift
- Android
- Unity
- Flutter
- NodeJS
- NodeJS (server-auth)
- REST API
- Python
- Java
- Rust
To send a transaction from a wallet using the React SDK, use the
sendTransaction method from the useSendTransaction hook:Report incorrect code
Copy
Ask AI
sendTransaction: (input: UnsignedTransactionRequest, options?: {
sponsor?: boolean;
uiOptions?: SendTransactionModalUIOptions;
fundWalletConfig?: FundWalletConfig;
address?: string;
}) => Promise<{ hash: HexString }>
Usage
Report incorrect code
Copy
Ask AI
import {useSendTransaction, useWallets} from '@privy-io/react-auth';
const {sendTransaction} = useSendTransaction();
const {wallets} = useWallets();
sendTransaction(
{
to: '0xE3070d3e4309afA3bC9a6b057685743CF42da77C',
value: 100000
},
{
address: wallets[0].address // Optional: Specify the wallet to use for signing. If not provided, the first wallet will be used.
}
);
Parameters
The details of the transaction to send on the chain.
Optional parameter to enable gas sponsorship for this transaction. Learn
more.
The options for the UI of the send transaction modal. Learn
more.
To hide confirmation modals, set
options.uiOptions.showWalletUIs to false. Learn more about
configuring modal prompts here.The configuration for funding the wallet.
The address of the wallet to use for sending the transaction. Recommended when working with
external wallets to ensure reliable functionality. If not provided, the first wallet will be
used.
Returns
The hash for the broadcasted transaction.
To send a transaction from a wallet using the React Native SDK use the
request method from the wallets EIP1193 provider:Report incorrect code
Copy
Ask AI
request: (request: { method: 'eth_sendTransaction', params: [SendTransactionParams] }) => Promise<HexString>
The Expo SDK does not support built-in UIs for sending transactions.
The
eth_sendTransaction method gives you complete control over the experience and UI.Usage
Report incorrect code
Copy
Ask AI
import {useEmbeddedEthereumWallet} from '@privy-io/expo';
const {wallets} = useEmbeddedEthereumWallet();
const wallet = wallets[0];
const provider = await wallet.getProvider();
const accounts = await provider.request({
method: 'eth_requestAccounts',
});
// Send transaction (will be signed and populated)
const response = await provider.request({
method: 'eth_sendTransaction',
params: [
{
from: accounts[0],
to: '0x0000000000000000000000000000000000000000',
value: '0x2386F26FC10000',
},
],
});
Parameters
The RPC method executed with the wallet.
The details of the transaction to send on the chain.
Returns
The hash for the broadcasted transaction.
Use the
request method on the Ethereum provider to send a transaction with an Ethereum wallet.Report incorrect code
Copy
Ask AI
func request(_ request: EthereumRpcRequest) async throws -> String
Usage
Report incorrect code
Copy
Ask AI
let provider = wallet.provider
let transaction = EthereumRpcRequest.UnsignedEthTransaction(
from: wallet.address,
to: "0xE3070d3e4309afA3bC9a6b057685743CF42da77C",
value: .int(10000),
chainId: .hexadecimal("0x2105") // Base, in hex
)
let transactionHash = try await provider.request(.ethSendTransaction(transaction: transaction)
Parameters
The transaction to send.
Hide child attributes
Hide child attributes
The address sending the transaction (the user’s wallet address).
The address to send the transaction to.
The amount of wei to send, as an integer or hexadecimal string.
The chain ID as an integer or hexadecimal string. Defaults to mainnet (0x1) if omitted.
The data to include with the transaction, as a hexadecimal string.
The gas limit for the transaction, as a hexadecimal string.
Returns
The hash of the broadcasted transaction.
Use the
request method on the Ethereum wallet provider to send a transaction with an Ethereum wallet.Report incorrect code
Copy
Ask AI
public suspend fun request(request: EthereumRpcRequest): Result<EthereumRpcResponse>
Usage
Report incorrect code
Copy
Ask AI
val transaction = JSONObject().apply {
put("to", "0xE3070d3e4309afA3bC9a6b057685743CF42da77C")
put("value", "0x186a0") // 100000 in hex
put("chainId", "0x2105") // 8453 (Base) in hex
put("from", ethereumWallet.address)
}.toString()
val result = ethereumWallet.provider.request(
request = EthereumRpcRequest.ethSendTransaction(transaction),
)
when (result) {
is Result.Success -> {
val transactionHash = result.data.data
// Handle successful transaction
}
is Result.Failure -> {
// Handle error
}
}
Parameters
The RPC method to execute with the wallet.
Array containing the transaction JSON as a single string element.
Hide child attributes
Hide child attributes
The address to send the transaction to.
The amount of wei to send, as a hexadecimal string.
The chain ID as a hexadecimal string. Defaults to mainnet (0x1) if omitted.
The address sending the transaction (the user’s wallet address).
The data to include with the transaction, as a hexadecimal string.
The gas limit for the transaction, as a hexadecimal string.
Returns
Use the
Request method on the wallet’s RPC provider to send a transaction with an Ethereum wallet.Report incorrect code
Copy
Ask AI
public Task<RpcResponse> Request(RpcRequest request);
Usage
Report incorrect code
Copy
Ask AI
// Create transaction JSON
string transactionJson = JsonUtility.ToJson(new {
to = "0xE3070d3e4309afA3bC9a6b057685743CF42da77C",
value = "0x186a0", // 100000 in hex
chainId = "0x2105", // 8453 (Base) in hex
from = embeddedWallet.Address
});
// Create RPC request
var rpcRequest = new RpcRequest
{
Method = "eth_sendTransaction",
Params = new string[] { transactionJson }
};
// Send transaction
RpcResponse transactionResponse = await embeddedWallet.RpcProvider.Request(rpcRequest);
// Transaction hash is in the response data
string transactionHash = transactionResponse.Data;
Parameters
The RPC method to execute with the wallet.
Array containing the transaction JSON as a single string element.
Hide child attributes
Hide child attributes
The address to send the transaction to.
The amount of wei to send, as a hexadecimal string.
The chain ID as a hexadecimal string. Defaults to mainnet (0x1) if omitted.
The address sending the transaction (the user’s wallet address).
The data to include with the transaction, as a hexadecimal string.
The gas limit for the transaction, as a hexadecimal string.
Returns
Use the
request method on the Ethereum wallet provider to send a transaction with an Ethereum wallet.Report incorrect code
Copy
Ask AI
Future<Result<EthereumRpcResponse>> request(EthereumRpcRequest request);
Usage
Report incorrect code
Copy
Ask AI
// Create transaction parameters as a Map
final transactionMap = {
'to': '0xE3070d3e4309afA3bC9a6b057685743CF42da77C',
'value': '0x186a0', // 100000 in hex
'chainId': '0x2105', // 8453 (Base) in hex
'from': ethereumWallet.address
};
// Convert Map to JSON string
final transactionJson = jsonEncode(transactionMap);
// Create the RPC request
final rpcRequest = EthereumRpcRequest(
method: 'eth_sendTransaction',
params: [transactionJson],
);
// Send the transaction
final result = await ethereumWallet.provider.request(rpcRequest);
// Handle the result
result.when(
success: (response) {
final transactionHash = response.data;
print('Transaction sent with hash: $transactionHash');
},
failure: (error) {
print('Failed to send transaction: $error');
},
);
Parameters
The RPC method to execute with the wallet.
List containing the transaction JSON as a single string element.
Hide child attributes
Hide child attributes
The address to send the transaction to.
The amount of wei to send, as a hexadecimal string.
The chain ID as a hexadecimal string. Defaults to mainnet (0x1) if omitted.
The address sending the transaction (the user’s wallet address).
The data to include with the transaction, as a hexadecimal string.
The gas limit for the transaction, as a hexadecimal string.
Returns
Use the
sendTransaction method on the Ethereum interface to send a transaction with an Ethereum wallet.Usage
Report incorrect code
Copy
Ask AI
const {hash, caip2} = await privy.wallets().ethereum().sendTransaction('insert-wallet-id', {
caip2: 'eip155:8453',
params: {
transaction: {
to: '0xE3070d3e4309afA3bC9a6b057685743CF42da77C',
value: '0x2386F26FC10000',
chain_id: 8453,
},
},
sponsor: true,
});
Parameters and Returns
Check out the API reference for more details.A successful response indicates that the transaction has been broadcasted to the network.
Transactions may get broadcasted but still fail to be confirmed by the network. To handle these
scenarios, see our guide on speeding up transactions.
The
@privy-io/server-auth library is deprecated. We recommend integrating @privy-io/node for
the latest features and support.Use the
sendTransaction method on the Ethereum client to send a transaction with an Ethereum wallet.Report incorrect code
Copy
Ask AI
sendTransaction: (input: EthereumSendTransactionInputType) => Promise<EthereumSendTransactionResponseType>
Usage
Report incorrect code
Copy
Ask AI
const {hash, caip2} = await privy.walletApi.ethereum.sendTransaction({
walletId: 'insert-wallet-id',
caip2: 'eip155:8453',
transaction: {
to: '0xE3070d3e4309afA3bC9a6b057685743CF42da77C',
value: '0x2386F26FC10000',
chainId: 8453,
},
sponsor: true,
});
Parameters
The ID of the wallet to send the transaction from.
The CAIP2 chain ID of the chain the transaction is being sent on.
The transaction to send.
Optional parameter to enable gas sponsorship for this transaction. Learn more.
Returns
The hash for the broadcasted transaction.
The CAIP2 chain ID of the chain the transaction was sent on.
A successful response indicates that the transaction has been broadcasted to the network.
Transactions may get broadcasted but still fail to be confirmed by the network. To handle these
scenarios, see our guide on speeding up transactions.
To send a transaction, make a A successful response will look like the following:
POST request toReport incorrect code
Copy
Ask AI
https://api.privy.io/v1/wallets/<wallet_id>/rpc
Wallets with
owner_id present must provide an authorization signature as a request header.If you are transacting with a user wallet, you must provide the user’s authorization signature.Usage
Report incorrect code
Copy
Ask AI
$ curl --request POST https://api.privy.io/v1/wallets/<wallet_id>/rpc \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>" \
-H "privy-authorization-signature: <authorization-signature-for-request>" \
-H 'Content-Type: application/json' \
-d '{
"method": "eth_sendTransaction",
"caip2": "eip155:1",
"params": {
"transaction": {
"to": "0xE3070d3e4309afA3bC9a6b057685743CF42da77C",
"value": "0x2386F26FC10000",
}
},
"sponsor": true
}'
Report incorrect code
Copy
Ask AI
{
"method": "eth_sendTransaction",
"data": {
"hash": "<transaction-hash>",
"caip2": "eip155:1"
}
}
Parameters
The RPC method executed with the wallet.
The CAIP2 chain ID of the chain the transaction is being sent on.
The details of the transaction to send on the chain.
Optional parameter to enable gas sponsorship for this transaction. Learn more.
Returns
The RPC method executed with the wallet.
The hash for the broadcasted transaction.
The CAIP2 chain ID of the chain the transaction was sent on.
A successful response indicates that the transaction has been broadcasted to the network.
Transactions may get broadcasted but still fail to be confirmed by the network. To handle these
scenarios, see our guide on speeding up transactions.
Report incorrect code
Copy
Ask AI
from .internal_client import generate_client
client = generate_client()
tx = client.wallets.rpc(
wallet_id=user.wallet_id,
method="eth_sendTransaction",
caip2="eip155:1",
params={
"transaction": {
"to": "0xE3070d3e4309afA3bC9a6b057685743CF42da77C",
"value": 100000,
},
},
)
return {"data": tx.data}
To send a transaction from your wallet, use the
sendTransaction method.
It will populate missing network-related values (gas limit, gas fee values, nonce, type),
sign your transaction, broadcast it to the network, and return the transaction hash to you.Usage
Report incorrect code
Copy
Ask AI
try {
String caip2 = "eip155:11155111"; // Sepolia testnet
EthereumSendTransactionRpcInputTransaction txn = EthereumSendTransactionRpcInputTransaction.builder()
.to(recipientAddress)
.value(EthereumSendTransactionRpcInputValue.of("0x1")) // 1 wei
.chainId(EthereumSendTransactionRpcInputChainId.of(11_155_111)) // Sepolia testnet
.build();
// Example: If wallet's owner is an authorization private key
AuthorizationContext authorizationContext = AuthorizationContext.builder()
.addAuthorizationPrivateKey("authorization-key")
.build();
EthereumSendTransactionRpcResponseData response = privyClient
.wallets()
.ethereum()
.sendTransaction(
walletId,
caip2,
txn,
authorizationContext
);
String transactionHash = response.hash();
} catch (APIException e) {
String errorBody = e.bodyAsString();
System.err.println(errorBody);
} catch (Exception e) {
System.err.println(e.getMessage());
}
Parameters
When defining a transaction, you may specify the following values on theEthereumSendTransactionRpcInputTransaction builder:The address sending the transaction (the user’s wallet address).
The address to send the transaction to.
The ID of the chain the transaction is being sent on.
The nonce for the transaction.
The data to include with the transaction, as a hexadecimal string.
The amount of wei to send, as an integer or hexadecimal string.
The type of transaction to send.
The gas limit for the transaction, as a hexadecimal string.
The gas price for the transaction, as a hexadecimal string.
The maximum fee per gas for the transaction, as a hexadecimal string.
The maximum priority fee per gas for the transaction, as a hexadecimal string.
Returns
TheEthereumSendTransactionRpcResponseData object contains a hash() fieldThe hash of the broadcasted transaction.
Use the
send_transaction method on the Ethereum service to sign and broadcast a transaction.Usage
Report incorrect code
Copy
Ask AI
use privy_rs::{AuthorizationContext, PrivyClient};
let client = PrivyClient::new("app_id".to_string(), "app_secret".to_string())?;
let ethereum_service = client.wallets().ethereum();
let auth_ctx = AuthorizationContext::new();
let transaction = EthereumSendTransactionRpcInputParamsTransaction {
to: Some("0x742d35Cc6635C0532925a3b8c17d6d1E9C2F7ca".to_string()),
value: None,
gas_limit: None,
max_fee_per_gas: None,
max_priority_fee_per_gas: None,
data: None,
chain_id: None,
from: None,
gas_price: None,
nonce: None,
type_: None,
};
let result = ethereum_service
.send_transaction(
&wallet_id,
"eip155:1",
transaction,
&auth_ctx,
None,
)
.await?;
println!("Transaction sent successfully");
Parameters and Returns
See the Rust SDK documentation for detailed parameter and return types, including embedded examples:For REST API details, see the API reference.A successful response indicates that the transaction has been broadcasted to the network.
Transactions may get broadcasted but still fail to be confirmed by the network. To handle these
scenarios, see our guide on speeding up transactions.
For a complete example of sending USDC with Privy’s SDKs, see our Sending USDC
recipe.

