Cointime

Download App
iOS & Android

How To Make Your Own NFTs On Flow

Written by: Nicholas Cantone, Agile Software Engineer, TribalScale

With blockchain technologies gaining immense popularity in recent years, it’s likely you’ve heard the buzz about non fungible tokens, or NFTs. Unfortunately, the inner workings of NFTs seem to be hidden behind a veil of complex blockchain concepts filled with technical jargon. Luckily for you, by the end of this blog post you will have gained a much deeper understanding of how these NFTs are made.

Today, we will be diving into NFTs on the Flow blockchain. If you aren’t familiar with blockchain technologies here is a good article by the verge to get you started. In brief, Flow was created in 2020 by Dapper Labs to meet their own growing demands for an efficient platform to host their immensely popular blockchain-based game, CryptoKitties. The language we use to interact with the Flow blockchain is called Cadence. The following section of this blog will explain key cadence concepts and the final portion will bring all those concepts together and show you how to make your very own NFT from scratch.

Cadence Concepts

Resources

Cadence is a resource-oriented programming language meaning that resources play a huge part in any Flow project. But what are they and why are they so great?

Well… resources are a type in cadence, but you can think of them as a highly secure and unique container for information (similarly to objects in javascript or structures in C). These resources have fields or functions associated with them, like in the code example below:

What makes resources so secure is the restrictions that are placed on them. (if you don’t believe me, check out the docs) “[Resources] can only exist in one location at a time and must be used exactly once”, therefore, resources are unique (kind of like NFTs) and can’t ever be created and unused or go out of scope and be lost forever.

The way we use resources is by either moving them, or destroying them. You can see how these restrictions are so useful in the context of NFTs. For instance, if I create an NFT resource, I can’t lose track of it. I have to transfer it into another user’s account, save it into mine, or explicitly destroy it. Here is a small code excerpt that highlights the creation and moving of resources in a function:

Smart Contracts

Moving on to one of the most important tools in any blockchain developers tool shed, smart contracts. They’re essentially like recipes. Much like recipes they are divided into their state (list of ingredients) and logic (cooking steps). The state of the contract lives in the blockchain and can be thought of as the attributes of our contract. The state of our contract will also hold any type definitions (such as resources). The logic portion of the contract consists of functions which simply tell you how to view or modify the state.

If you’re wondering how you can deploy your very own contract to the Flow blockchain, the first step would be to create an account.

Your account is basically your little storage allocation of the blockchain. In your account, you can store all your contracts along with any other resource, in the final section of this blog we’ll explore how resources are saved to storage and made publicly accessible. Your account will have an address associated with it which will be extremely important for accessing items in your storage. Think of your home address, it would be really hard to order from Amazon if you forgot your postal code or your street number.

Here is a link to get you started (you’ll also need the flow cli installed).

Transactions and Scripts

The only way you can interact with your contract (or any data on the blockchain for that matter) is through scripts or transactions and the conceptual difference between the two is quite simple. Scripts can only read from the blockchain, whereas transactions can read and modify data from the blockchain.

Common scripts would be used to get the metadata of an NFT, get a list of all the current owners of your NFTs or to get a list of the past owners. Common transactions could be to mint an NFT, setup a consumer’s account or transfer ownership of an NFT.

While the transactions and scripts you write are the ones doing all the heavy lifting, they are always implementing contracts. For instance, the act of minting an NFT through a transaction will always require the use of functions (such as createToken) that you define in your contract.

One last point that I will mention is that since transactions are modifying data on the blockchain there is a ‘gas fee’. Therefore every time the transaction is executed the person who executed it must pay a small fee. However there is a test environment that exists on Flow for development purposes.

Making an NFT

FLOW NFT standard

To make your own NFT all you need is a contract with a few special attributes. To make sure there isn’t any confusion, Flow created a contract that defines a standard that all non fungible tokens must meet. These standards are implemented using interfaces, click here to learn more. For your contract to be up to Flow’s standards it needs the following.

Your contract must have

  1. A NFT resource (and a function to create one createToken)

