Uncategorized

Coding an NFT crypto collectible in 3 days (DAY 1)

caption

If you're watching this video you 
most likely heard about this thing   called an NFT. After Beeple, a famous 
digital artist sold one of his images   for a whopping 69 million us dollars, 
the hype is all over the place. I had no idea what an NFT is, nor did I know how 
to create one. So I set out to a little challenge.   I find out as much as I can about NFTs, 
Smart-Contracts, Ethereum, and Decentralized   Apps.

And program my own NFT crypto collectible 
in only three days and release it to OpenSea. This is day one! I know that a lot of NFTs run 
on the Ethereum Blockchain.   But I have no Idea, what running 
on the blockchain actually means.   So first things first: I have to find out, 
what Ethereum actually is and how it works. Ethereum is the second-largest 
cryptocurrency by market capitalization   after Bitcoin and it is a blockchain-based 
software platform. You can send   and receive Ethereum globally without any 
third-party actually doing the transfer. But there is more to Ethereum than there is to 
other blockchains like the Bitcoin Blockchain:   Etherum is able to run programs, 
so-called smart contracts. These little programs are not run on one 
specific server, but inside of the blockchain. So while Ethereum is built upon the same 
technology Bitcoin is built on, a Blockchain,   the idea behind Ethereum is to decentralize 
other kinds of applications and services,   from social media networks to 
more complex financial agreements.

So we have this big network of computers at our 
disposal that we can use to run programs on. But   how can I create a program for it? And how can 
people access it? In the long run, Ethereum Apps   should be everywhere. At least that's the vison. 
So instead of talking to one server, apps from the   App Store would talk to the Ethereum Blockchain. 
But how far into this future are we already? Researching further I learned 
about decentralized apps or   dApps. dApps use the blockchain as 
the storage for their main data. I found dApps for exchanging 
different cryptocurrencies   and taking out loans.

There are also 
whole games or virtual worlds built,   which use the Ethereum Blockchain 
as their main knowledge base. But your browser can't just 
connect to the Ethereum blockchain.   To connect to the Ethereum Blockchain 
you need something called a wallet. Your Etherum wallet is your access 
portal to the Etherum network. It stores   your account on the Ethereum blockchain in the 
form of a private key. Everyone who has access to   that private key has access to your wallet which 
means access to all your data and your ether. There are a lot of different wallets out there,   but in order to interact with dApps 
one wallet is used a lot: MetaMask. MetaMask is a wallet that you can 
integrate into your web browser   via a plugin or download onto your 
phone and use the browser integrated   inside the MetaMask app to enable 
websites to interact with the blockchain.

This is used by dApps running 
inside of your browser to send   transactions into the blockchain 
or read data from the blockchain.   To interact with Ethereum with your own 
website there is a JavaScript library   called web3.js which can utilize MetaMask or 
any other wallet integrated into your browser. So a decentralized app is an app using some kind 
of wallet to connect to the Etherum network.   In which it has stored some smart 
contracts to run transactions,   store data, and read data from the blockchain. But there is a problem. Writing data into the 
blockchain is not for free. There is something   called a gas fee and for all memory-intensive 
calculations and for storing data inside the   blockchain the initiator of the transaction 
needs to pay the fee for the gas that is used. Gas fees raise with the amount of transactions 
being processed inside of the network.   So you can see here how the gas fees have 
risen over the last couple of years.

And   because there is a lot going on right now inside 
the network gas is really expensive these days. But that's a problem for future Daniel I guess. Next, I need to find out how I can develop 
smart contracts. I have no idea how the   development environment or a development 
cycle looks like for the blockchain. So what I found out is that smart contracts 
run on the EVM, the Ethereum Virtual Machine,   and are developed in a programming 
language called Solidity. Solidity   is an object-oriented programming 
language for writing smart contracts. Time to learn a new programming 
language. How hard can it be? There are different development environments 
for Solidity. But one that popped up over   and over again was Truffle.js a JavaScript 
development environment to build smart contracts.   And since I want to develop a web app that 
interacts with the blockchain later as well,   I figured that using JavaScript for 
everything would be a good idea. Another puzzle piece is Ganache. Ganache is a 
simulated Ethereum blockchain on your computer.   Ganache helps to test your smart contracts locally   without the need to deploy it to the 
Ethereum main net or one of it's test nets.

So the first thing I need to do is to 
install "truffle.js": npm install truffle The next thing is to initialize a 
new truffle project: truffle init. So I started Visual Studio Code here   and let's have a look at the initial 
content of an empty truffle project. The first folder you see is the contracts 
folder, you see a migrations.sol file which   is the first solidity file we see here.

After 
that, we have a migrations folder where we have   different migration scripts. As far as 
I understand it, the migrations contract   and the migration scripts work together in order 
to get our smart contracts onto the blockchain.   And we have a test folder which we can use 
to write unit tests for our smart contracts,   which will come in handy later I guess.

And 
then another file that's specific to this   truffle project is the truffle-config.js. As 
far as I understand it, it's used to connect   the project with the local blockchain and maybe 
later with other blockchains we want to deploy to. So the next thing we need is to install ganache,   our local blockchain to test our smart 
contracts. The easiest way to do this   is to use homebrew at least if you are 
on MacOS: brew install –cask ganache So the first time you start ganache it looks 
like this. To be honest I played around with   it a little bit before actually recording 
this part of the video. I learned that   creating a workspace and actually connecting it to 
your smart contract project, your truffle project,   is a smart way to do because this way you will 
keep the accounts on the blockchain static and   you don't need to reconnect your MetaMask 
to Ganache every time you start Ganache.

So we go "new workspace Ethereum", we give it a 
name, "add project", navigate to your truffle.js   folder, select the truffle-config.js, 
and click "open", "save workspace". Here you go, this is your private Ethereum 
blockchain on your machine. You see there are   10 different accounts on your blockchain, each 
of these accounts got a balance of 100 Ethereum. So next let's connect Ganache to MetaMask. So I 
have the MetaMask Google Chrome plugin installed   on my computer. As you can see here I'm connected 
to the Ethereum main net. So the first thing we   need to do is connect our MetaMask wallet to our 
local blockchain. In order to do that we click   here, select settings, go down to networks and 
click on "add network". We enter a network name,   we enter the new rpc url "http://localhost:7545",   the chain id is 1337, currency 
symbol is ETH, "save". Now my MetaMask wallet is connected to my Ganache 
blockchain. So the next thing we want to do   is to connect our MetaMask wallet to one of 
our accounts.

In the Ganache local blockchain.   To do that, we click on the key icon, we copy the 
private key, click on the avatar, import account,   and paste the private key here, click import, 
voila we have an account with 100 ETH. In order to show that this actually works 
let's send one Ethereum to the second account   on our local blockchain. So we need to copy 
the public address, "send", paste 1 ETH,   "next", "confirm". And here we go, we 
see that the balance of the first account   is reduced to 99 ETH and the balance 
of the second account is now 101 ETH.

That was day one. I learned a lot about 
the whole ETH ecosystem and I set up my   development environment. Tomorrow, I will 
implement my first ever smart contract.   If you want to follow my journey 
please, consider subscribing.   Thanks to all my patrons for helping running this 
channel and I see you in one of my other videos. As always have a lot of fun coders!.

As found on YouTube

Get in touch for your NFT project

What's your reaction?

Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0

You may also like