requestTransaction() is the primary method for executing state-changing blockchain operations through SocketFi. When your application calls it, the SDK constructs the transaction, presents an approval screen to the user, routes it through smart wallet authorization and policy enforcement, submits it to Soroban, and returns the result — all without you needing to manage keys, sign transactions, or handle network submission directly.
Method signature
TransactionRequest
TransactionResult
transactionHash is included in the response when success is true. You can use this hash to display a confirmation link, store it for auditing, or look up the transaction in a Stellar explorer.
Practical examples
Transfer tokens
Transfer tokens
Send tokens from the user’s wallet to another address.
Token approval (allowance)
Token approval (allowance)
Approve a protocol contract to spend tokens on the user’s behalf.
Staking
Staking
Stake tokens in a staking contract.
Protocol deposit
Protocol deposit
Deposit assets into a lending pool, vault, or other DeFi protocol.
Claim rewards
Claim rewards
Claim accumulated rewards from a rewards contract.
DAO vote
DAO vote
Cast a governance vote on an active proposal.
Mint NFT
Mint NFT
Mint a new NFT by calling the mint method on a collectible contract.
The approval flow
Every call torequestTransaction() enters an approval phase before any on-chain action occurs. The SocketFi approval screen shows the user exactly what they’re authorizing: the action being performed, which assets are involved, the destination address or protocol, and the estimated fee.
deposit(100)” — the approval screen reinforces this context, but your app should set it up clearly beforehand.
Error handling
Always wraprequestTransaction() in a try/catch block. The promise rejects on certain failure conditions such as popup blocking or token expiry, and it resolves with success: false when the user cancels or a transaction-level failure occurs.
UI state management
A well-designed transaction UI guides the user through each phase of the workflow. The recommended state progression is:When to use readContract() instead
requestTransaction() is for state-changing operations only. If you need to query contract state without modifying anything — checking a balance, reading a price, fetching governance data — use readContract() instead. Read-only queries don’t require user approval and resolve immediately.