Cointime

Download App
iOS & Android

NFTs, Explained by A Software Developer

What you need to know (as a developer) to create an NFT

In this article, you will understand what an NFT is and how we developers can create one ( or maybe 10,000).

An NFT is a transaction recorded on a blockchain that attests the ownership of a unique object, linked via metadata to some assets, usually images or video.

Okay, this definition is so general that it doesn’t explain anything when you read it like this.

Let’s take a step back and start with the basics.

What does fungible mean?

Imagine you are at the supermarket, and you get a coupon or stamp for every $30 you spend. You are a loyal customer and have 20 half-dollar coupons.

Now imagine that as you rush out the doors with your coupons in hand, a middle-aged lady bumps into you, and your 20 coupons fall out, mingling with the lady’s ones.

No big deal, you know you had 20, and the lady know she had 10. You pick them up off the ground and share them. Each one is fine.

If we think of coupons as tokens, they are fungible: you can exchange them for each other. Each has the same value and characteristics as the other.

If you dropped your house keys instead of coupons, that was different.

Although visually similar, each key differs from the other, and you could not interchange them with the lady. If we think of keys as tokens, these are non-fungible tokens.

NFTs on the blockchain

Now that we know what non-fungible means, let’s figure out how to connect these tokens to the blockchain.

The good news is that it is optional to know in detail how a blockchain works to develop an NFT. We need to know some basic information. Let’s see it.

The first blockchain — Bitcoin — was born in 2008 by Satoshi Nakamoto: however, the subsequent implementations are all based on some standard features.

The blockchain (at its base) is a distributed data ledger, i.e., we can imagine it as a database or data storage in which transactions, i.e., changes in the state of the blockchain, are written.

Its fundamental characteristic is that it is not a single, centralized data source. Still, it is distributed in a peer-to-peer network, where each computer (called a node) has a copy of the entire ledger.

The addition of data is done through consensus mechanisms because most of the network nodes validate the transaction.

The essential characteristics of the blockchain are:

it is distributed (precisely because it is decentralized).

it is transparent (because the ledger is public and open).

it is trustless (that is, it has no central authority or intermediaries that users must rely on, but anyone can operate directly on the network)

it is incorruptible (the data written on the blockchain is permanent and immutable)

it is secure (because it relies on mechanisms that ensure that data are validated, using asymmetric key cryptography and various hashing systems)

A key feature that gives the technology its name is the way the data are stored: they are grouped in a block structure concatenated together in chronological order.

Writing data to the blockchain is done by generating a new block containing a certain number of records (named transactions).

The current block’s hash is calculated, then inserted as a reference within the next block, thus concatenating the two blocks. As new blocks are added, the chain grows.

Getting closer to NFTs

In the Bitcoin blockchain, transactions essentially contain currency transfers from one account to another. Still, in 2015, thanks to the work of Vitalik Buterin, Ethereum was born.

This new blockchain allows code to run on it. This code, these programs that run on the blockchain, are called smart contracts.

Each node on the Ethereum network implements a system called the Ethereum Virtual Machine (EVM), a virtual machine capable of executing smart contracts code, using the local copy of the blockchain to read and write information, and possibly interacting with other smart contracts.

Finally, NFTs

NFTs are a particular type of smart contract that implement a specific standard. This standard is ERC-721, which defines an interface to be implemented by the smart contract.

This interface has functions for determining the ownership of an NFT and functions for transferring it.

Then there are functions to obtain the name and symbol of the NFT.

An essential function is tokenURI, which defines a URI for each of the tokens managed by the contract.

This URI must point to a JSON file with a structure like the one defined in the figure. The standard defines the first three fields. The attributes are an extension added by the OpenSea marketplace and then became very common.

The image attribute points to the actual image.

Creating NFTs

Typically, users interact with a smart contract through a dApp (decentralized application), which interacts with the smart contracts deployed on the blockchain.

Usually, the dApp takes care of getting the user connected through its wallet. At this point, it allows the user to perform minting, that is: generating a new NFT from the smart contract.

The contract will write a transaction on the blockchain, generating a new token with its associated token id.

This token id is used to retrieve the metadata and image (usually previously uploaded to a distributed filesystem, e.g., IPFS) to show the image of the newly acquired NFT to the user.

At this point, we can write the initial definition again, which I hope has become more evident:

