ton-society / grants-and-bounties

TON Foundation invites talent to imagine and realize projects that have the potential to integrate with the daily lives of users.

Home Page:https://ton.org/grants

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tutorials: How to create (mint) own NFT

Hiyorimi opened this issue · comments

Summary

Tutorial allowing minting single NFT without help of 3rd parties, just with a bare CLIs and general environment for FunC / development on TON.

Context

There is no tutorial on how to mint standalone NFT in TON without using help of any 3rd party. With this Footstep we suggest creating tutorial and / or corresponding repository with all the code and tools required to mint a single NFT on the mainnet and testnet.

Goals

  • Create tooling / code for minting single NFT
  • Cover it with extensive documentation
  • Provide comprehensive README, so the repository can be used on its own and/or
  • Write a tutorial for using such a repository, so a mediocre developer capable to set up FunC / TON development environment is able to mint NFT following this tutorial

Deliverables

  • Repository with tools to mint standalone NFT
  • Tutorial covering how to mint standalone NFT

Definition of Done

[ ] Suggested tools allow minting standalone NFT following the instructions
[ ] Developers are able to find information on how to set up initial environment and to mint NFT

Reward

  • Standard TON Footstep NFT
  • 777 Toncoin

Total: $1250

Great

commented

Hi,
I'm excited to cover this tutorial and provide a repository containing the necessary scripts and README. I'll begin upon your approval.

My team wrote a similar tutorial just for Jettons instead of NFT (without a grant, purely for benefit of community). I would like to see this NFT tutorial written in the same level particularly since there's a grant involved. Our tutorial is published as a standalone GitHub repo here - https://github.com/ton-defi-org/jetton-deployer-contracts

