Module

Transfer — 10 credits

Send native currency (ETH, MATIC, BNB, etc.) and ERC-20 tokens between addresses. All transfer methods require API Key authentication and cost 10 credits each.

⚠️
API Key required. Transfer endpoints require X-Api-Key authentication. JWT cannot be used for transfers. This is a security requirement — private keys should only be sent from trusted server environments.
native()
POST 10 credits API Key

Transfer the native currency (ETH, MATIC, BNB, AVAX, etc.) from one address to another. The amount is specified in human-readable form (not wei).

Parameters

NameTypeRequiredDescription
$fromAddressstringYesSender's wallet address
$privateKey?stringNoSender's private key (0x-prefixed). Pass null to sign with the stored managed wallet for the from address
$toAddressstringYesRecipient's wallet address
$amountstringYesAmount to send in native units (e.g. "0.1" for 0.1 MATIC)
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK

Example

use Web3Sdk\Laravel\Facades\Web3Api;
use Web3Sdk\Laravel\Exceptions\InsufficientCreditsException;

try {
    $tx = Web3Api::transfer()->native(
        fromAddress: '0xSENDER_ADDRESS',
        privateKey:  '0xYOUR_PRIVATE_KEY',
        toAddress:   '0xRECEIVER_ADDRESS',
        amount:      '0.1',        // 0.1 MATIC
        network:     'polygon',
    );

    echo $tx['tx_hash'];  // "0xabcdef1234..."
    echo $tx['status'];   // "pending"

} catch (InsufficientCreditsException $e) {
    echo "Need {$e->cost} credits, have {$e->balance}";
}

Response

[
  'tx_hash' => '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
  'status'  => 'pending',
]
token()
POST 10 credits API Key

Transfer an ERC-20 token from one address to another. Amount is specified in human-readable form; use $decimals to match the token's decimal places.

Parameters

NameTypeRequiredDescription
$tokenAddressstringYesERC-20 token contract address
$fromAddressstringYesSender's wallet address
$privateKey?stringNoSender's private key (0x-prefixed). Pass null to sign with the stored managed wallet for the from address
$toAddressstringYesRecipient's wallet address
$amountstringYesAmount in human-readable form (e.g. "10.5" for 10.5 USDC)
$decimalsintNoToken decimals (default: 18). USDC = 6, most ERC-20 = 18
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK

Example — Send USDC (6 decimals)

$tx = Web3Api::transfer()->token(
    tokenAddress: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', // USDC on Polygon
    fromAddress:  '0xSENDER_ADDRESS',
    privateKey:   '0xYOUR_PRIVATE_KEY',
    toAddress:    '0xRECEIVER_ADDRESS',
    amount:       '10.5',   // 10.5 USDC
    decimals:     6,        // USDC has 6 decimal places
    network:      'polygon',
);

Example — Send a standard 18-decimal token

$tx = Web3Api::transfer()->token(
    tokenAddress: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', // WETH on Polygon
    fromAddress:  '0xSENDER_ADDRESS',
    privateKey:   '0xYOUR_PRIVATE_KEY',
    toAddress:    '0xRECEIVER_ADDRESS',
    amount:       '0.05',   // 0.05 WETH
    // decimals defaults to 18
);

Response

[
  'tx_hash' => '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
  'status'  => 'pending',
  'network' => 'polygon',
]
ℹ️
After submitting a transfer, use Web3Api::transactions()->status() to poll for confirmation, or configure a webhook in your provider dashboard for transaction.confirmed events.