This document covers the setup and basic usages of Hokusai.
After completing this tutorial, you'll be able to use Hokusai and start integrating NFT on your website.
Getting Started
Using Hokusai
Hokusai Links
To get started with Hokusai, first, clone this repository and follow the below tutorial.
git clone https://github.com/0xhokusai/hokusai-get-started.git
The installation requires the following steps:
- Obtain API key
- Create your wallet
- Publish NFT metadata
- Access NFT metadata
Submit your request for an API key here. You will receive the key, which contains HOKUSAI_API_KEY
and HOKUSAI_CONTRACT_ID
. Currently, it takes 2-3 business days to issue the API Key.
To mint an NFT, you must have your wallet address. We recommend using Metamask for wallet software.
Metamask is a software cryptocurrency wallet used to interact with the Ethereum blockchain. These articles provide a great introduction on how to set up Metamask.
Metadata is data that provides information about other data. NFT metadata contains information about its name, description, and image. We use nft.storage to publish NFT metadata.
Follow the setup guideline for nft.storage here.
Copy the .env.sample
file and fill in your own API keys in .env
file.
cp .env.sample .env # and rewrite API Keys
yarn # install the required packages
In case you have not installed yarn, follow the setup here.
You can publish metadata using our sample image (hokusai.png) by running the following codes
yarn store-metadata
You will get a URL for the metadata like this
HTTPS URL for the metadata: https://dweb.link/ipfs/bafyreieaaqfof34kfqyvwe4arta6jsuwuauim4d24qo22ct2xnvjnlnrb4//metadata.json # example metadata URL
You can access the metadata uploaded on IPFS via HTTPS URL by running the code below. IPFS is a distributed system for storing and accessing files, websites, applications, and data. Learn more about IPFS here.
curl https://dweb.link/ipfs/bafyreieaaqfof34kfqyvwe4arta6jsuwuauim4d24qo22ct2xnvjnlnrb4/metadata.json # example metadata url
{
"name":"nft.storage store test",
"description":"Using the nft.storage metadata API to create ERC-1155 compatible metadata.",
"image":"ipfs://bafybeicsu73gednfaa5svozuoac4ebpi76nn4auhygcvkvbn4kk2vdv5ey/hokusai.png"
}
Congratulations! You're ready to use Hokusai. Check out Hokusai Document for the full documentation. Now, let's try minting and getting an NFT. If you using the Mumbai testnet, change the baseUrl of src/getNft.ts and src/mintNft.ts's to "https://mumbai.hokusai.app".
To mint an NFT, run the code below
yarn mint-nft {to} {tokenUri}
{
txHash: '0x8765feaa11a7e0f9f4a84f21415434d80dd9be27728a8f6eff4d402e4d0c2766' # example Transaction Hash
}
You may refer to our documentation here for parameter descriptions.
tokenId
issued by Hokusai can be viewed via polygonscan. You can search by txHash received from minting.
yarn get-nft {tokenId}
{ id: {tokenId}, tokenUri: 'https://example.com/1' } # example response
To transfer an NFT, you need to perform 2 steps:
- Fill in the private key of your wallet in
.env
file (Get the private key) - Run the code below
yarn transfer-nft {to} {tokenId}
{
txHash: '0xdec77ee7148dc796dd08d656a256e1466daf2763c08cfe104f76e8baf318f3ed' # example Transaction Hash
}
To Burn an NFT, you need to perform 2 steps:
- Fill in the private key of your wallet in
.env
file (Get the private key) - Run the code below
yarn burn-nft {tokenId}
{
txHash: '0x67eca6ca63d542f4b01fd60d53feda89ce64f42394c27b77fa3fccbb15244d3c' # example Transaction Hash
}
⚠️ The private key is very sensitive information. You should make sure no one else sees.
So far, you have minted an NFT, got NFT info and transfered an NFT via Hokusai. See what else you can do with our API on Hokusai Document 🥳