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
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
| Name | Type | Required | Description |
|---|---|---|---|
$fromAddress | string | Yes | Sender's wallet address |
$privateKey | ?string | No | Sender's private key for signing. Pass null to use the stored managed wallet |
$to | string | Yes | Recipient address |
$value | string | Yes | Value in wei (e.g. "1000000000000000" = 0.001 ETH) |
$data | string | No | ABI-encoded call data (default: "0x") |
$gas | ?int | No | Gas limit (auto-estimated if null) |
$gasPrice | ?string | No | Gas price in wei (uses network default if null) |
$nonce | ?int | No | Transaction nonce (auto-fetched from node if null) |
$network | ?string | No | Network 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
| Name | Type | Required | Description |
|---|---|---|---|
$rawTransaction | string | Yes | Hex-encoded signed transaction (0x-prefixed) |
$network | ?string | No | Network 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',
]