> ## Documentation Index
> Fetch the complete documentation index at: https://rain-sandbox-trial.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Arbitrary Sends & DeFi

> Send tokens anywhere from the embedded wallet, and use it with DeFi and other dapps by driving the underlying wallet provider.

Send funds anywhere and use the embedded wallet with DeFi and other dapps: it's a standard non-custodial wallet, so it can do anything the underlying provider can. This goes beyond Rain's built-in card and collateral flows.

## Arbitrary sends

Send native or ERC-20 tokens from the wallet to any recipient with the SDK's send methods: the same API you use for transfers. See [Balances & Transactions](/sdks/embedded-wallets-balances-and-transactions#send-tokens). The `recipient` and token addresses below are examples; replace them with your own, and use a testnet chain id (`RainChain.avalancheTestnet` / `RainChain.AVALANCHE_TESTNET`) while you develop.

<CodeGroup>
  ```swift iOS theme={null}
  let recipient = "0x3cA8ac240F6ebeA8684b3E629A8e8C1f0E3bC0Ff"
  let usdc = "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"

  let native = try await client.sendNative(chainId: RainChain.avalancheMainnet, to: recipient, amount: 0.5)
  let erc20 = try await client.sendToken(
      chainId: RainChain.avalancheMainnet, contractAddress: usdc, to: recipient, amount: 100
  )
  ```

  ```kotlin Android theme={null}
  val recipient = "0x3cA8ac240F6ebeA8684b3E629A8e8C1f0E3bC0Ff"
  val usdc = "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"

  val native = client.sendNativeToken(chainId = RainChain.AVALANCHE_MAINNET, toAddress = recipient, amount = BigDecimal("0.5"))
  val erc20 = client.sendToken(
      chainId = RainChain.AVALANCHE_MAINNET, contractAddress = usdc, toAddress = recipient, amount = BigDecimal("100.0")
  )
  ```
</CodeGroup>

## Arbitrary transactions & DeFi

For arbitrary contract calls (swaps, staking, bridging, minting), the Client SDK doesn't wrap a generic "send any transaction." Build the calldata with your DeFi library, then sign and submit directly through the wallet provider you drive, using the wallet's address (from `getWalletAddress()`):

* **Managed Turnkey**: you hold the authenticated `TurnkeyContext`; use Turnkey's SDK to sign and submit any transaction the user approves.
* **Privy**: you hold the authenticated `Privy` singleton; use Privy's EIP-1193 provider directly.
* **Portal**: on iOS, capture the `Portal` instance via `PortalProvider`'s `onPortalCreated` hook and call Portal directly. The Android adapter constructs Portal internally and doesn't expose the instance, so stick to the SDK's send methods for Portal wallets on Android.

The SDK's helper assembles a Rain-owned transaction bag for a zero-value call, and Android can price a call before sending it:

<CodeGroup>
  ```swift iOS theme={null}
  let params = rain.buildTransactionParameters(
      walletAddress: walletAddress,
      contractAddress: contractAddress,
      transactionData: calldata
  )
  // RainTransactionParameters { from, to, data, value: 0 }
  ```

  ```kotlin Android theme={null}
  // Assemble { from, to, data, value: 0 }
  val params = client.composeTransactionParameters(walletAddress, contractAddress, transactionData)

  // Price a call before sending it
  val gas: BigDecimal = client.estimateGas(chainId, from = walletAddress, to = contractAddress, data = transactionData)
  ```
</CodeGroup>

For payable calls (sending native value along with the call), set the `value` field yourself on the transaction you submit to the provider.

## Gas

Arbitrary transactions pay network gas in the chain's native token. Make sure the wallet holds enough native token (for example ETH or AVAX) for the operations you submit: these transactions are the user's own wallet actions and are independent of Rain card spend and collateral.

## What's next

<Columns cols={3}>
  <Card title="Balances & Transactions" icon="coins" href="/sdks/embedded-wallets-balances-and-transactions">
    Query balances and send tokens.
  </Card>

  <Card title="Withdraw Collateral" icon="arrow-right-from-bracket" href="/sdks/embedded-wallets-withdraw-collateral">
    Execute collateral withdrawals from your app.
  </Card>

  <Card title="Supported Chains & Tokens" icon="link" href="/docs/supported-chains-and-tokens">
    See which networks and tokens Rain supports.
  </Card>
</Columns>
