decentramall / decentramall-ui

Your Unstoppable Decentralized Shopping Destination 🛍️🛒
https://decentramall.on.fleek.co/
GNU General Public License v3.0
5 stars 0 forks source link

Get user SPACE status #14

Closed vibern0 closed 4 years ago

vibern0 commented 4 years ago

Depends on #11

vibern0 commented 4 years ago

To know if SPACE is rent, we only need to verify if the tokenURI is set. Here's an example using the command line after renting a SPACE with success

truffle(development)> decentra = await DecentramallToken.deployed()
undefined
truffle(development)> (await decentra.totalSupply()).toString()
'1'
truffle(development)> (await decentra.tokenByIndex(0)).toString()
'59445606994480167206646304069559128798226201844767837182811341979008600605747'
truffle(development)> (await decentra.tokenURI('59445606994480167206646304069559128798226201844767837182811341979008600605747')).toString()
'QmRCNryuXnysNZKnN5evFJrzQ39ZtuPAr4xwRAGvKv4oAC'
truffle(development)>
raphaelpg commented 4 years ago

There might be a simple way to do this but I can't figure out how to retrieve the tokenURI from the smart contract based on the tokenID from the context. I can display the tokenURI through an independent async function calling the contract, but I can't call the context inside the useEffect nor call the contract inside the renderContext...