Skip to main content

Function Signature

Future<DelegationTransferFromResponse> transferFrom({
  required String chain,
  required String token,
  required String fromAddress,
  required String toAddress,
  required String amount,
})

Description

Execute a transfer using previously approved delegated authority. The caller must have been granted delegation approval by the fromAddress owner.

Parameters

ParameterTypeRequiredDescription
chainStringYesCAIP-2 chain ID (e.g., "eip155:11155111" for Sepolia)
tokenStringYesToken symbol or address (e.g., "USDC")
fromAddressStringYesThe owner’s address (who approved the delegation)
toAddressStringYesThe recipient’s address
amountStringYesThe amount to transfer (e.g., "50.0")

Returns

DelegationTransferFromResponse - An object containing:
PropertyTypeDescription
transactionsList<DelegationConstructedTransaction?>?Array of constructed transactions (for EVM chains)
encodedTransactionsList<String?>?Array of encoded transaction strings (for Solana)
metadataDelegationTransferFromMetadataTransfer metadata with chain ID, delegate address, amount, etc.

Example

EVM

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

final response = await portal.delegations.transferFrom(
  chain: 'eip155:11155111',
  token: 'USDC',
  fromAddress: '0xowner...',
  toAddress: '0xrecipient...',
  amount: '50.0',
);

// Sign and send the transaction
final tx = response.transactions!.first!;
final txResponse = await portal.request(
  chainId: 'eip155:11155111',
  method: 'eth_sendTransaction',
  params: [
    {'from': tx.from, 'to': tx.to, 'data': tx.data, 'value': tx.value}
  ],
);
print('Tx hash: ${txResponse.result}');

Solana

final response = await portal.delegations.transferFrom(
  chain: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
  token: 'USDC',
  fromAddress: 'ARttPLesu9RiX6H111Pfdc9Y2DhGy1B8P8jyyrD8Cj5b',
  toAddress: 'GPsPXxoQA51aTJJkNHtFDFYui5hN5UxcFPnheJEHa5Du',
  amount: '50.0',
);

// Sign and send the transaction
final encodedTx = response.encodedTransactions!.first!;
final txResponse = await portal.request(
  chainId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
  method: 'sol_signAndSendTransaction',
  params: [encodedTx],
);
print('Tx hash: ${txResponse.result}');

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
DELEGATION_FAILEDThe delegated transfer failed
INSUFFICIENT_ALLOWANCEThe delegation allowance is insufficient