Skip to content
LogoLogo

Transfer with Wallet

wallet.transfer

Transfers a TIP-20 token via the connected Tempo wallet.

This action invokes the wallet_transfer JSON-RPC method on the connected wallet. By default it is read-only: the wallet uses a matching access key when one is available, otherwise it shows a confirm dialog. Pass editable: true to open the wallet send UI with the supplied fields pre-filled.

Usage

example.ts
import { ,  } from 'viem/tempo'
import 'viem/window'
 
const  = .({
  : (.!),
})
 
const {  } = await ..({
  : '1.5',
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : 'pathusd',
})
 
.('Transaction hash:', .)
Transaction hash: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

Editable Usage

Pass editable: true to open the wallet send UI for the user to confirm or edit before signing. All other fields become optional pre-fills:

import { ,  } from 'viem/tempo'
import 'viem/window'
 
const  = .({
  : (.!),
})
 
const {  } = await ..({
  : true,
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : 'pathusd',
})

Recipes

Tag a Checkout Payment with an Order Memo

Attach the order reference as a memo (UTF-8, max 32 bytes) so your backend can match the onchain transfer to the order.

example.ts
import { ,  } from 'viem/tempo'
import 'viem/window'
 
const  = .({
  : (.!),
})
 
const {  } = await ..({
  : '249.99',
  : 'order_1024',
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : 'pathusd',
})

Charge a Subscription from an Allowance

Set from to collect a recurring charge from a subscriber who granted your account an allowance with token.approve; the wallet submits a transferFrom.

example.ts
import { ,  } from 'viem/tempo'
import 'viem/window'
 
const  = .({
  : (.!),
})
 
const {  } = await ..({
  : '15',
  : '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : 'pathusd',
})

Point feePayer at your own fee payer service to sponsor customer transfers such as micropayments, or pass false to disable the wallet's default fee payer.

example.ts
import { ,  } from 'viem/tempo'
import 'viem/window'
 
const  = .({
  : (.!),
})
 
const {  } = await ..({
  : '0.05',
  : 'https://sponsor.example.com',
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : 'pathusd',
})

Return Value

type ReturnType = {
  /** Chain ID the transfer was submitted to. */
  chainId: number
  /** Receipt of the submitted transfer. */
  receipt: TransactionReceipt
}

The submitted transfer receipt and chain ID.

Parameters

amount

  • Type: string

Human-readable amount to transfer (for example, "1.5"). Optional when editable is true.

chainId

  • Type: number
  • Default: the active chain

Chain ID to transfer on.

editable

  • Type: boolean
  • Default: false

Whether to open the editable wallet send UI. When false, the wallet uses a matching access key when one is available, otherwise it shows a confirm dialog.

feePayer

  • Type: boolean | string

Fee payer override. false disables the wallet's default fee payer. A URL string uses a custom fee payer service.

from

  • Type: Address
  • Default: the active account

Address to transfer tokens from. When set to a different address, the call uses transferFrom and requires the active account to have an allowance from from. Read-only variant only.

memo

  • Type: string

UTF-8 memo (max 32 bytes) to attach to the transfer.

to

  • Type: Address

Recipient address. Optional when editable is true.

token

  • Type: Address | string

Token to transfer, accepted as either a contract address or a curated tokenlist symbol (case-insensitive, for example "pathusd"). Optional when editable is true.