The goal of this tutorial is to use the OpenSea SDK to buy and sell NFTs programmatically. Before we get started, you'll need a few things.
Note: if you already have a wallet through a different provider (ex. Metamask), you can export your private key through their preferred method and move on to the next step.
In order to create offers and listings, you'll need a wallet funded with cryptocurrency. Start by going to the OpenSea website and creating an account by clicking the "Login" button in the top right corner. After your account is created, you'll see your new Ethereum address.
After your wallet has been created, add some funds to it. See this OpenSea Help Center article for how to add funds if you aren't sure.
For the rest of this tutorial, you'll need your newly created wallet's private key. Go to "Settings" -> "Export private key", authenticate, and note the key down somewhere safe.
Please do not share your private key with anyone.
You'll need an OpenSea API Key to use our SDK. Follow this guide to get one.
This Github repo is an example on the basics of using our SDK to buy and sell NFTs. Clone it and
cd into the directory.
git clone [email protected]:ProjectOpenSea/buy-sell-opensea-sdk-demo.git
At this point, you should have three things:
- A funded wallet
- An OpenSea API key
- An Alchemy API Key
Set these as environment variables like this:
export OPENSEA_API_KEY='<YOUR_OPENSEA_API_KEY>' &&
&& export ALCHEMY_API_KEY='<YOUR_ALCHEMY_API_KEY>'
Updated 22 days ago