-
Notifications
You must be signed in to change notification settings - Fork 0
Chia NFTs
Chia Network has released the NFT1 standard along with initial DID support. To get started you should first visit: https://docs.chia.net/docs/13cli/did_cli/ and follow the first guide to set up a DID wallet, and then visit https://docs.chia.net/docs/13cli/nft_cli and follow the example 2 guide for creating an NFT wallet with DID. The majority of the following information also comes from these guides, the RPC versions of these guides (can be seen at the same location), and from the developer documentation which can be found here: https://devs.chia.net/guides/nft-intro.
This is the most important phase of minting an NFT, making sure you have everything ready to go. What you will need:
- A synced node running chia 1.4.
- Your NFT Data payload.
- Your NFT Metadata in json format.
- Your NFT License data in a text format.
- Generate a UUID for your "collection_id".
- A place to host these files.
- Hashes for the files, verifying that the hosted hash matches the local hash
- A json file containing all of this information and more for the minting
Currently people are using image files, but since this is just going to be a link in the NFT, it can be anything. Create your image and upload it to the appropriate source.
This is the most important part to make sure your NFT displays correctly when inspecting it on websites and in the client. Without metadata, your NFT will just be a nameless image. There is a json schema file located here and a schema validator here. Example metadata.json:
{
"name": "Did you see anything?",
"description": "Good, knock next time.",
"format": "CHIP-0007",
"collection": {
"id": "b1dce7b4-2fe2-431d-bb3e-358b799dd685",
"name": "GeneMemes",
"attributes": [
{
"type": "description",
"value": "A collection of spicy memes featuring Gene Hoffman."
},
{
"type": "icon",
"value": "https://nuzlgfw3yjd5im3fki44weizlfarfl2dg4fhja7levva5nkz.arweave.net/bTKzFtvCR9QzZVI-5yxEZWUESr0M3Cn_SD6yVqDrVZ8"
},
{
"type": "banner",
"value": "https://ff5flyehwe4u5ddyfsjms3edck52rtncosgtbtrme5cqrxh32fqq.arweave.net/KXpV4IexOU6MeCySyWyDEruozaJ0jTDOLCdFCNz70WE"
}
]
}
}
Additionally you can add an "attributes"
array for each NFT itself, and there are additional things you can include in the collection's "attributes"
array, but this is what I would consider the minimum for the majority of functionality. More on the contents later, but the absolute minimum required contents are the "name"
, "description"
, and "format": "CHIP-0007"
. Once Again, you should verify that your json file matches the schema using the validator tool here.
The license is an optional inclusion and can be any displayable file, most likely preferred by be some kind of text formatted document like a txt, doc, or pdf file.
From the CHIP-0007 schema, we can see that the collection ID must be in format "uuid". There are a few ways to generate a UUID, one is search google for a UUID generator, and the second is to use the uuid python module locally. The top google result for uuid generator is https://www.uuidgenerator.net/. To generate a UUID locally using python:
$ python
>>> import uuid
>>> print(str(uuid.uuid4()).upper())
generated-UUID4-string-here
>>> print(str(uuid.uuid1()).upper())
generated-UUID1-string-here
>>> exit()
Once generated, add it to your metadata json.
There are many options out there for hosting, just make sure the solution you choose does not change the file in any way by running that checksum. IPFS is a popular choice, such as https://nft.storage. The solution I chose was arweave, I sent some xch to kucoin, converted it to USDT, then converted that to AR and transferred to an arweave wallet. Then using https://ardrive.io, I connected the wallet and started uploading files. Typical couple hundred KB uploads have been around 0.00007 or less AR. Once the files are hosted, verify the hashes, and add the URLs to the minting json.
For this example I will assume we are minting an image NFT of a file named see-anything.jpg, with metadata named gm8.json, along with a license file called license.txt, and that these files are locally in the present working directory, as well as uploaded to arweave:
$ sha256sum see-anything.jpg
18534cd1d3e7b2d2b5a6064beb4081dc0555d9f157d00da65df8b0a01e706c76 see-anything.jpg
$ curl -s https://mnjrjtdzc5ng6sq5ur3vt7dqcwop3hobgfc4qa4ouum5445c5poq.arweave.net/Y1MUzHkXWm9KHaR3WfxwFZz9ncExRcgDjqUZ3nOi690 | sha256sum
18534cd1d3e7b2d2b5a6064beb4081dc0555d9f157d00da65df8b0a01e706c76 -
$ sha256sum gm8.json
d2397ec3c236950d4c4793b45d1c228788af7d84de57af865d5d9b335229a2ff gm8.json
$ curl -s https://zofqxdagit2nlgu6yo2zig24zwq7dsjrurvpoa47diootuocajxq.arweave.net/y4sLjAZE9NWansO1lBtczaHxyTGkavcDnxoc6dHCAm8 | sha256sum
d2397ec3c236950d4c4793b45d1c228788af7d84de57af865d5d9b335229a2ff -
$ sha256sum license.txt
270ac935b3f45d71b50fbe395f81ce099d76efd8e3a7c0e622712e2aa2e338af license.txt
$ curl -s https://vgowprh5i3k5nkq4cxcctpzoflomoabq5k5kzqcyldr4brs6.arweave.net/qZ1nxP1G1daqHBXEKb-8uKtzHADDquqzAWFjjwM_Zew | sha256sum
270ac935b3f45d71b50fbe395f81ce099d76efd8e3a7c0e622712e2aa2e338af -
Once we've verified the hashes match, we can write the minting json.
Using the RPC NFT minting guide located here we will create a JSON formatted file to more easily mint the NFT. Using all of the information we have gathered, it will look something like this:
{
"wallet_id": 6,
"uris": ["https://mnjrjtdzc5ng6sq5ur3vt7dqcwop3hobgfc4qa4ouum5445c5poq.arweave.net/Y1MUzHkXWm9KHaR3WfxwFZz9ncExRcgDjqUZ3nOi690","ar://Y1MUzHkXWm9KHaR3WfxwFZz9ncExRcgDjqUZ3nOi690"],
"hash": "18534cd1d3e7b2d2b5a6064beb4081dc0555d9f157d00da65df8b0a01e706c76",
"meta_uris": ["https://zofqxdagit2nlgu6yo2zig24zwq7dsjrurvpoa47diootuocajxq.arweave.net/y4sLjAZE9NWansO1lBtczaHxyTGkavcDnxoc6dHCAm8","ar://y4sLjAZE9NWansO1lBtczaHxyTGkavcDnxoc6dHCAm8"],
"meta_hash": "d2397ec3c236950d4c4793b45d1c228788af7d84de57af865d5d9b335229a2ff",
"license_uris": ["https://vgowprh5i3k5nkq4cxcctpzoflomoabq5k5kzqcyldr4brs6.arweave.net/qZ1nxP1G1daqHBXEKb-8uKtzHADDquqzAWFjjwM_Zew"],
"license_hash": "270ac935b3f45d71b50fbe395f81ce099d76efd8e3a7c0e622712e2aa2e338af",
"series_number": 1,
"series_total": 1,
"royalty_address": "xch1rtgkqnqfr8na9hg7atuwmmuvtcf2qp0ugs7faqvxw7pk0c6llqsqryz4my",
"target_address": "xch1rtgkqnqfr8na9hg7atuwmmuvtcf2qp0ugs7faqvxw7pk0c6llqsqryz4my",
"royalty_percentage": 100
}
There are a few things to note here. I have used 2 URIs for the data and metadata, in this specific case adding the ar://
addresses in case anyone is using an arweave app to download files. The license URI is only a single link, but it still must entered as an array. This is NFT number 8 in the series, which has a total of 69 NFTs. The royalty_address
and target_address
are the same in this example. They can be any address you want, and the target address can be omitted, it will just go to a receive address in your wallet when minted. The royalty_percentage
is 1%, as per the chia documentation, the royalty percent is multiplied by 100. The wallet_id
will be the NFT wallet you created at the beginning. During times of high network usage, it would be highly recommended to include a fee. (When minting with CLI, the fee is in XCH, when minting with RPC, the fee is in mojos, do not mix these up).
- UPDATE: From the devs on keybase, the wording used in 1.4 for "series_number"
and "series_total"
is not accurate, and they are meant to be used as "editions" for when you mint multiple copies of the same data/metadata (e.g. you mint 20 baseball cards of Joe Nobody, you have "edition" 1 through 20). In version 1.4.1 these options during minting will be reworded to "editions". For tracking the series number in collections, you can use an attribute type field in the metadata, or do what most people do and put the number in the name and or description.
Now that everything has been prepared, we can mint the NFT very easily with:
$ chia rpc wallet nft_mint_nft -j filename.json
There will be an output either dumping a big block of chia spendbundle info and reporting success, or there will be an error if something is not correct. All that's left to do is wait a few moments for the transaction to be included in a block. After some time has passed, check the NFT wallet for the new NFT with chia wallet nft list -i <wallet id>
.
Now that you've minted the NFT, you'd probably like to offer it to others in exchange for xch (or CATs). It is simple to make an offer for XCH in the GUI, but the GUI can not currently create an offer for CATs. After any offer creation via CLI, it will show you a preview of the transaction, then ask for confirmation twice before creating the offer file.
If you forget an option, you can view all options at any time with chia wallet make_offer -h
.
To make an offer for XCH we simply use the NFT id and the normal wallet id:
$ chia wallet make_offer -o "nft105rwccplx6jcxnjp9w3aj0l7zlwme7zekppldqhg93nvd6l3dyzs5vpcy0":1 -r 1:0.5 -m 0 -p offer_file
To make an offer for a CAT, we substitute the normal wallet id for the CAT wallet id:
$ chia wallet make_offer -o "nft105rwccplx6jcxnjp9w3aj0l7zlwme7zekppldqhg93nvd6l3dyzs5vpcy0":1 -r 3:80000 -m 0 -p SBX_offer_file
Much like above, we just switch the -o
and -r
options, in this example we'll attempt to buy the same NFT for a lower offer in SBX:
chia wallet make_offer -o 3:50000 -r "nft105rwccplx6jcxnjp9w3aj0l7zlwme7zekppldqhg93nvd6l3dyzs5vpcy0":1 -m 0 -p SBX_offer_file2
The chia RPC allows passing a simple json to carry out the commands, so it makes automation of creating offers a bit simpler, below is an example json as well as the simple chia rpc
command to execute it:
{
"offer": {
"0xc541f3c2b8f01fb1a71cae1c0cd4e7121c8169876803cdb5558c4d2ff44bed07": -1,
"1": 100000000000
},
"fee": 0
}
chia rpc wallet create_offer_for_ids -j file.json
Notice that the launcher coinid is used rather than the nft id, this can be entered with or without the 0x in front to indicate hexadecimal. Also the way the client distinguishes what is being offered and what is being requested is by the value being positive or negative, in this case we are telling the wallet that we want to have 1 less of the NFT and 100000000000 more mojos (RPC uses mojos rather than xch like the CLI does).
To convert your desired xch amount into mojos, simply multiply the xch value by 1,000,000,000,000.
Lastly, an example using the RPC manually without a json (the json being passed directly via command line):
chia rpc wallet create_offer_for_ids '{"offer":{"abe84faa0e35188b3b177c519c767caad94a68dcd8096a1d8f3008e48d14cfc8": -1,"1": 100000000000},"fee": 4}'
There is an additional driver_dict
optional parameter, but I do not know what it does or how to use it.