Intents

NFT Transfer

Learn how to create NFT transfer operations using the Okto TypeScript SDK.

The nftTransfer() function creates a user operation for transferring NFTs. This function initiates the process of transferring an NFT 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
Polygon Amoy
Polygon Amoy

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

Not available on

Base Sepolia
Base Sepolia
HyperEVM Testnet
HyperEVM Testnet

There are two ways to implement NFT 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

import { nftTransfer } from "@okto_web3/core-js-sdk"; 
 
async function handleNFTTransfer() {
    try {
        const transferParams = { 
            caip2Id: "eip155:1", // Ethereum Mainnet 
            collectionAddress: "0x23581767a106ae21c074b2276D25e5C3e136a68b", 
            nftId: "123", // NFT token ID 
            recipientWalletAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", 
            amount: 1, 
            nftType: 'ERC721'
        }; 
        
        // Execute the transfer
        const jobId = await nftTransfer(oktoClient, transferParams); 
        console.log('Transfer jobId:', jobId);
    } catch (error) {
        console.error('Error in NFT transfer:', error);
    }
}

Note

For error handling:

Method Overview

MethodDescription
async nftTransferCreate a user operation for NFT transfer

NFT Transfer

async nftTransfer(oktoClient: OktoClient, data: NFTTransferIntentParams) creates a user operation for transferring NFTs.

Parameters

ParameterTypeDescriptionRequired
oktoClientOktoClientInstance of OktoClientYes
dataNFTTransferIntentParamsParameters for the NFT transferYes

Where NFTTransferIntentParams contains:

FieldTypeDescriptionRequired
caip2IdstringThe network identifier, formatted as a CAIP network IDYes
collectionAddressAddressThe address of the NFT collectionYes
nftIdstringThe unique identifier of the NFTYes
recipientWalletAddressAddressThe wallet address of the recipientYes
amountnumber | bigintThe amount of NFTs to transfer, typically "1"Yes
nftType'ERC721' | 'ERC1155'The type of NFT standardYes

Response

Success Response

Field NameTypeDescription
resultPromise<string>Returns the jobId for the NFT transfer

On this page