Bring your own contract

Using Crossmint's minting infrastructure with your own imported smart contract

Crossmint has a pre-audited library of smart contracts that will serve most use cases. However, if you have custom needs, you can also bring your own contract and leverage Crossmint's scalable infrastructure to mint and distribute the NFTs. Crossmint will execute transactions at the maximum rate the blockchain can handle, pay gas fees, and create wallets for users don't have one, all with enterprise SLAs and customer support.

However, note that certain functionality may not be available with your own smart contracts, unless Crossmint supports those functions and is granted permission on the contract to execute them.

Smart contract pre-requisites

  • Your token contract must follow the ERC721 standard. For ERC1155s support, contact us.
  • Your minting contract must have a function that allows free mints. This function must whitelist Crossmint's treasury address. Contact us for the wallet address to whitelist.

We recommend that you use Open Zeppelin's audited AccessControl contract to manage the authorization logic. Here is a very basic abbreviated example of how to implement this:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/AccessControl.sol";

...

contract BYOCMinter is ERC721, AccessControl {

    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

    constructor() payable ERC721("EVM 721 Starter", "XMPL") {
        _grantRole(MINTER_ROLE, msg.sender);

        // THIS IS THE IMPORTANT DETAIL
        _grantRole(MINTER_ROLE, '0x13253aa4Abe1861124d4c286Ee4374cD054D3eb9'); // polygon mumbai
        _grantRole(MINTER_ROLE, '0xa8C10eC49dF815e73A881ABbE0Aa7b210f39E2Df'); // polygon mainnet
    }

    function mint(address _to, string calldata uri) external onlyRole(MINTER_ROLE) {
        // mint function logic
    } 
}

📘

Existing Integrations

Crossmint natively supports smart contracts from Salesforce, Infura (ERC721Mintable) and other common templates, under the enterprise plan.

Integration Guide

1. Register your smart contract

Go to the API Keys tab on the console and create a key with scopes nfts.create & nfts.read.

Then navigate to the Collections tab, click on New Collection, fill in the contract metadata, and select Import an existing contract.

Once created, click on Contract Registration, and enter the following info about your smart contract:

  • Contract type: ERC-721
  • Contract address: The address of your deployed smart contract
  • ABI section and other parameters: Crossmint will automatically retrieve the ABI of verified contracts. Read this guide if you encounter any issues.
1600

Contract registration example via the console

2. Contract review

Copy the collectionID from the collection page in the Crossmint console and share it with your Crossmint point of contact. The team will validate the contract meets the requirements, set it up to be used with the minting tools, and provide you a new collectionID which you can use to make calls to the API.

3. Mint ⛏️

You can call any of the Mint API functions documented in the API reference.

Note that for the Mint NFT function you can’t pass custom metadata (as that’s controlled by your contract) and you must all pass all the parameters needed to call your mint function, except the one specifying the recipient (which is populated by our application). The request should follow this structure:

{
  "recipient": "<locator in format specified at https://docs.crossmint.com/docs/recipients>"
  "contractArguments": {
     // JSON object with the arguments to the mint function and specified value
  }
}

For example:

{
    "recipient": "email:<email address>:poly",
    "contractArguments": {
        "tokenCount_": 1,
        "signature": "0xabc..."
    }
}

This request will generate a wallet for the user and deliver the NFT. You can also send it directly to any wallet address, if the user has one.