Hey everyone, I’m having trouble setting up the Crossmint button for my NFT project. I keep getting an error saying “NFT count must be a string or number”. It’s driving me crazy!
I’ve tried using both string and number formats for the amount fields. I even experimented with different contract setups - one using counters for tokenIDs and another using Strings. But nothing seems to work.
Here’s a simplified version of my mint function:
function mintNFT(address buyer, uint256 quantity) public payable {
require(isActive, "Minting is not active");
require(msg.value >= price * quantity, "Not enough ETH sent");
require(msg.sender == crossmintWallet, "Only Crossmint can call this");
for (uint256 i = 0; i < quantity; i++) {
_safeMint(buyer, totalSupply() + 1);
}
}
Has anyone else run into this problem? Any ideas on how to fix it? I’m completely stuck and would really appreciate some help!
hey there flyingeagle! crossmint can be a real head-scratcher sometimes, right?
i’ve been there too.
have you tried playin around with the data types in your smart contract? maybe try changing the quantity parameter in your mintNFT function to a string instead of uint256? like this:
function mintNFT(address buyer, string memory quantity) public payable {
// convert quantity to uint256 here
uint256 quantityNum = uint256(keccak256(abi.encodePacked(quantity)));
// rest of your function...
}
just a wild guess, but it might help with that pesky error message youre getting.
also, im curious - how are you handling the crossmint integration on the frontend? are you using their sdk or custom implementation? maybe theres somethin funky goin on there?
let us know if you figure it out! always interested in learning more about these tricky integrations. good luck! 
yo, had similar headache w/ crossmint. tried checkin ur frontend code? make sure ur passin the quantity right to their API. also, double check ur crossmint config - sometimes tiny typos mess everything up. if nothin works, hit up their support team. they helped me sort it out pretty quick
I’ve encountered a similar issue with Crossmint integration before. The error you’re seeing often stems from how the quantity is being passed to the Crossmint API, not necessarily your smart contract implementation.
Try explicitly converting the quantity to a string when setting up the Crossmint button in your frontend. Something like:
const crossmintConfig = {
// other config options...
quantity: quantity.toString(),
};
Also, double-check that your Crossmint API key and collection ID are correctly set. Sometimes, these configuration issues can manifest as unexpected errors.
If the problem persists, I’d recommend reaching out to Crossmint’s support team. They’re usually quite responsive and can provide more specific guidance based on your setup.