NFT Smart Contracts

NFT Smart Contracts

The core of every NFT project is a Smart Contract, which holds all the information about your NFT collection on-chain. Magic's Minting and Delivery API and NFT Checkout services support ERC-721 and ERC-1155 contracts on Polygon, but still require some specific implementation details.

This guide will walk you through setting up your smart contract for integration with Magic NFT Minting + Delivery and NFT Checkout.

#Smart Contract Requirements

In order to integrate with Magic NFT Minting + Delivery or NFT Checkout, developers must construct and deploy their own NFT smart contract, which can either be an ERC721 or ERC1155 contract. However, it is crucial to incorporate a minting function that follows the specified standards outlined below.

#Required Function

01// ERC721
02function mint(address _userWallet, uint256 _quantity) external payable {}
04// ERC1155
05function mint(address _userWallet, uint256 _quantity, uint256 _tokenId) external payable {}

If you’ve already deployed your contract and it does not match the above, reach out to Magic Support, there may be ways to interface between Magic and your contract.

Next, if you have minting restrictions on your contract, you need to grant permission to Magic’s address to be able to mint. For example, if you’re using Open Zeppelin’s Access Control library you might run something like:


Grant permission to the following Magic Wallet Addresses based on your NFT Contract Type:

Polygon Mainnet

Standard ERC721 or ERC1155: 0x17C5e0af7D75F8d6e3dEf32E89dBE572788F4D77

Polygon Amoy Testnet

Standard ERC721 or ERC1155: 0xD53027B4db49ad2c9DA2EED644A1494A4CCAE275

Finally, you need to verify your contract on Polygonscan, for example using Hardhat. This allows our support team to review your contract and help if needed.

#Submitting Details to Magic

Once you have your contract deployed, send the following details to your Magic Customer Success rep:

  • Publishable API Key (from any app in your Magic dashboard)
  • Contract Address
  • Minting function name
  • Webhook URL for minting and delivery status updates - see section below

#Next Steps

Once you have your contract deployed, and Magic has registered it in our backend, you can continue to integrate the Minting and Delivery API or the NFT Checkout service.