Open and Close an NFT Sale From a React dApp

InstructorRyan Harris

Share this video with your friends

Send Tweet

We need to give the owner of the smart contract the ability to open and close an NFT sale in the React dApp UI.

We’ll use the .openSale and .closeSale methods off of the connectedContract stored in React state. Then for the best possible experience we’ll create a pending state while the sale is opening or closing. During the pending state the buttons will be disabled.

Then we’ll bring in useToast from chakra-ui to give a message depending on if the opening/closing of the sale was successful or not.

~ 2 years ago

Hey Ryan,

I am getting an error when I click open sale:

TypeError: connectedContract.openSale is not a function at openSale (Admin.js:27:1)

I am wondering if you have any idea why this may be?

Lucas Minter
~ 2 years ago

Hey, here is a github issue that should hopefully fix the problem that you're having https://github.com/ethers-io/ethers.js/discussions/1946.