The NFT resource that your contract must contain has fairly few required attributes. As long as your NFT resource has an ‘id’ field it is good to go!

(code from flow’s NonFungibleToken.cdc contract)


2. A collection resource (and a function to create one createEmptyCollection)

The collection on the other hand is a little more complex. As we know, resources are unique, however, this poses a problem to users who would like to own more than one of our NFTs. Flow’s solution is the Collection resource. A collection, is simply a container built to store multiples of our NFT resource (every NFT has their own unique collection so we must define ours!).

Our collection resource must have an ownedNFTs field which stores a list of all the NFTs being stored in that collection. A withdraw function which allows us to remove NFTs from the collection. A deposit function which lets us add an NFT into the collection. A getIDs function which returns a list of all the IDs of the NFTs in the collection. Last but certainly not least, there must be a borrowNFT function which takes in an ID and returns the NFT which posses that ID.

(code from flow’s NonFungibleToken.cdc contract)


3. A publicCollection resource interface.

Lastly, we must have a publicCollection resource interface. Interfaces are a more complicated topic so I’ll give more of a conceptual overview of what this resource accomplishes. In sum, a resource interface is a restricted version of a resource. Our publicCollection will be a version of our collection that anyone will be able to access, so we want to remove some functionality to make sure that someone can’t just withdraw all of your NFTs.

Our publicCollection will restrict our Collection to 3 functions, deposit, getIDs and borrowNFT. As a clarification, borrowNFT only returns a reference to the NFT so don’t worry about someone borrowing your favourite NFT and messing it up.

(code from flow’s NonFungibleToken.cdc contract)


Finally, with these resources and resource interface your contract will be up to the Flow NFT standards! If you want to have some Metadata associated with your token make sure to view this contract to see how you can give your token some standardized Metadata which will allow you to post it on a marketplace and make some royalties!

Mint transaction

To mint a NFT there are a few steps, as we now know NFTs need to reside in a collection, but where do these collections reside? Well, if you recall the ‘Smart Contracts’ portion of this post, I mentioned that accounts are essentially storage, therefore step 1 of minting an NFT is to save an empty collection to our storage using our createEmptyCollection function.

In the following code excerpts I’ll be using ‘MyNFT’ as a placeholder for the name of an NFT contract:

The step 2 was foreshadowed in the previous section, we must link a publicCollection to a public section of our storage (paths beginning with /public are public and /storage are private).

Step 3 is to borrow the collection we just created.

Finally, we create an NFT using our createToken function and deposit it into our collection using our deposit function that we defined in our Collection resource.

And with that our minting transaction is complete. Hopefully you have gained a good conceptual understanding of the NFT creation process through this post and if ever you want to explore the world of NFTs on the flow blockchain there is no better time to start than the present! Even as a developer I found the world of NFTs very intimidating at first but once you get started you’ll be amazed at what you can do!

NFT
Comments

All Comments

