This repo provides python scripts to ease NFT deployment on TON (The Open Network).
- Install
Python3
- Setup TON Development Environment
- Make sure to include binaries in your
PATH
before moving ahead!
- Make sure to include binaries in your
- Clone the repository
git clone https://github.com/anomaly-guard/nft-deployer cd nft-deployer
- Download necessary configs:
mkdir tmp cd tmp wget https://ton-blockchain.github.io/global.config.json wget https://ton-blockchain.github.io/testnet-global.config.json cd ..
Before moving on you should configure config.json
. It configures network
, your private key
, lite-client configs
, and contract codes
.
Warning At least test the flow one time with
testnet
before moving on tomainnet
.
To begin your work with deploying, you need to setup your wallet for sending messages and paying for fees. This script currently supports v3r2
wallets. If you don't have one, upon first execution, keys will be generated and you will be asked to save it.
- Set your private key in
config.json
(If you want key generation, replace the value withnull
) - Run
deploy-wallet.py
python deploy-wallet.py
- According to the account state, the script will notify you with the proper action for you to do.
- You can use
@testgiver_ton_bot
to get testnet TONs. - You're done when you see a message like the following message:
using existing key defined in config ... This account is already active and deployed ... Wallet Address: kQC/+HiWP5fgsu9fS7cECGCGON5PZAdKO7fHZ0JyJxV8t6Yj Balance: 1.46751 TON
- Open
deploy-collection.py
and configure the parameters ofNFTCollection
to create your desired 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/', ) # ...
- Save and run the deploy script, you will see a message like:
❯ python3 deploy-collection.py using existing key defined in config ... preparing to deploy nft collection contract ... NFT Collection address: kQCtSPsG5JlnAeviQAzc811k2X4aRbHm1OJmzUnpkNNoPgLJ Deploy message successfully sent to lite-servers!
- Take note of NFT Collection address, we will use it in next section to deploy NFT Items.
- Edit
deploy-item.py
and replace the values with desired ones:nft_collection_addr = "kQCtSPsG5JlnAeviQAzc811k2X4aRbHm1OJmzUnpkNNoPgLJ" msg_body = DeployNFTMessage( index=0, content_url="my_nft.json", amount=50000000, owner=addr, ).to_boc()
- Save and run the deploy script, you will see a message like:
❯ python3 deploy-item.py using existing key defined in config ... Message successfully sent to lite-servers!
- Your NFT is successfully deployed!
- The
0.05 TON
amount in messages are for covering the TON fees. - NFT Item url is not stored completely in NFT Item contract, the common part of url is saved in Collection contract and just the last part is saved in Item contract (To optimize fees).
- You can use tonscan or its testnet version to check transactions status. (Enter address and check its transactions)
- You can use TON NFT Explorer or its testnet version to check NFT contracts state.
- You can customize the codes too, just point the
config.json
's code path to modified contracts.