Skip to main content

Fund your Wallet

Now that you have a wallet, the next step is to get test tokens for it. You can fund your wallet using portal.receiveTestnetAsset. If you are looking for a greater variety of test tokens, we recommend exploring our faucets page.
The chainId will need to be a CAIP-2 compliant Chain ID. For more info on Chain ID formatting, see this doc.
import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Monad Testnet
final chainId = 'eip155:10143';

// Fund your Portal wallet
final response = await portal.receiveTestnetAsset(
  chainId: chainId,
  amount: '0.01', // You will receive 0.01 MON
  token: 'NATIVE', // Use "NATIVE" for the chain's native token
);

print('Transaction hash: ${response.transactionHash}');

Sending Tokens from your Wallet

Portal provides two ways to send transactions:
  1. portal.sendAsset() - A simple method for sending tokens from your Portal wallet.
  2. portal.sendTransaction() - Direct access to the underlying provider for custom transactions. (You can learn more about this method here.)
For most use cases, we recommend using portal.sendAsset() as shown in the examples below.

Submitting an EVM Transaction

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Monad Testnet
final chainId = 'eip155:10143';

// Send the tokens
final txHash = await portal.sendAsset(
  chainId: chainId,
  to: '0xDestinationAddress', // The recipient address
  amount: '0.0001', // Sends 0.0001 MON
  token: 'NATIVE', // Use "NATIVE" for the chain's native token
);

print('Transaction hash: $txHash');
If your Portal client is using Account Abstraction, then txHash is actually a User Operation hash. You can manually look up the user operation hash here.

Sending ERC-20 Tokens

To send ERC-20 tokens, specify the token contract address:
// Send USDC on Ethereum mainnet
final txHash = await portal.sendAsset(
  chainId: 'eip155:1',
  to: '0xDestinationAddress',
  amount: '10', // 10 USDC
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC contract address
);

print('Transaction hash: $txHash');

Submitting a Solana Transaction

You will need SOL to submit a Solana transaction, which is not currently supported by portal.receiveTestnetAsset. You can find a faucet to get test SOL tokens here.
import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Solana Devnet
final chainId = 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1';

// Send the tokens
final txHash = await portal.sendAsset(
  chainId: chainId,
  to: 'DestinationAddress', // The recipient address (Solana format)
  amount: '0.0001', // Sends 0.0001 SOL
  token: 'NATIVE',
);

print('Transaction hash: $txHash');
You just sent your first token from your Portal wallet!

Advanced: Controlling Gas Sponsorship

If your client is using Account Abstraction, you can control whether Portal sponsors the gas fees for each transaction using the sponsorGas parameter.

Example: User Pays Gas

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Ethereum Sepolia
final chainId = 'eip155:11155111';

// Send tokens with user paying gas
final txHash = await portal.sendAsset(
  chainId: chainId,
  to: '0xDestinationAddress',
  amount: '0.0001',
  token: 'NATIVE',
  sponsorGas: false, // Portal client pays transaction fees
);

print('Transaction hash: $txHash');
By setting sponsorGas: false, the Portal client will pay for the transaction fees instead of having them sponsored. This is useful for testing or when you want users to pay for specific operations.
Omitting sponsorGas or setting it to true produces the same behavior - both will sponsor gas if your environment is configured for AA on that chain. Only sponsorGas: false changes the default behavior to disable sponsorship.
Learn more about gas sponsorship control in the Account Abstraction guide. Related Documentation