Recommended for you

  • Ethereum Foundation Sells 2,785 ETH Worth Approximately $6.42 Million

    On October 26, according to monitoring by Onchain Lens, the Ethereum Foundation sold 2,785 ETH through CoW Swap for approximately $6.42 million in exchange for USDS.

  • Qatari Mediators Arrive in Tehran to Alleviate Regional Tensions

    According to an official familiar with the situation, Qatari mediators arrived in Tehran on Sunday with the aim of easing regional tensions. Qatar's mediation efforts are being conducted in coordination with the United States.

  • Musk: Future Phones Will Have No Apps or Operating Systems, Just AI Generation

    On October 25, Musk predicted that in the next 5 to 6 years, smartphones may undergo a complete transformation: traditional operating systems and apps will gradually disappear, and phones will become dedicated terminals for running AI. At that time, users will no longer need to download applications or open software; instead, they will simply tell the AI what they want, and the phone's AI will collaborate with cloud AI to generate videos, images, and various interactive content in real-time.

  • Iran: Tehran's Stance Unchanged Despite Potential New U.S. Strikes

    On October 25, Iranian Foreign Minister Zarif stated on Sunday that Iran's position will not change even if a new round of conflict erupts between Israel and the United States. This comes amid escalating tensions between Tehran and Washington. U.S. President Trump had mentioned on Friday that Washington "might come back for another small-scale 'epic fury'" military operation. Zarif remarked, "Recently, some have talked about the possibility of a new war, but I am already considering the post-war situation. Our policies will not change whether or not war occurs. They have tried twice before and have seen the results. If they want to try again, they should understand that the final outcome will be no different from the past." (Golden Ten)

  • Russia Ready to Supply Any Amount of Diesel to the U.S.

    On October 25, Russian Deputy Prime Minister Novak stated that Russia is prepared to supply any amount of diesel to the United States.

  • Egypt's Benchmark Stock Index Declines by 5%

    Egypt's benchmark stock index has expanded its decline to 5%.

  • Yemen Conflict Escalates, Saudi and Egyptian Stock Markets Decline

    On October 25, Sunday, the stock markets in Saudi Arabia and Egypt experienced declines. This followed a statement from the Saudi-led coalition indicating that, amid escalating conflicts with the Yemeni Houthi forces, the coalition intercepted several drones and missiles over Riyadh and southern Saudi Arabia. Under pressure from widespread sell-offs, the Saudi benchmark index (TASI) fell by 2.6%, marking its worst intraday performance since April 2025, with major stock Saudi Aramco dropping by 1.1%. Outside the Gulf region, the Egyptian blue-chip index (EGX30) plummeted by 2.5%, nearing its lowest level in about seven months, with all constituent stocks declining. The Egyptian parliament is expected to vote on October 26 to decide whether to authorize the armed forces to provide support for Saudi Arabia in its conflict with the Houthi forces upon request.

  • SemiAnalysis CEO: Substrates are the 'Biggest Bottleneck'

    On October 25, the CEO of SemiAnalysis stated: 'I believe that in the semiconductor industry, the biggest limiting factor, aside from memory, is substrates. Substrates, PCB materials, and substrate materials are all severely under-invested. Many companies in the supply chain that produce these materials in Japan are relatively conservative and unwilling to make significant investments in capacity. As a result, there is a huge bottleneck. In terms of what can be produced in the next two years, whether it’s accelerators, CPUs, or any other component in the supply chain, I believe substrates are the biggest bottleneck.'

  • Keystone Hardware Wallet Website Hacked, Customer Information Leaked

    On October 25, Hong Kong-based self-custody hardware wallet brand Keystone, known for its full isolation and QR code signing, disclosed that its official website was unauthorizedly accessed on October 20, exposing customer names, contact information, shipping addresses, and order details (including purchased products and prices). The company confirmed on October 23, after verifying API activity with Shopify, that a third party obtained customer shipping information. Keystone emphasized that payment card and bank information, mnemonic phrases, private keys, and wallet passwords were not leaked. The company has blocked access, patched vulnerabilities, initiated an investigation, and notified affected customers via email, warning that scammers may impersonate Keystone to deceive customers under the pretext of refunds or device exchanges. Customers are advised not to click on suspicious links and not to disclose mnemonic phrases and private keys, with plans to release a detailed report within a few days. Other companies in the industry, such as Trezor (which experienced a leak from logistics provider ShipMonk in August) and Ledger (which had a security incident this month involving modified devices stealing mnemonic phrases), have also faced security issues.

  • Goldman Sachs Lowers 12-Month Target for South Korea's KOSPI Index by 25%

    On October 25, strategists at Goldman Sachs Group lowered their target for South Korea's KOSPI index by 25%. Previously, they had raised the target multiple times this year, but with increasing market concerns over AI-related trades, they have now opted for a downgrade. Led by analyst Timothy Moe, the team reduced the 12-month target for the KOSPI index from 12,000 points to 9,000 points. They noted that, given the benchmark index has fallen more than 35% from its peak in June, valuation assumptions need to become more cautious. These strategists believe that the current sell-off has left the South Korean stock market significantly undervalued; even after the target downgrade, the index still has over 60% upside potential.