Pratham Prasoon Profile picture
Dev Rel Engineer @MovementLabsxyz ๐Ÿฅ‘๐Ÿ”ฌ Python, JavaScript, & Rust junkie. Building things I love with blockchains by the day, working on AI at night ๐Ÿ› ๏ธ

Nov 19, 2021, 15 tweets

You can mint an NFT on the blockchain in JavaScript with ~10 lines of code.

No solidity, no testing... just these 10 lines of JavaScript.

Here's how it works ๐Ÿงต

Typically minting an NFT would require you to write code in this language called 'solidity' to create a smart contract which would then mint the nft.

It require lots of testing, security checks and remember, once code goes on the blockchain it cannot be changed.

This sucks.

What we'll do instead is use the thirdweb's JavaScript library, and with 7 lines of code we'll mint NFTs without any hassle.

I'll guide you through the entire process, let's go ๐Ÿ‘‡๐Ÿป

Make you sure have a metamask account set up and some fake ETH, here's step by step guide on how to get that done.

๐Ÿ”— thirdweb.com/portal/guides/โ€ฆ

Next head over to thirdweb.com/start, you will be guided through a setup process.

These steps are to get your metamask setup.

These steps are for choosing the chain network, we'll go with the rinkeby testnet.

Our NFT will be minted on this "fake" test network called rinkeby for free.

Now we can create the project to which we'll be adding the NFT module to create NFTs ๐Ÿ˜‹

Adding the NFT module... and volia!

We actually can now mint NFTs straight from the dashboard.

But we don't do that, we're JavaScript programmers.

Make sure you copy the "module address" from the previous step which we'll use in the code.

Just click on the pill and it'll copy it for you.

Now onto the code.

Using these commands we'll install the thirdweb sdk and types.

Additionally you can install TypeScript if thats your jam.

We'll import the thirdweb library and ethers js for connecting our wallet and also import the private key that you should remember from the metamask guide.

Remember to store your private key safely and do not share them with anyone.

We will now instantiate the sdk, add our private key and connect to the blockchain.

Finally can add the module address from the dashboard and mint the NFT.

We're adding details like the same of the NFT,description and the URL of the image that is going to be an NFT.

Run the code and you have just minted your very first NFT, congratulations! ๐ŸŽ‰

All it took was 15 minutes of setup and ~10 lines of JavaScript.

If you liked this thread make sure to follow @PrasoonPratham and retweet it.

I'll teach you all about web3!

Want to read this thread later on?

Save it as a link, there's also additional content in this guide ๐Ÿ‘‡๐Ÿป

thirdweb.com/portal/guides/โ€ฆ

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling