EVM Raw Transactions
Use the EVM raw transaction format to create arbitrary EVM contract calls. For simple transfers or allowance revocations, consider using the dedicated higher-level formats (see EVM Transfers and EVM Revoke Allowances).
An alternative to Fordefi's REST API is the Fordefi JSON-RPC Provider interface.
Required Parameters
When creating an EVM transaction request, you need to specify:
Request Type Parameters
type
: Set toevm_transaction
details.type
: Set toevm_raw_transaction
signer_type
: In most cases, set it toapi_signer
Network Parameter
chain
: The target chain (can be specified as chain name or chain ID)
{
// ...
"chain": "evm_1"
}
Transaction Parameters
vault_id
: The origin vault identifierto
: The recipient's addressvalue
: The transaction value in weidata
: The call data, which can be specified in three different formats:- Method and arguments based on the contract's ABI
- Hex data
- Base64 data
The following examples show how to create transaction requests using the three different supported data formats:
Specify the method name and arguments directly. This format requires you to specify:
- The method name from the contract's ABI
- The method arguments as a list of key-value pairs.
{
"vault_id": "16b5aa12-509e-4944-b656-cf096515d627",
"signer_type": "api_signer",
"type": "evm_transaction",
"details": {
"type": "evm_raw_transaction",
"chain": "ethereum_mainnet",
"gas": {
"type": "priority",
"priority_level": "medium"
},
"to": "0x565697B5DD1F7Bdc61f774807057D058E5A27cbC",
"value": "0",
"data": {
"type": "full_details",
"method_name": "mintPublic",
"method_arguments": [
"quantity": "6"
]
}
}
}
Gas price
When creating an EVM transaction, you must specify the gas price, by populating the details.gas
field of the request.
There are two ways to specify it:
- The simplest way is to let Fordefi set the gas price based on the chain's current gas price. You can choose between
low
,medium
, andhigh
gas levels, which translate to different percentiles of recent gas prices. To do this, set thetype
topriority
and thepriority_level
to one of the following:low
,medium
, orhigh
. - You can also specify a gas price in wei manually. To do this, set the
type
tomanual
and thegas_price
to the price you want to use.
Examples:
{
// ...
"details": {
// ...
"gas": {
"type": "priority",
"priority_level": "medium"
}
}
}
Optional: Gas limit
The gas limit is the maximum amount of gas that can be used to execute the transaction. By default, it is set automatically by Fordefi using the eth_estimateGas
method of the node's JSON-RPC interface.
You can optionally specify a custom gas limit by setting the details.gas.gas_limit
field in the request. If omitted, Fordefi will automatically estimate an appropriate gas limit for the transaction.
Example with custom gas limit:
{
// ...
"details": {
// ...
"gas": {
// ...
"gas_limit": "1000000"
}
}
}
Optional: MEV Protection
Fordefi offers MEV protection for transactions on Ethereum Mainnet by sending the transaction to a secure node (Flashbots Protect) as opposed to the public mempool.
To enable MEV protection, set the use_secure_node
field to true
.
{
// ...
"details": {
// ...
"use_secure_node": true
}
}