Loading

evm_prepare_tx

Scalar function

Builds an unsigned eth_sendTransaction JSON payload with minimal inputs.

1
-- Encode an ERC20 transfer payload inside DuckDB
2
WITH prepared AS (
3
SELECT evm_prepare_tx(
4
'0x4200000000000000000000000000000000000006'::ADDRESS,
5
encode_function_data(erc20_abi, 'transfer', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS, 1::UINT256)
6
) AS tx
7
)
8
SELECT json_extract_string(tx, '$.data') AS calldata FROM prepared;
Notebook ready in readonly mode.

evm_prepare_tx(ADDRESS, BYTES)

Accepts ADDRESS + calldata BLOB; wallets infer value/gas/fees.

Parameters

Name Type
to ADDRESS
data BYTES

Returns

Name Type
tx SIGNABLE

evm_prepare_tx(ADDRESS, BYTES, UINT256)

Extends the minimal form with an explicit ETH value.

Parameters

Name Type
to ADDRESS
data BYTES
value UINT256

Returns

Name Type
tx SIGNABLE
1
-- Prepare a payable contract call with 1e18 wei
2
SELECT evm_prepare_tx(
3
vault_address,
4
encode_function_data(vault_abi, 'deposit'),
5
1000000000000000000::UINT256
6
) AS tx;
Notebook ready in readonly mode.

evm_prepare_tx(ADDRESS, BYTES, UINT256, JSON)

Allows advanced field overrides via an options JSON (nonce, gas, blob fees, etc.).

Parameters

Name Type
to ADDRESS
data BYTES
value UINT256
options JSON

Returns

Name Type
tx SIGNABLE
1
-- Pin fee caps and nonce for a multisig execution
2
SELECT evm_prepare_tx(
3
safe_address,
4
multisig_calldata,
5
0::UINT256,
6
json('{
7
"from": "0x5AbF..." ,
8
"nonce": 42,
9
"maxFeePerGas": "0x77359400",
10
"maxPriorityFeePerGas": "0x3b9aca00"
11
}')
12
) AS tx;
Notebook ready in readonly mode.