Tezos: Create an NFT on the Tezos Network using IPFS on Filebase
Learn how to create an NFT on Tezos with IPFS on Filebase.
Last updated
Learn how to create an NFT on Tezos with IPFS on Filebase.
Last updated
Tezos is an open source, decentralized blockchain network that serves as a platform for executing peer-to-peer transactions and deploying smart contracts.
This tutorial uses a pre-compiled FA2 NFT contract that uses a command line interface to originate and interact with the NFT contracts. FA2 is a token standard (TZIP-12) on the Tezos network. FA2 provides an API standard for token transfers, balance inquiries, and managing token metadata.
To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.
Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.
Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.
Once uploaded, it will be listed in the bucket.
Choose the method you prefer, and take note of the IPFS CID.
mkdir nft-tutorial
cd nft-tutorial
@oxheadalpha/tznft
npm package:npm install -g https://github.com/@oxheadalpha/nft-tutorial.git
tznft init
The value returned should be ‘sandbox’:
tznft show-network
tznft bootstrap
If this is the first time you are bootstrapping the sandbox network, Docker will automatically download the Flextesa docker image for use in the project.
tznft mint <owner_alias> --tokens <token_meta_list>
Tznft comes with 2 default accounts for use - ‘bob’ and ‘alice’. For example, to mint an NFT called ‘Filebase Robot’ that is owned by the default account ‘bob’, you would use this command:
tznft mint bob --tokens '0, T1, Filebase Robot'
This command will return the NFT contract’s token ID. Take note of this for the next step.
tznft show-meta --nft <nft_address> --signer <alias> --tokens <token_id_list>
For example, to view the NFT contract for the contract created in the last step, the command would be:
tznft show-meta --nft E6S9t44fKR9Uo5KT1XP3RrAfqHvHXu9Cy7fh --signer bob --tokens 0 1
tznft show-balance --nft <nft_address> --signer <alias> --owner <alias> --tokens <token_id_list>
For example, to view the balance of the NFT we just created for the account bob, we can use the command:
tznft show-balance --nft E6S9t44fKR9Uo5KT1XP3RrAfqHvHXu9Cy7fh --signer bob --owner bob --tokens 0
The output should resemble the following:
querying NFT contract E6S9t44fKR9Uo5KT1XP3RrAfqHvHXu9Cy7fh using balance inspector H1ytG7saMZ34sfdKT1Pezr7JjgmrPcPhpkbk
requested NFT balances:
owner: tSZAXWvGsGwVJqUtz1YPSCGWXwBdTncK2aCc token: 0 balance: 1
To use the IPFS CID, we’ll add a fourth parameter to our token mint command:
tznft mint bob -t '0, Filebase, Filebase Robot, A44RPciW5pM4iyqRGQmRyTc9KbD7ZSkmEf4e7fk6rhbyvj'
Then, we can inspect the new token’s metadata to see the IPFS CID listed:
tznft show-meta -s bob --nft 3w1x23oiC31B8KT1SgzbcfTtdHRV8qHNG3hd --tokens 0
Which will return the following output:
token_id: 0 symbol: Filebase name: Filebase Robot extras: { ipfs_cid=A44RPciW5pM4iyqRGQmRyTc9KbD7ZSkmEf4e7fk6rhbyvj }
You can view the IPFS File by using the Filebase IPFS Gateway with the IPFS CID. For example, to view this image, you can go to:
https://ipfs.filebase.io/ipfs/A44RPciW5pM4iyqRGQmRyTc9KbD7ZSkmEf4e7fk6rhbyvj
You can connect to different Tezos networks by using the command:
Tznft set-network [network-name]
From here, you can create and mint NFTs right from the command line on any of the Tezos networks.