Skip to main content

Function Signature

Future<String> sendAsset({
  required String chainId,
  required String to,
  required String token,
  required String amount,
  String? signatureApprovalMemo,
  bool? sponsorGas,
})

Description

Send tokens from your Portal wallet to another address. This is the recommended method for simple token transfers.

Parameters

ParameterTypeRequiredDescription
chainIdStringYesThe chain ID in CAIP-2 format
toStringYesThe recipient address
tokenStringYesToken address or "NATIVE" for native token
amountStringYesAmount to send (in human-readable format)
signatureApprovalMemoStringNoOptional memo for transaction approval
sponsorGasboolNoWhether to use gas sponsorship (Account Abstraction)

Returns

String - The transaction hash.

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Send native token
final txHash = await portal.sendAsset(
  chainId: 'eip155:1',
  to: '0xRecipientAddress',
  token: 'NATIVE',
  amount: '0.01',
);

print('Transaction hash: $txHash');

Send ERC-20 Token

final txHash = await portal.sendAsset(
  chainId: 'eip155:1',
  to: '0xRecipientAddress',
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
  amount: '10',
);

With Gas Sponsorship Control

final txHash = await portal.sendAsset(
  chainId: 'eip155:1',
  to: '0xRecipientAddress',
  token: 'NATIVE',
  amount: '0.01',
  sponsorGas: false, // User pays gas
);

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
INSUFFICIENT_BALANCENot enough tokens to send
TRANSACTION_FAILEDThe transaction failed