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).
For more tutorials on calling EVM smart contracts, check out our pubic API Examples repository on Github.
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 either hex or Base64 format.
The following examples show how to create transaction requests using the two different supported data formats:
{
"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": "hex",
"hex_data": "0x0d1d7ae50000000000000000000000000000000000000000000000000000000000000006"
}
}
}
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
}
}