HashLips / example_nft_minter

Use this repo to see how to create a Dapp that can mint NFTs.
MIT License
253 stars 172 forks source link

Buy more than 1 nft per transaction #11

Open DanOlise opened 3 years ago

DanOlise commented 3 years ago

Hi guys,

Does anyone know what changes are required to change the buy button section to allow the user to buy more than one nft at a time? The current set-up only allows 1 nft to be purchased per transaction

Thanks in advance

iulianba commented 3 years ago

Hello,

You can do this:

const [nft_quantity, setQuantity] = useState(1);

function checkQuantity(value) { // here you can add some checks to not have values greater than your max mint amount. if everything is ok, call

setQuantity(value); }

The actual input:

<input name="nft-quantity"
onChange={e => checkQuantity(e.target.value)} value={nft_quantity} />

Mint button onClick action:

claimNFTs(nft_quantity);

Hope this helps you get an idea on how to achieve this.

DanOlise commented 3 years ago

Thanks so much, will give this a try now.

rrrrrrraaaaaaaaaaa commented 3 years ago

Hello,

You can do this:

const [nft_quantity, setQuantity] = useState(1);

function checkQuantity(value) { // here you can add some checks to not have values greater than your max mint amount. if everything is ok, call

setQuantity(value); }

The actual input:

<input name="nft-quantity" onChange={e => checkQuantity(e.target.value)} value={nft_quantity} />

Mint button onClick action:

claimNFTs(nft_quantity);

Hope this helps you get an idea on how to achieve this.

Hey, could you please explain more in detail?