Send native assets and tokens
UsesendNative for a network’s native asset and sendToken for tokens.
25 means 25 USDC. The SDK determines the token’s decimals and converts the amount before submitting the transaction.
For EVM tokens, decimals are resolved from Rain’s token registry, tokens registered by your application, or the token contract. If the SDK cannot determine the token, it returns RAIN_102 with tokenNotFound.
The chainId determines which account and network are used. Solana chain IDs use the wallet’s Solana account. Supported EVM chain IDs use the wallet’s EVM account.
What the SDK checks before signing
Before requesting a signature or submitting anything to the network, the SDK validates the transaction on the device and returns a typed error if a check fails.
With gas sponsorship enabled, the SDK skips the local simulation check. A transaction that later fails during processing can return
RAIN_403 or RAIN_501 after signing.
Fees
With gas sponsorship enabled, users do not pay network fees, so most send screens do not need to show a fee. If you want to display the network cost, or if sponsorship is disabled, useestimateGas to estimate the fee in the chain’s native asset.
estimateGas returns the estimated network cost even when Rain sponsors the transaction, so you can show what the user saves.
Transaction results
A successful send returns aRainTokenTransferResult with a transactionHash. The presence of a transaction hash means the transaction was broadcast. It does not mean the transaction has been confirmed onchain. Use transaction history to reflect the final status in your UI.
Two additional outcomes require special handling:
RAIN_302 transactionPending(statusId)means Rain accepted the transaction, but the transaction hash was not available before the SDK polling window ended. Show the transaction as pending, retain thestatusId, refresh transaction history, and do not allow the user to resend immediately.RAIN_301 networkErrorafter the user submits a send means the outcome is unknown: the request may have reached Rain and been broadcast even though the client did not receive a response. Do not treat it as a failure or offer an immediate retry. History lists confirmed transactions only, so an emptygetTransactionsresult right after the error does not prove the send was lost. Keep the send pending, refresh history and the balance, and offer a retry only once the transaction has had time to confirm and neither reflects it.
Solana considerations
Solana sends have a few additional requirements:- Token decimals are validated onchain. The SDK reads the token’s decimals from the mint and uses
TransferCheckedfor token transfers. - The sender may need SOL for account creation. If the recipient has never held the token, the transfer may need to create an associated token account. That cost is paid by the sender and is not covered by gas sponsorship. If the sender does not have enough SOL, the SDK returns
RAIN_402with the shortfall. - Outbound support is limited to mainnet and devnet. Solana testnet is read only and returns
RAIN_104for sends.
Collateral withdrawals
Withdrawing card collateral is also a wallet signed transaction, but it follows a separate flow from a standard send. The withdrawal targets the user’s collateral contract and also requires authorization from your backend. UsewithdrawCollateral, prepareWithdrawal, and estimateWithdrawalFee for this flow. See Card funding and settlement for implementation details.
What’s next
Error reference
Every code above, with handling patterns.
Gas sponsorship
Why the user doesn’t need ETH, and where they still need SOL.