An NFT is a transaction recorded on a blockchain that attests the ownership of a unique object, linked via metadata to resources, usually images or video.

Yes, but in practice?

To develop the smart contract code, you use an adequate programming language, Solidity is one of them.

The ERC-721 interface has already been implemented for us by Openzeppelin, a company that has written many open-source smart contracts.

Some frameworks and tools help us develop the smart contract of an NFT, test it, deploy it on the blockchain, interact with the deployed contract, and finally create a dApp for users to interact with it.

Truffle and Hardhat are two of the most popular of these tools.

To develop an NFT, you should follow these steps:

Generate the assets (images, video, audio, etc.) and upload them online. Preferably on a distributed file system such as IPFS.

Copy the URI of the assets.

Develop the smart contract that implements ERC-721. You can use Openzeppelin’s ERC-721 basic smart contract to make your life easier.

Write tests on the newly developed smart contract. Once on the blockchain, the smart contract is not editable: our bugs will remain on the blockchain forever.

Deploy the smart contract on a test network. Yes, testing environments exist in the blockchain as well, fortunately.

Run tests of mint and other transactions on a test network.

Deploy the smart contract on a production network. This step requires hooking into a node on the blockchain.

Optional but recommended: develop a dApp to allow users to create NFTs (usually paying a fee).

Bonus: deploy the contract on the blockchain

Connecting to a blockchain node is a challenging task.

But first, let’s see how a node works. Each blockchain node consists of essential parts:

the blockchain data

the EVM (Ethereum Virtual Machine) to execute smart contracts

JSON-RPC APIs that the node exposes to allow users and other nodes to communicate with it.

When a user wants to interact with the blockchain, he must connect to a node, and he does so by calling the APIs that each node exposes.

To do so, he needs to know the Internet address of this API.

Moreover, these APIs are not the classic REST APIs we are used to using every day but are “slightly” more complex. For two reasons:

1. the content of the messages, which follow a standard, are encoded in hexadecimal

2. You must sign most of the messages with your private key.

You should use a ready-made library to implement calls to a blockchain node. There are some for almost every language.

But that’s not the end of the story. It gets even more complicated, the nodes may need to be in perfect sync with the rest of the blockchain, or it may be turned off or become unreachable just as it handles one of our transactions.

How do we solve this problem?

Fortunately, there are so-called providers, i.e., services that expose the same API as the blockchain nodes but are more reliable and dedicated to these operations. The most famous providers are certainly Infura and Alchemy.

So, when you want to deploy the NFT’s smart contract on the blockchain, you must connect to a provider and perform a “special” contract creation transaction.

When the contract gets deployed on the blockchain, it assigns an address to it.

The blockchain contract address is unique and must be used to execute the various transactions that the smart contract exposes: for example, the mint or transfer of an NFT.

Closing up

We have given an overview of what it takes to create an NFT. We have barely scratched the surface of this world, and in this article, there was no way to get into the depths of development details, but stay tuned. I will post more implementation-specific material as soon as possible.

In the meantime, if you want to learn how to develop an NFT or smart contract, feel free to contact me.

Thanks, and until next time

NFT
Comments

All Comments

