Ethereum / Polygon

Read on to learn how to integrate our client SDK with your Ethereum / Polygon NFT Drop.

Use Crossmint to allow your customers to mint NFTs using their credit card in less than 5 minutes.

πŸ“˜

The default transaction limit is $1,500. If your mint price is higher than this, please contact us at [email protected].

Pre-requisites

  • You must have yarn installed. Install yarn by following these instructions.
  • Your Crossmint Developer Account must be verified.
  • Your contract must be ERC-721, ERC-721A, or ERC-1155 compliant. Also, it must meet our Smart Contract Requirements defined below. If you have a unique contract, message us at [email protected].

🚧

See the testing section to learn more about how to test the integration before releasing to production.

Obtaining your Crossmint Client ID

To configure the Crossmint button, you will need a Crossmint Client ID. To obtain a Crossmint Client ID, sign up for an account using the Crossmint Developer Console, and register your contract address.

Verifying your Crossmint Developer Account

First, visit our Crossmint Developer Console. Choose Ethereum or Polygon and register your Contract Address. You'll also need to enter the following information for your drop:

Next, your collection must be verified, or else your drop won't work in production. In most cases, verification takes a few minutes. In very rare cases, we'll reach out to you via email to provide additional information.

Smart Contract Requirements:

To minimize gas fees for your customers, we require that your smart contract meets two criteria:

  1. There must be a minting function that allows minting directly to another address different than the one which invoked the contract.
  2. A single address must be able to call the mint function unlimited times but does not need to be able to hold unlimited NFTs.

Your minting function must contain at least one parameter that specifies the recipient address to mint the NFT to. Crossmint needs a mint function that lets the caller specify a different address to mint too.

πŸ“˜

If your contract is already deployed and doesn't meet this criteria, reach out to us at [email protected].

Let's see some very minimal examples below:

Contract Minting Function Example:

// save as property of contract
  address public crossmintAddress;

  function crossmint(address _to) public payable {
    require(mintPrice == msg.value, "Incorrect value sent");
    require(_tokenIdCounter.current() + 1 <= maxSupply, "No more left");
    // NOTE THAT the address is different for ethereum, polygon, and mumbai
    // ethereum (all)  = 0xdab1a1854214684ace522439684a145e62505233 
    // polygon mainnet = 0x12A80DAEaf8E7D646c4adfc4B107A2f1414E2002
    // polygon mumbai  = 0xDa30ee0788276c093e686780C25f6C9431027234  
    require(msg.sender == crossmintAddress, 
      "This function is for Crossmint only."
    );

    uint256 newTokenId = _tokenIdCounter.current();
    _tokenIdCounter.increment();

    _safeMint(_to, newTokenId);
  }
    
  // include a setting function so that you can change this later
  function setCrossmintAddress(address _crossmintAddress) public onlyOwner {
    crossmintAddress = _crossmintAddress;
  }

The mint function Crossmint uses can be named anything and contain any number of additional parameters as long as it meets these requirements. You can configure all parameters when minting with our client SDK.

Grabbing the ABI section for your minting function

When you compile your smart contract there will be a corresponding abi file. It'll have a .abi or .json extension depending on how you compiled your smart contract.

Inside this file you'll see a property, abi, that's an array with various objects. You'll need to grab the specific one that corresponds to the mint function you want us to call, and enter this into the Crossmint Developer Console.
Here's an example of what your abi file will look like, but yours might have more objects.

// Example generated abi file for smart contract
{
   "abi":[
      {
         "inputs":[
            
         ],
         "stateMutability":"nonpayable",
         "type":"constructor"
      },
      {
         "inputs":[
            {
               "internalType":"address",
               "name":"to",
               "type":"address"
            },
            {
               "internalType":"uint256",
               "name":"_count",
               "type":"uint256"
            }
         ],
         "name":"mintTo",
         "outputs":[
            
         ],
         "stateMutability":"payable",
         "type":"function"
      }
   ]
}

Next, grab the specific object that corresponds to the mint function you want Crossmint to call. To make this function easier to find you can use CTRL+F and search for the name of your function, in this case our minting function's name is mintTo.

The object below is the one that contains the information for the minting function we want to call. It contains all the function arguments and the type is function. In the example above's case, it would look like this:

// Example of specific section of abi file to enter into Crossmint Developer Console
{
   "inputs":[
      {
         "internalType":"address",
         "name":"to",
         "type":"address"
      },
      {
         "internalType":"uint256",
         "name":"_count",
         "type":"uint256"
      }
   ],
   "name":"mintTo",
   "outputs":[
      
   ],
   "stateMutability":"payable",
   "type":"function"
}

Copy and paste that object, and paste it into the ABI section for mint function field.

982982

Specifying a recipient address parameter for your minting function

After entering your ABI function, you will see in a dropdown all the options so you can easily choose the recipient address parameter.

928928

The first address field encountered will be set as default, make sure to double check it is the right one.

Specifying the parameter that indicates the number of NFTs to mint in a single transaction

If your mint function has a parameter that specifies the amount of NFTs to mint in a single transaction, select it out from the options provided after the ABI function was entered. This parameter can be named anything. For example, _count or _mintAmount are perfectly fine parameter names, just make sure it corresponds to the parameter name in your minting function.

918918

Testing Your Project

We support testing on the Goerli (Ethereum) and Mumbai (Polygon) networks. This will let you demo the minting process through Crossmint end-to-end with a mock credit card.

To get started, first create a test contract using our Staging Developer Console. KYC verification is not necessary for testing purposes, but will need to be completed before going live on production.

πŸ“˜

You'll need to create a new account for the Staging Developer Console because it's separate from our primary developer console.

When you register your contract address in the developer console it must be a testnet contract.

🚧

Our address, 0xdAb1a1854214684acE522439684a145E62505233, is the same for testing on Goerli and for production on Mainnet.

For Mumbai we use this address 0xDa30ee0788276c093e686780C25f6C9431027234

When testing, use the card number 4242 4242 4242 4242. Use any three-digit CVC and a valid future date, such as 12/34.

If there's an issue with your smart contract and you have to re-compile you'll have to create a new collection in the staging developer console, re-enter the new contract address, function params, and ABI, get a new clientId, and update your front-end.


What’s Next

Next you can setup the Crossmint Pay Button using your clientId