Skip to content

Instantly share code, notes, and snippets.

@SantoshCode
Last active December 13, 2021 14:15
Show Gist options
  • Save SantoshCode/31910fa699740616caa144441b940ed6 to your computer and use it in GitHub Desktop.
Save SantoshCode/31910fa699740616caa144441b940ed6 to your computer and use it in GitHub Desktop.

NFT (Non Fungible Tokens)

WHAT ARE NFTS ?

Thought definition.

A way to represent anything unique as a Blockchain-based asset. Powered by smart contracts by smart contracts on a Blockchain. NFT can really be anything digital (such as drawings, music, your brain downloaded and turned into an AI). NFTs are popular in representing digital arts. But digital arts is only one way to use NFTs. Really they can be used to represent ownership of any unique asset, like a deed for an item in the digital or physical realm.

Formal definition (Technical Definition).

NFT is a unique and non-interchangeable unit of data stored on a digital ledger . NFT stands for non-fungible token. Non-fungible is an economic term that you could use to describle thing like your furniture, a song file, or your computer. These things are not interchangeable for other items because they have unique properties.

Ofcourse we can exchange sofa with a chair with someone but when we exchange sofa with a chair then we wouldn't have sofa with us.

Example of a interchangeable/fungible thing is money exchange. We can exchange $10 bill with ten $1 bill. After the exchange we would have $10 in value.

Example of Non Fungible is we cannot exchange a paint with another paint. They both have different values.

Simply,

Fungible

Exchange items with same values. like exchaging identical item, exchanging same amount of money.

Non-Fungible

We cannot exchange items. Because these items would have different values. like exchanging painting of an artist.

The Ethereum Virtual Machine

Ethereum is a decentralized platform that runs smart contracts, applications that run exactly as programmed without possibility of downtime, censorship, fraud or third party interference.

To run smart contracts we need to deploy it to EVM. Purpose of EVM is to run bytecode of smart contracts. EVM is not a software we download and run it. EVM is a part of ethereum protocol. Most popular is geft which is a Go implementation of ethereum protocol which runs EVM. We can run geft in our machine and when we run geft we also run EVM. When we run geft we are now part of ethereum network.

Smart contracts

Smart contracts are written in a programmging language called Solidity. Smart contracts is simply a program that runs on the Ethereum blockchain. It's a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.

Here code consists of the terms and agreements that build our NFT's.

Smart contracts are a type of Ethereum account. This means they have a balance and they can send transactions over the network. However they're not controlled by a user, instead they are deployed to the network and run as programmed. User accounts can then interact with a smart contract by submitting transactions that execute a function defined on the smart contract. Smart contracts can define rules, like a regular contract, and automatically enforce them via the code. Smart contracts cannot be deleted by default, and interactions with them are irreversible.

Contract Storage.

The Ethereum VM is a stack-based, big-endian VM with a word size of 256-bits and is used to run the smart contracts on the Ethereum blockchain.

Under the hood, the EVM uses a set of instructions (called opcodes) to execute specific tasks. There are over 100 opcodes. This means the EVM is able to compute (almost) anything, given enough resources. Because opcodes are 1 byte, there can only be a maximum of 256 (16^2) opcodes.

Lower-level programming languages often use a stack to pass values to functions. The EVM uses a 256-bit register stack from which most recent 16 items can be accessed or manipulated at once. In total, the stack can only hold 1024 items.

Because of these limitations, complicated opcodes instead use contract memory to retrieve or pass data. Contract storage essentially acts as a public database, from which values can be read externally without having to send a transaction to the contract (no fees!). However, writing to storage is very expensive (as much as 6000x) compared to writing to memory.

Summarized

Smart contracts language like solidity cannot be executed by the EVM directly. Instead, they are compiled to low-level machine instruction (called opcodes).

Smart contracts interact with the EVM which is more expensive than running programs on traditional servers however provide for a more decentralized approach to developing Applications.

What is ERC721 Standard?

An ERC standard is basically a set of rules which enables your contract play to well with other developers' contracts (or Marketplaces, DApps, other software, etc)

ERC20 is for crypto currencies.

ERC20 token is fungible , whereas the ERC721 are nonfungible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment