Module

Raw TX — 5–10 credits

Low-level raw transaction operations. Sign a transaction (5 credits) and broadcast it to the network (10 credits). Useful for offline signing workflows, batch processing, or advanced transaction composition.

API Key
ℹ️
The sign → broadcast pattern lets you sign offline and broadcast later, or inspect the serialized transaction before submission. For most use cases, the higher-level Transfer or Contract modules are simpler.
sign()
POST 5 credits API Key

Sign a raw transaction and return the serialized RLP-encoded hex string and its transaction hash. The transaction is not broadcast at this step.

Parameters

NameTypeRequiredDescription
$fromAddressstringYesSender's wallet address
$privateKey?stringNoSender's private key for signing. Pass null to use the stored managed wallet
$tostringYesRecipient address
$valuestringYesValue in wei (e.g. "1000000000000000" = 0.001 ETH)
$datastringNoABI-encoded call data (default: "0x")
$gas?intNoGas limit (auto-estimated if null)
$gasPrice?stringNoGas price in wei (uses network default if null)
$nonce?intNoTransaction nonce (auto-fetched from node if null)
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK

Example

$signed = Web3Api::tx()->sign(
    fromAddress: '0xSENDER_ADDRESS',
    privateKey:  '0xSENDER_PRIVATE_KEY',
    to:          '0xRECEIVER_ADDRESS',
    value:       '100000000000000000',  // 0.1 ETH in wei
    data:        '0x',
    gas:         21000,
    gasPrice:    '50000000000',         // 50 gwei
    nonce:       null,                  // auto-fetched
    network:     'polygon',
);

$rawTx = $signed['raw_transaction'];    // "0xf86c..."
$txHash = $signed['tx_hash'];           // predicted hash

Response

[
  'raw_transaction' => '0xf86c808505d21dba008252089...',   // RLP-encoded hex
  'tx_hash'         => '0xabcdef1234567890...',            // predicted tx hash
]
broadcast()
POST 10 credits API Key

Broadcast a pre-signed raw transaction to the network. Use the raw_transaction from sign() or from any other signing tool.

Parameters

NameTypeRequiredDescription
$rawTransactionstringYesHex-encoded signed transaction (0x-prefixed)
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK

Example — full sign → broadcast flow

// Step 1: sign (5 credits)
$signed = Web3Api::tx()->sign(
    fromAddress: '0xSENDER_ADDRESS',
    privateKey:  '0xSENDER_PRIVATE_KEY',
    to:          '0xRECEIVER_ADDRESS',
    value:       '100000000000000000',  // 0.1 ETH in wei
    network:     'polygon',
);

// Inspect if needed, store for later, etc.
logger()->info('Signed tx', ['hash' => $signed['tx_hash']]);

// Step 2: broadcast (10 credits)
$result = Web3Api::tx()->broadcast(
    rawTransaction: $signed['raw_transaction'],
    network:        'polygon',
);

echo $result['tx_hash'];   // confirmed hash after submission

Response

[
  'tx_hash' => '0xabcdef1234567890...',
  'network' => 'polygon',
]