This is the repo to create NFTs on EVM compatible blockchains (able to run solidity code).
- clone the code in your system.
- Install all the dependencies by running :
npm install - Add a secret.json in the root directory, in below format:
{
"alchemyApiKey": "<alchemy_api_key>",
"privateKey": "<wallet_account_private_key>",
"sendridApiKey": "<sendgeid_api_key>"
}
- Run the server by connecting to Rinkeby network by running
npx hardhat run --network rinkeby app.js
- clone the code in your system.
- Install all the dependencies by running :
npm install - start a local blockchain by running
npx hardhat node - In another terminal window compile the smart contract,
npx hardhat compile - deploy the smart contract on local blockchain,
npx hardhat run --network localhost scripts/deploy.js
By now following things are happening in your system:
- a local blockchain is running
- smart contracts under the directory contracts/solidity have been deployed on this blockchain
Next:
start your nodeJs server by running npx hardhat run --network localhost app.js
Now, you nodeJs server is running at port 3000.
- Curl to create a NFT token
curl --location --request POST 'localhost:3000/createNft' \
--header 'Content-Type: application/json' \
--form 'file=@"/Users/vg/Documents/nft images/1.jpeg"' \
--form 'mintTo="0xb8FAAB1f7f19E7021A8736777d7D0d75b7bdFcbc"' \
--form 'name="cool dude"' \
--form 'description="a cool new nft token"'
if you wish then you can update the mintoTo and tokenUri values.
- curl to query the owner of a token Id
curl --location --request POST 'localhost:3000/ownerOf' \
--header 'Content-Type: application/json' \
--data-raw '{
"tokenId" : 1
}'
- curl to get the URI of the token
curl --location --request POST 'localhost:3000/tokenURI' \
--header 'Content-Type: application/json' \
--data-raw '{
"tokenId" : 1
}'
paste the request curl in the postman and you will be able to interact with NFT smart contract deployed.