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


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!


All Comments

Recommended for you

  • Hong Kong and Macao police jointly arrested 4 people this week in connection with the JPEX case and seized or frozen 24 million Hong Kong dollars in assets.

    With regards to the JPEX virtual asset trading platform case, the Hong Kong police have received 2,417 reports, involving a total amount of over HKD 1.5 billion. Assistant Commissioner of Police, Chung Yung-min, stated that the Hong Kong police carried out a joint operation with the Macau Judiciary Police from Tuesday to Thursday this week, arresting four people and seizing or freezing HKD 24 million in assets, including casino accounts and a large amount of cash. She also said that the police are actively tracing the whereabouts of virtual assets, have identified other targets, but some have left Hong Kong. The police will work with international cooperation to arrest those involved. She pointed out that the JPEX fraud network is very large and complex, and the investigation is still in its early stages. Those involved still insist that it is a legitimate investment platform. She hopes that the public will be more cautious when making any decisions regarding JPEX. Chief Superintendent of the Cyber Security and Technology Crime Bureau, Cheng Lai-ki, said that the criminal group has destroyed many documents, making it difficult for the police to track the fraudulent funds and investigate. However, she emphasized that the police will continue to communicate with overseas trading platforms to trace the whereabouts of virtual assets. A total of HKD 5 million worth of encrypted currency assets have been frozen temporarily. 

  • Valkyrie Ethereum Futures ETF Receives U.S. SEC Approval

    The US SEC has approved Valkyrie to convert its existing Bitcoin futures ETF to a Bitcoin and Ethereum futures ETF. The new fund will be renamed "Valkyrie Bitcoin and Ethereum Strategy ETF" and will take effect on October 3, with the code still being BTF.

  • AlphaSense Raises $150M in Series E Funding Round Led by BOND and Alphabet's CapitalG

    AlphaSense, a B2B AI platform focused on business intelligence and search, has completed a successful Series E funding round, raising $150 million. The round was led by BOND and included investments from Alphabet's CapitalG, Goldman Sachs, and Viking Global. AlphaSense's valuation has grown from $1.7 billion to $2.5 billion since its Series D funding round in June 2023. The platform uses machine learning to provide deep insights into business and finance analytics, offering "insights-as-a-service." The latest investment will allow AlphaSense to continue leading the generative AI revolution in the B2B sector.

  • web3 startup IYK raises $16.8 million in seed funding, led by A16z Crypto

    Web3 startup IYK has raised $16.8 million in seed funding, with A16z Crypto leading the way and other investors including 1kx, Collabcurrency, Lattice Capital, and gmoney. According to its website, IYK is a participant in the a16z Crypto Startup School, which is an accelerator program from the venture capital giant that typically invests $500,000 in participating startups in exchange for 7% equity. IYK says that it has recruited over 100 creators from industries such as fashion, music, and art since its founding in 2021. To attract more brands and creators, it is launching a self-service platform to help create digital physical experiences.

  • Oracle project Supra completed over US$24 million in financing, with participation from Animoca Brands and Coinbase Ventures.

    On September 28th, Supra, a provider of oracle and VRF services, announced that it had completed a funding round of over $24 million. Investors in this round include Animoca Brands, BCW, Coinbase Ventures, FiveT Fintech (formerly Avaloq Ventures), Galaxy Interactive, Hashed, HashKey, Huobi Ventures, No Limit Holdings, Prosus Ventures,, Republic Crypto, Shima Capital, Signum Capital, SMO Capital, Sound Ventures, Sublime Ventures, UOB Venture Management (Dahua Bank), and Valor Equity Partners.

  • Hong Kong police arrested three people again in connection with the JPEX case, bringing the total number of arrests to 15

    Hong Kong police arrested three more people related to the JPEX case, including one director and one employee of the overseas exchange Lupin, and one popular analyst from a foreign currency exchange shop. The total number of arrests is now 15. The police have received a total of 2,392 reports, involving a total amount of nearly 1.5 billion yuan, and have frozen 77 million yuan in assets. 

  • The EU will collect data proving that cryptocurrency PoW mechanisms "seriously" harm the environment and plans to develop sustainability standards

    On September 28th, the European Commission released a tender contract worth 800,000 euros (approximately $842,000) aimed at mitigating the "significant harm" that cryptocurrency poses to the environment. The research, which will end on November 10th, will establish standards that will be incorporated into potential future EU policies to curb the impact of cryptocurrency on climate change and develop new energy efficiency labels for blockchain. The European Commission stated in the tender document that "there is evidence that crypto-assets can cause significant damage to the climate and the environment," which could undermine the EU's greenhouse gas reduction targets, indicating that new sustainable development standards may be adopted in the future. EU legislators are concerned about the energy-intensive PoW consensus mechanism that supports blockchain such as Bitcoin. The EU's research will be completed within a year and will study green issues related to the use of water, waste, natural resources, and energy by cryptocurrencies. (CoinDesk)

  • Brazil’s cryptocurrency trading volume in July was US$3.7 billion, with USDT trading accounting for 81.6%

    According to data from the Federal Tax Authority, cryptocurrency transactions in Brazil reached 18.8 billion Brazilian real (approximately 3.7 billion US dollars) in July, a decrease of 11.4% compared to the previous month. The three highest transaction volumes were stablecoins, with USDT accounting for 15.3 billion Brazilian real, or 81.6% of the total transaction volume, followed by USDC (838 million Brazilian real) and Brazilian real stablecoin BRZ (641 million Brazilian real). 

  • The National Blockchain Industry Industry-Education Integration Community was established in Xiongan New Area

    National Blockchain Industry Production-Education Integration Community Establishment Conference was held in Xiong'an New Area on September 27. The National Blockchain Industry Production-Education Integration Community is jointly formed by Xiong'an Guochuang Center Technology Co., Ltd., Southwest University of Finance and Economics, Hebei Software Vocational and Technical College, and other units under the guidance of the Vocational and Adult Education Department of the Ministry of Education, the Education and Examination Center of the Ministry of Industry and Information Technology, and the China Association of Small and Medium Enterprises, together with relevant industry associations, enterprises, undergraduate colleges, vocational colleges, scientific research institutes and other units. The establishment of the National Blockchain Industry Production-Education Integration Community aims to gather high-quality production-education resources and establish a new type of production-education integration organization to support the development of the blockchain industry, promote industrial development and talent cultivation, effectively promote the deep integration of industry and education, improve the quality of talent cultivation, better meet the development needs of the blockchain industry, and effectively promote economic and social development.

  • Slope, a Fintech Startup Backed by the Founder of Worldcoin, Completed $30 Million in Financing

    Slope, a financial technology startup supported by Worldcoin founder Sam Altman, announced the completion of a $30 million financing round, with participation from Y Combinator, monashees, and a group of angel investors in the financial technology field. It is reported that Sam Altman and Union Square Ventures jointly led Slope's previous $24 million Series A financing round. So far, the company's total financing amount has reached $187 million.