Intents

Token Transfer

Learn how to create token transfer operations using the Okto SDK.

The ExecuteTokenTransfer() function creates a user operation for transferring tokens. This function initiates the process of transferring a token by encoding the necessary parameters into a User Operation, which can then be signed and executed using the OktoClient.

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 token transfers:

  • 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

TransferTokens transferData = new TransferTokens 
{
    network_name = "POLYGON_TESTNET",
    token_address = "0x1234...",
    quantity = "1.5",
    recipient_address = "0x5678..."
};
 
try 
{
    // Basic Transfer
    var result = await OktoProviderSDK.Instance.TransferTokens_(transferData);
    Debug.Log("Token transfer initiated. Order ID: " + result.orderId);
 
    // Transfer with job status tracking
    var status = await oktoProvider.TransferTokensWithJobStatus(transferData);
    Debug.Log($"Transfer status: {status.status}");
} 
catch (Exception e) 
{
    Debug.LogError($"Transfer failed: {e.Message}");
}

Note

For error handling:

Method Overview

MethodDescription
string ExecuteTokenTransferCreate a user operation for token transfer

Token Transfer

UserOp CreateUserOp(data: TokenTransferIntentParams) creates a user operation for transferring tokens.

Parameters

ParameterTypeDescriptionRequired
dataTokenTransferIntentParamsParameters for the token transferYes

Where TokenTransferIntentParams contains:

FieldTypeDescriptionRequired
amountBigIntegerAmount to send, in the smallest unit (e.g., gwei for ETH)Yes
recipientstringWallet address of the recipientYes
tokenstring | ''The token address for the transactionYes
caip2IdstringThe network ID (e.g., Ethereum - eip155:1, Polygon - eip155:137)Yes

Response

Success Response

Field NameTypeDescription
resultstringReturns the jobId for the token transfer

On this page