Updating the Frontend
Now we've updated the contract to include an NFT as a reward and changed the contract such that it accepts bids in fungible tokens, we need to update the frontend accordingly.
Getting the data from the contract
Now we have a function to output the whole contract state we will call this function in our frontend
- index.js
Loading...
This call will deliver us the contract Ids of the FT and NFT contracts along with the token Id of the NFT. We will then use this information to call the ft_metadata and nft_token methods on the FT and NFT contracts respectively to get information about the FT and NFT.
Displaying the NFT
We want to show what NFT is being auctioned. To do this we will call nft_token on the NFT contract to get the NFT metadata. To call this method we need to specify the NFT contractId and the token_id, which can be found in the auction information. nft_token also returns the owner of the NFT, so we'll check this against the contract account to verify that the auction is valid.
- index.js
Loading...
Note that this effect will only run once the auctionInfo updates because we first need the NFT contract ID and token ID from auctionInfo to make a valid call to nft_token.
In a new component named AuctionItem we display the NFT image, name, and description.
- AuctionItem.jsx
Loading...
Note that an image caching service is used to display the NFT image for better performance.