Bulk Transfer NFTs on Ethereum with Node.JS

Oliver
2 min readMar 27, 2022

--

Credit goes to Gal Shir

We’ve noticed that there aren’t many simple tutorials on how to bulk transfer NFTs. Also, you might not want to rely on an external website or service to transfer the NFTs for you since that could potentially expose your private keys. So we have written a small tutorial on how we can achieve that on our own.

Create an Alchemy account

In this tutorial, we’ll also take advantage of Alchemy’s developer tools for transferring the NFTs. If you don’t already have an Alchemy account, you can sign up for free here.

Once you’ve created an Alchemy account, you can generate an API key by creating an app. This will allow us to make requests to the Mainnet ethereum network.

Initialize our project

First, we’ll need to create a folder for our project. Navigate to your command line and type:

mkdir transfer-nfts-script
cd transfer-nfts-script

Now we’ll initialize the node project via npm init

If you don’t already have npm installed, you can go to nvm github repo and follow the instructions there to install it. We use nvm to manage multiple version for node.js in our machines.

After that, we need install the npm packages that will be used in the script:

yarn add @alch/alchemy-web3@^1.1.4 ethereumjs-util@^7.0.10 dotenv@^10.0.0

Grab your contract ABI

The contract ABI (Application Binary Interface) is the interface to interact with the smart contract of the NFTs we want to transfer. Let’s go to https://etherscan.io/ and enter the contract address of the NFTs . Now click on “Contract” and “Read”:

Contract on Etherscan

Now scroll down until you see “Contract ABI” and click on “copy ABI to clipboard”.

Go back to the node project, create a new file called contractAbi.js , paste the value you just got, and export the variable. For example:

const contractAbi = [
...
]
module.exports = contractAbi;

Since we are interacting with ethereum and our wallet, we’ll need to create an .env file that holds our private key, public key and Alchemy API Key we got earlier:

Now create a new file called index.js where we’ll add the logic to transfer the NFTs.

Paste the following to the file:

Remember to add the contract address to NFT_CONTRACT_ADDRESS variable and the list of addresses where the NFTs will be transferred to ADDRESS_LIST variable.

Run the script:

node index.js

You did it! 👏

Hope this tutorial saves your time and makes it easy to bulk transfer NFTs. Thanks :)

--

--

Oliver
Oliver

Written by Oliver

I share practical solutions to the challenges I encounter in business and tech.

Responses (1)