Intents

Raw Transaction

Learn how to create raw EVM transactions using the Okto SDK.

The ExecuteEvmRawTransaction() function creates a user operation for executing raw EVM transactions. This function allows you to create custom transactions by specifying the raw transaction parameters.

Available on

Ethereum
Ethereum
Polygon
Polygon
Avalanche
Avalanche
Arbitrum
Arbitrum
BSC
BSC
Fantom
Fantom
Linea
Linea
Metis
Metis
Optimism
Optimism
Base
Base
Base Sepolia
Base Sepolia
HyperEVM Testnet
HyperEVM Testnet
Polygon Amoy
Polygon Amoy

To enable these chains for your application, please configure them in the Okto Dashboard.

Not available on

There are two ways to implement raw transactions:

  • Abstracted Flow: A simplified approach where the user operation is automatically created, signed, and executed in a single step. Perfect for most applications.
  • UserOp Flow: A granular approach where you manually control the creation, signing, and execution of the user operation. Useful for custom implementations or advanced use cases.

Example

// EVM Transaction
EVMTransaction evmTx = new EVMTransaction 
{
    from = "0x1234...",
    to = "0x5678...",
    data = "0x...",    // contract call data
    value = "0"        // amount of tokens, usually 0 for read operations
};
 
ExecuteRawTransaction txData = new ExecuteRawTransaction 
{
    network_name = "ETHEREUM",
    transaction = evmTx
};
 
try 
{
    var result = await OktoProviderSDK.Instance.executeRawTransactionPol(txData);
    Debug.Log("Transaction submitted, Job ID: " + result.jobId);
 
    var status = await OktoProviderSDK.Instance.ExecuteRawTransactionWithJobStatus(txData);
    Debug.Log($"Transaction status: {status.status}");
} 
catch (Exception e) 
{
    Debug.LogError($"Transaction failed: {e.Message}");
}

Note

For error handling:

Method Overview

MethodDescription
string ExecuteEvmRawTransactionCreate a user operation for raw EVM transaction

EVM Raw Transaction

Note

Before using this function, ensure your target chain is an EVM-compatible chain by checking the Supported Chains and Tokens documentation.

UserOp CreateUserOp(data: Transaction) creates a user operation for raw EVM transactions.

Parameters

ParameterTypeDescriptionRequired
dataRawTransactionIntentParamsParameters for the raw transactionYes

Where RawTransactionIntentParams contains:

FieldTypeDescriptionRequired
caip2IdstringThe network identifier (e.g., eip155:1 for Ethereum)Yes
transactionTransactionThe raw transaction parametersYes

And Transaction contains:

FieldTypeDescriptionRequired
fromstringThe sender's addressYes
tostringThe recipient's addressYes
datastringThe transaction dataNo
valuestringThe amount of native currency to sendYes

Response

Success Response

Field NameTypeDescription
resultstringReturns the jobId for the raw transaction

On this page