Polygon Labs is acquiring Sequence to power the Open Money Stack. Learn more
Sequence

How to Transfer an NFT in your dapp

December 5 2022

Transfer NFTs into your dapp

In today’s post, we’ll look at the process of transferring a non-fungible token (NFT) with just a few lines of code using Sequence.

NFTs provide game builders with an array of opportunities to create unique user experiences. Gaming characters, weapons, and wearables are examples of NFTs that players can acquire, earn and trade.

As player ownership of interoperable in-game assets increases with the rise of shared worlds and cross-game economies, new possibilities will open up for buying, selling and transferring NFTs. Users will benefit from being able to transfer their NFTs between games, marketplaces, and wallets.

Adding functionality to enable dapps to transfer NFTs has previously been challenging. This is because the process typically requires a complex data structure, which can involve considerable time and effort to develop.

Sequence allows developers to set up an NFT transfer in mere lines of code, abstracting away the complexities of the movement of in-game assets. Sequence users benefit from its underlying infrastructure, which handles all the heavy lifting and allows developers to focus on creating their best blockchain projects.

Let’s dive in and see just how easy it is!

Feel free to copy and paste the code below to implement it.

If you would like to see the code in action, check out the Sequence demo on GitHub.

Install prerequisites

For this tutorial, you will be using ethers.js.

First, you `cd` into your dapp’s directory and install Sequence and ethers.js using your favorite package manager.

yarn add 0sequence ethers

or

npm install —-save 0sequence ethers

Instantiate the Sequence Wallet into your dapp

This step is for dapps running on the Ethereum mainnet. Sequence also works with other EVM-compatible chains and testnets; you can find them here.

import { sequence } from “0xsequence”;
const wallet = sequence.initWallet(‘mainnet’)

Connect to the wallet

Allow users to connect to your dapp using the Sequence Wallet.

const wallet = sequence.getWallet()
const connectDetails = await wallet.connect({
app: 'Your Dapp name',
authorize: true,
})
console.log('user accepted connect?', connectDetails.connected)
console.log('users signed connect proof to valid their account address:', connectDetails.proof)

This will connect to the default wallet. The Sequence Wallet is highly customizable, with settings allowing you to turn email login on and off, remove payment providers, toggle dark mode and more. You can check out the settings here.

Instantiate an ERC-721 token instance

An ERC-721 token is the Ethereum NFT token standard. You can instantiate one in your dapp using the following:

const erc721Interface = new ethers.utils.Interface([
'function safeTransferFrom(address _from, address _to, uint256 _tokenId)'
])

Create the NFT transaction

First, use `encodeFunctionData()` to encode the transfer of the NFT tokenId to the recipient.

const address = await wallet.getAddress()
const data = erc721Interface.encodeFunctionData(
‘safeTransferFrom’, [address, recipientAddress, tokenId]
)```
Using this encoded data, create a transaction object.
```const transaction = {
to: erc721TokenAddress,
data
}

This will provide you with the transaction data required to sign the NFT transfer.

Send the NFT

const signer = wallet.getSigner()
const txnResponse = await signer.sendTransaction(transaction)
//Wait for the transaction to be validated.
await txnResponse.wait()

Check Etherscan

Running this code will send your NFT to your recipient.

Check your wallets and Etherscan to ensure your NFT has been successfully transferred.

Now start building

In this quick tutorial, we’ve looked at how to transfer an NFT in your dapp using Sequence.

The Sequence SDK is built to make transactions cheap, fast and easy. You can also bundle this NFT transaction with another for cheaper gas.

Sequence allows you to easily integrate multichain ERC-20 tokens, NFTs, SFTs, gasless transactions, onramps, blockchain indexing, web wallets and more.

Get started with Sequence here. If you get stuck at any point, you can always dive into Github or get help on Discord.

We’re here to answer any questions you have along the way.


Sequence makes building onchain simple. Developers and teams can launch, grow, and monetize apps with unified wallets, 1-click cross-chain transactions, and real-time data, all in a modular and secure stack. No more stitching together fragmented tools or battling poor user flows. Sequence is production-ready infrastructure that helps teams ship faster, onboard more users, and scale confidently. From chains and stablecoins to DeFi and gaming, Sequence powers developers and applications across the EVM ecosystem with billions in transaction volume and millions of users. Trusted by leaders in blockchain, Sequence powers today’s onchain apps and delivers future-proof infrastructure for tomorrow’s breakthroughs. Learn more at sequence.xyz.


Written by

Robert Guenette

Product Marketing Director

Share this article

Share on FacebookShare on XShare on Linked In

Related Posts

Sequence x Polygon Labs acquisition
Sequence and Polygon: one unified solution to move money globally

Today marks a major milestone: Polygon Labs is acquiring Sequence.

January 13, 2026
A short guide to gasless transactions for web3 developers
A short guide to gasless transactions for web3 developers

A short guide that explains exactly what gasless transactions are, and why they matter for your web3 experience.

December 12, 2025
Netflix’s Black Mirror series goes onchain with Sequence and KOR Protocol
Netflix’s Black Mirror series goes onchain with Sequence and KOR Protocol

In partnership with KOR Protocol, Sequence and Msquared, Black Mirror's franchise has launched the $MIRROR token and a new web3 experience!

December 8, 2025
How to use web3 payment flows to grow revenue in apps and games
How to use web3 payment flows to grow revenue in apps and games

Web3 payment flows allow any app to embed onchain purchases and interactions in a way that feels natural for users. Learn more about them!

December 5, 2025

Stay up to date with Sequence

We'll keep you informed about the latest and best in web3 game development.