Fujicracy / fuji-v1

0 stars 0 forks source link

[Locking Ceremony] Display the view after lock #408

Closed doliG closed 2 years ago

doliG commented 2 years ago

See figma

doliG commented 2 years ago

@DaigaroCota @tiagofneto need help on the second point: how can I read the souvenir NFT from smart contracts ? Which method to call, and what to expect in return. Ty.

tiagofneto commented 2 years ago

I'm not exactly sure by what you mean by "read the souvenir NFT" but I will give you some insight on how it works:

0xdcota commented 2 years ago

What Tiago described is precise. Once you get the LockNFTID you need to pass it to the functionuri() in the contract NFTGame.sol. You will get in return a base64 encoded json object. To uncode it you need a package like:

https://www.npmjs.com/package/base-64

Important to note that the image property of the json object is also base64 encoded.

You can see the output of uri() by running one of the test scripts. From the hardhat package root folder:

Start a node with yarn fork on a terminal On a seperate terminal run: npx hardhat --network localhost test ./test/fantom/nftgame/onchain_nfts.js

You will see the output spitted out in the terminal. You can then use a public website https://www.base64decode.org/ to decode manual and see the json data structure yourself.

0xdcota commented 2 years ago

As a side note, I believe browsers have built-in these two functionsatob()and btoa() that encode and decode base64. I did the following from Brave. However, don't know if this is universal to all browsers... or if these functions are accessible by React framework. image