Notice some of the things we paid attention to and you may want to replicate:

  1. The full flow runs on the user's client. There is no third party service involved. Just clone the repo (it's all open source) and you have everything you need to deploy a Jetton by yourself.

  2. The README is VERY detailed and doesn't assume the users know anything. It even explains how to install the func compiler on your machine. You can copy these parts from us.

  3. Repo includes the full sources with the Jetton standard contract code so users can still make small changes in the standard code. https://github.com/ton-defi-org/jetton-deployer-contracts#option-2-edit-the-jetton-code-to-add-a-custom-token-behavior

  4. For users that don't want to compile the code by themselves, the repo also includes a convenient UI (https://jetton.live) that lets you deploy in one click. Notice that this is still standalone since it's served from GitHub Pages and runs 100% client side on user's machine. https://github.com/ton-defi-org/jetton-deployer-contracts#option-1-deploy-a-standard-jetton-using-your-browser

  5. We explain to users what every field choice means and explain best practices. https://github.com/ton-defi-org/jetton-deployer-contracts#jetton-metadata-field-best-practices

  6. We explain a lot about security. You must explain enough that creators don't make mistakes and create dangerous NFTs - you are teaching them the best security practices. I can help review your recommendations and make sure they are secure. https://github.com/ton-defi-org/jetton-deployer-contracts#protect-yourself-and-your-users

  7. The repo even has tests in TypeScript! https://github.com/ton-defi-org/jetton-deployer-contracts/tree/main/test

  8. The repo has its own easy to understand compilation/deployment scripts. Just NPM install and you can use them. https://github.com/ton-defi-org/jetton-deployer-contracts/tree/main/build

  9. I think GitHub repo is enough. No need to write a blog post. Just a README with all the code you need in the repo.

  10. There is one delicate point about NFTs and this is where the metadata is stored. In Jettons we stored it on-chain but with NFT you must probably use IPFS. Now this is an issue because IPFS requires a third-party service to do the pinning. When TON Storage is released, you will need to replace the tutorial from IPFS to TON Storage since we support that more. But for now you will need to explain how to upload to IPFS and do pinning. You will probably explain about services like Pinata (https://www.pinata.cloud/) and teach users how to use them.

If you have any questions or want to discuss, I'll be happy to help you, just DM me on Telegram @talkol

I also recommend that you take our Jetton repo and fork it and tweak it for NFTs. This will save you a lot of work and set you on the best possible path.

Feel free to fork https://github.com/ton-defi-org/jetton-deployer-contracts and adapt it. It's open source with MIT license and forking it is encouraged! Even if you get a grant :)

And please don't use a Fift script to deploy. For new developers Fift is very complicated with a huge learning curve. TypeScript deployment is much much simpler to understand for them.

@anomaly-guard I believe that input from @talkol is really worthy to be taken into account. Will you be able to comply with it?

commented

@talkol Thanks for all this worthy information and the great time you and you're team have dedicated to the project.
@Hiyorimi I don't actually see an obstacle here and the compliance would be ok. Just noting that talkol's expectations cover a lot more than the goals and deliverables described, so It would take a reasonable amount of time. I'll start working on the topic and try to update and report iteratively.

I think we can postpone the UI (like https://jetton.live) to a later phase and focus on the contracts first (compile by yourself on your machine, no 1 click deployment via browser) which should reduce the load considerably

I think we can postpone the UI (like https://jetton.live) to a later phase and focus on the contracts first (compile by yourself on your machine, no 1 click deployment via browser) which should reduce the load considerably

Reasonable! and it can be delivered as an intermediate milestone!

@anomaly-guard how is it going with a project ?

commented

Hi, It's going well. I will share my progress in the next few days.

commented

Sorry for the delay in completing this step. Actually, it had concepts that took longer than I anticipated. I'm here to provide an update.
My goal is to accomplish this step entirely with native tools (func,fift, lite-client, and python as the scripting language.

In addition, I researched and attempted to adapt the solution mentioned by talkol. Although it works well, IMHO it lacks the readability and flexibility I was looking for. And because there are no Python alternatives, I decided to start from scratch with Python.

From my perspective, the main goal is to make the source as simple as possible for users by abstracting the fift calls and providing readability and flexibility to adapt the source for customized contracts. Although fift has a steep learning curve, it provides excellent functionality and simplifies the process. Instead of avoiding fift, I believe we should abstract it so that users can use the stuff simply in the first step, and then investigate further to understand the underlying fift scripts in the second step [If needed].

Here is the project's current status:

from pyfift.nft_collection import NftCollection


wallet_address = "UQDJ4h-_7rxomPphDPZA2u0sOFUse7hH_0cSjM-cZM3NP5XS"
collection = NftCollection(
    wallet_address,
    1, 0, 2,
    'https://raw.githubusercontent.com/ton-blockchain/token-contract/main/nft/web-example/my_collection.json',
    'https://raw.githubusercontent.com/ton-blockchain/token-contract/main/nft/web-example/'
)
print(collection.to_boc().bytes())

I'm currently working on implementing the signature and other messages, and then I'll write a script to communicate with liteclient in order to send the message to the network.

I think it is unwise to move efforts to Python

We should consolidate our efforts and so far the JavaScript/TypeScript ecosystem (npm ton, TonWeb, ton-contract-executor) seems the leading one in terms of dev infrastructure efforts. I cannot imagine how we create a tool like yours without a testing environment and I cannot imagine a testing environment that is not ton-contract-executor, which is not available on Python.

I have also noticed a similar project by ton diamonds - https://github.com/tondiamonds/ton-nft-deployer
It is based on the TypeScript stack. They also came to the very interesting conclusion that the bottleneck is deploying 10,000 contracts instances and have clever solutions to address this.

commented

I respectfully disagree with your point of view.

There is no requirement that all of the ecosystem's tools be written in the same language. The fact that we develop different tools in different languages would greatly benefit the ecosystem, making the decision for new developers much easier.

As far as I can tell, there are solid Python projects for the TON Ecosystem, such as toncli, which has extensive testing and does not rely on ton-contract-executor. However, creating such a testing framework is not a barrier.

Putting a force and necessity to unify over one language/ecosystem is the biggest mistake a large, growing project like TON could make. Developers will proceed with their preferences and create tools to eventually converge to the ideal state.

This footstep does not impose a language and instead emphasizes the use of TON's native tools, which are satisfied, and pure Python is used as the scripting language.

This footstep does not impose a language and you are free to choose whatever stack you prefer. Simply making an observation that we are stronger united and building on each other's work, not each trailblazing their own separate path.

If you look at other similar ecosystems like Ethereum, they are normally consolidating around one popular language for contracts (Solidity, FunC in our case) and one popular language for toolchain and frontend (JS).

You limit yourself to smart contracts (ok, FunC is absolutely organic here and there are no other options) and frontend (in my opinion javascript/typescript is a bottleneck of development not only the centralized Internet), but you forget about many other things. It seems like for you the whole TON ecosystem is wallets, NFTs, and probably DEX.

Guys, I do not want to seem rude, but do not restrict development (especially development by the community - open source), just because you like some technology more than others.

What's up with this footstep?

commented

Almost done, will share the repo soon after tidying up the code. Deploying on testnet was completely successful.

commented

I was eventually able to complete the footstep with the necessary deliverables:)
The deploying process was difficult, and I had some trouble debugging the flow since I'm new to TON.
You may now check the following repository:

https://github.com/anomaly-guard/nft-deployer

Everything is written in pure Python, so a user would only need to install the TON environment + Python (which is installed by default in most operating systems) to mint his/her NFTs. In addition, the syntax is maintained as basic and plain as possible. As in the case of deploying an NFT collection:

collection = NftCollection()
collection.init_data(
    owner=addr,
    royalty_factor=5,
    royalty_base=100,
    next_item_index=0,
    collection_content_url='https://raw.githubusercontent.com/ton-blockchain/token-contract/main/nft/web-example/my_collection.json',
    common_content_url='https://raw.githubusercontent.com/ton-blockchain/token-contract/main/nft/web-example/',
)
collection.prepare_deploy(value=0.05, external=False)
print("preparing to deploy nft collection contract ...")
print("NFT Collection address:", collection.h_addr)
collection.deploy(wallet, mode=64 + 3)

@Hiyorimi

I'm checking the repository

commented

@Hiyorimi
Hi, Any updates?

@anomaly-guard @Hiyorimi
Interesting footstep implementation, We could make great use of this in the rift framework.
I encourage you to take a look at rift and become a contributor if you'd like! And please update the license of the repository.
I tested the repository and checked the sources. It looks good and works fine. There are some possible enhancements and some minor issues to fix, that I will mention in the repository's issues.

@Hiyorimi
Hi, Any updates?

Not yet, didn't have time. Will investigate on a weekend.

commented

@anomaly-guard @Hiyorimi Interesting footstep implementation, We could make great use of this in the rift framework. I encourage you to take a look at rift and become a contributor if you'd like! And please update the license of the repository. I tested the repository and checked the sources. It looks good and works fine. There are some possible enhancements and some minor issues to fix, that I will mention in the repository's issues.

I'm glad to hear that:) Rift appears to be a great project; will check it shortly!

@Gusarich can you please assist on checking the tutorial @anomaly-guard have built?

I've already checked this repository last week. Tried again and it works good.
Successfully deployed items both on testnet and mainnet.
In my opinion this footstep is completed!

Also I think @SwiftAdviser would like to see this tutorial on tonspace.co

Thank you !

@anomaly-guard would you like to submit a PR to complete the Footstep?

commented

Sure, Done!

Thank you!