{"id":14992055,"url":"https://github.com/near-examples/nft-tutorial","last_synced_at":"2025-09-25T14:30:44.442Z","repository":{"id":37500059,"uuid":"435632806","full_name":"near-examples/nft-tutorial","owner":"near-examples","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-30T14:43:44.000Z","size":1945,"stargazers_count":97,"open_issues_count":2,"forks_count":94,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-12-30T15:31:03.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/near-examples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-06T20:09:04.000Z","updated_at":"2024-08-12T20:18:37.000Z","dependencies_parsed_at":"2024-04-30T15:42:37.376Z","dependency_job_id":"05646d92-4cfe-4517-afc3-df1884a7984a","html_url":"https://github.com/near-examples/nft-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near-examples%2Fnft-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near-examples%2Fnft-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near-examples%2Fnft-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near-examples%2Fnft-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/near-examples","download_url":"https://codeload.github.com/near-examples/nft-tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234200162,"owners_count":18795139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T15:00:42.447Z","updated_at":"2025-09-25T14:30:44.436Z","avatar_url":"https://github.com/near-examples.png","language":"Rust","funding_links":[],"categories":["Web3 and ZKP Framework"],"sub_categories":[],"readme":"# NEAR NFT-Tutorial\n\n[![](https://img.shields.io/github/workflow/status/near-examples/nft-tutorial/Tests/main?label=Tests)](https://github.com/near-examples/nft-tutorial/actions/workflows/tests.yml)\n\nWelcome to NEAR's NFT tutorial, where we will help you parse the details around NEAR's [NEP-171 standard](https://nomicon.io/Standards/NonFungibleToken/Core.html) (Non-Fungible Token Standard), and show you how to build your own NFT smart contract from the ground up, improving your understanding about the NFT standard along the way. \n\n## Prerequisites\n\n* [NEAR Wallet Account](https://testnet.mynearwallet.com/)\n* [Rust Toolchain](https://docs.near.org/develop/prerequisites)\n* [NEAR-CLI](https://docs.near.org/tools/near-cli#setup)\n* [yarn](https://classic.yarnpkg.com/en/docs/install#mac-stable)\n\n## Tutorial Stages \n\nEach branch you will find in this repo corresponds to various stages of this tutorial with a partially completed contract at each stage. You are welcome to start from any stage you want to learn the most about. \n\n\n\n| Branch        | Docs Tutorial                                                                                    | Description |\n| ------------- | ------------------------------------------------------------------------------------------------ | ----------- |\n| 1.skeleton    | [Contract Architecture](https://docs.near.org/tutorials/nfts/skeleton) | You'll learn the basic architecture of the NFT smart contract, and you'll compile this skeleton code with the Rust toolchain.            |\n| 2.minting     | [Minting](https://docs.near.org/tutorials/nfts/minting)                |Here you'll flesh out the skeleton so the smart contract can mint a non-fungible token             |\n| 3.enumeration | [Enumeration](https://docs.near.org/tutorials/nfts/enumeration)        |    Here you'll find different enumeration methods that can be used to return the smart contract's states.          |\n| 4.core        | [Core](https://docs.near.org/tutorials/nfts/core)                      | In this tutorial you'll extend the NFT contract using the core standard, which will allow you to transfer non-fungible tokens.             |\n| 5.approval    | [Approval](https://docs.near.org/tutorials/nfts/approvals)             | Here you'll expand the contract allowing other accounts to transfer NFTs on your behalf.            |\n| 6.royalty     | [Royalty](https://docs.near.org/tutorials/nfts/royalty)                                                                                        |Here you'll add the ability for non-fungible tokens to have royalties. This will allow people to get a percentage of the purchase price when an NFT is purchased.             |\n| 7.events      | [Events](https://docs.near.org/tutorials/nfts/events)               |   This allows indexers to know what functions are being called and make it easier and more reliable to keep track of information that can be used to populate the collectibles tab in the wallet for example. (tutorial docs have yet to be implemented )          |\n| 8.marketplace | [Marketplace](https://docs.near.org/tutorials/nfts/marketplace)     | Get a comprehensive understanding of how an NFT marketplace contract can be built on NEAR through this tutorial. This contract facilitates the buying and selling of non-fungible tokens with $NEAR.             |\n\n\nThe tutorial series also contains a very helpful section on [**Upgrading Smart Contracts**](https://docs.near.org/tutorials/nfts/upgrade-contract). Definitely go and check it out as this is a common pain point.\n\n# Quick-Start \n\nIf you want to see the full completed contract go ahead and clone and build this repo using \n\n```=bash\ngit clone https://github.com/near-examples/nft-tutorial.git \ncd nft-tutorial\ngit switch 6.royalty\nyarn build\n```\n\nNow that you've cloned and built the contract we can try a few things. \n\n## Mint An NFT\n\nOnce you've created your near wallet go ahead and login to your wallet with your cli and follow the on-screen prompts\n\n```=bash\nnear login\n```\n\nOnce your logged in you have to deploy the contract. Make a subaccount with the name of your choosing \n\n```=bash \nnear create-account nft-example.your-account.testnet --masterAccount your-account.testnet --initialBalance 10\n```\n\nAfter you've created your sub account deploy the contract to that sub account, set this variable to your sub account name\n\n```=bash\nNFT_CONTRACT_ID=nft-example.your-account.testnet\n\nMAIN_ACCOUNT=your-account.testnet\n```\n\nVerify your new variable has the correct value\n```=bash\necho $NFT_CONTRACT_ID\n\necho $MAIN_ACCOUNT\n```\n\n\n### Deploy Your Contract\n```=bash\nnear deploy --accountId $NFT_CONTRACT_ID --wasmFile out/main.wasm\n```\n\n### Initialize Your Contract \n\n```=bash\nnear call $NFT_CONTRACT_ID new_default_meta '{\"owner_id\": \"'$NFT_CONTRACT_ID'\"}' --accountId $NFT_CONTRACT_ID\n```\n\n### View Contracts Meta Data\n\n```=bash\nnear view $NFT_CONTRACT_ID nft_metadata\n```\n### Minting Token\n\n```bash=\nnear call $NFT_CONTRACT_ID nft_mint '{\"token_id\": \"token-1\", \"token_metadata\": {\"title\": \"My Non Fungible Team Token\", \"description\": \"The Team Most Certainly Goes :)\", \"media\": \"https://bafybeiftczwrtyr3k7a2k4vutd3amkwsmaqyhrdzlhvpt33dyjivufqusq.ipfs.dweb.link/goteam-gif.gif\"}, \"token_owner_id\": \"'$MAIN_ACCOUNT'\"}' --accountId $MAIN_ACCOUNT --amount 0.1\n```\n\nAfter you've minted the token go to wallet.testnet.near.org to `your-account.testnet` and look in the collections tab and check out your new sample NFT! \n\n\n\n## View NFT Information\n\nAfter you've minted your NFT you can make a view call to get a response containing the `token_id` `owner_id` and the `metadata`\n\n```bash=\nnear view $NFT_CONTRACT_ID nft_token '{\"token_id\": \"token-1\"}'\n```\n\n## Transfering NFTs\n\nTo transfer an NFT go ahead and make another [testnet wallet account](https://wallet.testnet.near.org).\n\nThen run the following\n```bash=\nMAIN_ACCOUNT_2=your-second-wallet-account.testnet\n```\n\nVerify the correct variable names with this\n\n```=bash\necho $NFT_CONTRACT_ID\n\necho $MAIN_ACCOUNT\n\necho $MAIN_ACCOUNT_2\n```\n\nTo initiate the transfer..\n\n```bash=\nnear call $NFT_CONTRACT_ID nft_transfer '{\"receiver_id\": \"$MAIN_ACCOUNT_2\", \"token_id\": \"token-1\", \"memo\": \"Go Team :)\"}' --accountId $MAIN_ACCOUNT --depositYocto 1\n```\n\nIn this call you are depositing 1 yoctoNEAR for security and so that the user will be redirected to the NEAR wallet.\n\n## Errata\n\nLarge Changes:\n* **2022-06-21**: updated the rust SDK to version 4.0.0. PR found [here](https://github.com/near-examples/nft-tutorial/pull/32)\n\n* **2022-02-12**: updated the enumeration methods `nft_tokens` and `nft_tokens_for_owner` to no longer use any `to_vector` operations to save GAS. In addition, the default limit was changed from 0 to 50. PR found [here](https://github.com/near-examples/nft-tutorial/pull/17). \n\nSmall Changes:\n* **2022-02-22**: changed `token_id` parameter type in nft_payout from `String` to `TokenId` for consistency as per pythonicode's suggestion\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnear-examples%2Fnft-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnear-examples%2Fnft-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnear-examples%2Fnft-tutorial/lists"}