Recommended for you

  • U.S. Senate Passes Resolution Aiming to Limit Trump's War Powers Against Iran

    On June 24, the U.S. Senate passed a resolution regarding war powers related to Iran, with 50 votes in favor and 48 against, following a similar approval by the House of Representatives. This marks the first time such a resolution has been approved by both chambers of Congress. The resolution calls for the president to end military actions against Iran without a declaration of war or authorization of force from Congress. However, since this resolution is a joint resolution of Congress, it is not legally binding and does not require the president's signature, thus serving mainly a symbolic purpose.

  • AI Smart Terminals Experience Full Explosion

    On June 23, according to CCTV Finance, at the fourth Chain Expo, the original "Digital Technology Chain" was upgraded to the "Smart Technology Chain." This change in wording reflects that artificial intelligence is becoming the main character in the industrial chain. A newly established AI zone at the event gathered leading AI companies from both domestic and international markets, showcasing the entire chain from data and computing power to applications. Various AI products were on display, including AI glasses, smart cars with digital chassis, and humanoid robots that can play soccer. CCTV Finance reporters observed that the integration of artificial intelligence into the physical world is transitioning from mobile phones and computers to various new smart terminals. This year, the application of AI agents has also experienced a full explosion. Qian Kun, Senior Vice President of Qualcomm, stated that the empowerment of AI agents is leading to a significant upgrade cycle for existing terminal devices. China's industrial chain is very complete, and through continuous collaboration with Chinese partners, their products can quickly reach the market and gain global acceptance. Liu Xiangwen, Vice President of Alibaba Cloud Intelligence Group, noted that AI has evolved from mere chatting to becoming a productive force. The development of all stacks, whether GPU cloud or CPU, is progressing rapidly, and there is still greater potential ahead.

  • U.S. Stock Indices Experience Short-Term Rally

    On June 23, the Dow Jones Industrial Average rose by 0.07%; the S&P 500 index narrowed its decline to 0.77%, having previously fallen over 1.5%; the Nasdaq Composite index also reduced its drop to 1.17%, after having been down more than 2.3% at one point.

  • Vitalik: Ethereum Foundation Budget Cut by 40%, Shifting to Long-term Fund Model

    On June 23, Vitalik Buterin revealed that the Ethereum Foundation (EF) will reduce its budget by approximately 40% this year. According to its previously announced financial management plan, EF is transitioning from a model where it spends about 15% of its remaining funds annually to a model where it will spend about 5% annually after 2030, moving towards a long-term donation-oriented organization. To this end, EF will adjust its multi-client model, relying more on AI-assisted formal verification. The PSE privacy and scalability exploration team will shift from 'exploration' to a focus on building around zero-knowledge proofs. The scale and losses of Devcon events will be reduced, and large projects beyond Ethereum itself will also decrease. EF's institutional work will focus on smaller-scale, replicable CROPS-friendly deployment cases.

  • Huo Qigang: In the AI Era, Our Own Judgment is Key

    On June 23, according to CCTV Finance, Huo Qigang stated that over the past year, the topic of AI has been overwhelming, shifting from 'not using AI' to 'having to use AI,' making him acutely aware that 'not participating will lead to elimination.' As a father, Huo Qigang candidly expressed the dilemma of whether parents should 'control' or 'assist' when their children use AI. He mentioned that he has already begun to assist with AI in his work, but emphasized that using AI does not mean bypassing the thinking process; one must rely on their own experience, thought, and logical judgment, and cannot simply replicate AI outputs.

  • NVIDIA's Market Value Falls Below $500 Billion

    On June 23, NVIDIA (NVDA.O) saw its market value drop below $500 billion, with a latest decline of 2.6%.

  • U.S. Manufacturing Activity Surges Beyond Expectations, But Factory Employment Falls to Six-Year Low

    Driven by companies placing orders in advance to prevent shortages and price increases, U.S. manufacturing activity expanded again in June. However, factory employment fell to a six-year low, primarily due to rising operational costs influenced by conflicts in the Middle East. The preliminary S&P Global Manufacturing PMI for June rose to 55.7 from 55.1 in May, marking the highest level since May 2022, while economists surveyed by Reuters had previously expected the index to drop to 54.8. The increase in the manufacturing PMI, combined with a rise in the services PMI from 50.7 in May to 51.3, contributed to a composite PMI output index increase from 51.5 last month to 52.2. The rebound in the services PMI is partially attributed to the World Cup events jointly hosted by the U.S., Canada, and Mexico.

  • Microsoft Completes Data Center Construction in Wisconsin

    Microsoft (MSFT.O) announced the completion of its first data center construction in Mount Pleasant, Wisconsin, USA.

  • Goldman Sachs: Brazilian Central Bank Expected to Alternate Between Rate Cuts and Holding Steady

    On June 23, Goldman Sachs' Alberto Ramos stated that the Brazilian Central Bank may alternate between pausing rate cuts and lowering its benchmark Selic rate. Last week, the Brazilian Central Bank reduced the Selic rate from 14.5% to 14.25%, and its next steps remain unclear. Amid sticky inflation and risks of economic slowdown, the meeting minutes provided some insight into the central bank's thinking. Ramos noted that intermittent rate cuts 'will lead to milder output fluctuations, with inflation converging to target levels by the first quarter of 2028.' He added, 'Overall, in the short-term trade-off between growth and inflation, Copom is more inclined to protect economic activity rather than adopt a more aggressive inflation-focused strategy.'

  • U.S. Treasury Department: U.S. Issues Sanctions Related to Cuba

    U.S. Treasury Department: The United States has issued sanctions related to Cuba.