Skip to main content
BETA
HomeIntegration BuilderAPI ReferenceGuidesChangelog
View Mirror World on Github
Join the Discord server

Integrate NFT Fiat Checkout Using Mirror World

By Mirror World

Mirror World allows you to create a seamless and secure checkout process for your in-game crypto assets. This guide will provide step-by-step instructions on how to integrate your Fiat-to-NFT Solution using Mirror World Smart Platform.

If you want to integrate this service, please contact us: [[email protected]] and we'll start supporting it right away!

Modify your Smart Contract

Start by creating a new contract using the following template or modify your existing NFT contract that you would like the checkout to apply to: The setMWMintAddress and mwMint functions must be included in the contract in order to grant Mirror World airdrop access.

Contract Template:

  • ERC721

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyNftTemplate721 is ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
uint256 public totalSupply = 100;
uint256 public mintedCount;
bool public enablePurchase = true;
mapping(address => bool) public validMWMintAddress;
constructor() ERC721("MyNft", "MN") {
}
modifier onlyMWMinter() {
require(validMWMintAddress[msg.sender], "This function is for MirrorWorld only.");
_;
}
function setEnablePurchase(bool _enable) external onlyOwner {
enablePurchase = _enable;
}
function setMWMintAddress(address[] memory _wallets, bool _enable) external onlyOwner {
for (uint256 i = 0; i < _wallets.length; i++ ) {
address wallet = _wallets[i];
validMWMintAddress[wallet] = _enable;
}
}
function mwMint721(address _to, uint256 _amount) public onlyMWMinter {
require(enablePurchase, "currently paused");
require(_tokenIdCounter.current() + _amount <= totalSupply, "reached max supply");
// your own code...
for (uint256 i = 0; i < _amount; i++ ) {
uint256 newTokenId = _tokenIdCounter.current();
_safeMint(_to, newTokenId);
_tokenIdCounter.increment();
mintedCount += 1;
}
}
}

  • ERC1155

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyNftTemplate1155 is ERC1155, Ownable {
bool public enablePurchase = true;
mapping(address => bool) public validMWMintAddress;
constructor(
string memory uri_
) ERC1155(uri_) {
}
modifier onlyMWMinter() {
require(validMWMintAddress[msg.sender], "This function is for MirrorWorld only.");
_;
}
function setEnablePurchase(bool enable) external onlyOwner {
enablePurchase = enable;
}
function setMWMintAddress(address[] memory _wallets, bool _enable) external onlyOwner {
for (uint256 i = 0; i < _wallets.length; i++ ) {
address wallet = _wallets[i];
validMWMintAddress[wallet] = _enable;
}
}
function mwMint1155(
address _to,
uint256[] memory _ids,
uint256[] memory _amounts,
bytes memory _data
) external onlyMWMinter {
require(enablePurchase, "currently paused");
// your code ...
_mintBatch(_to, _ids, _amounts, _data);
}
}

Provide Necessary Information

Once you have created your project and have your contract address, you need to provide the necessary information about your NFT project to Mirror World so that we can create your API key.

This includes the blockchain you want to deploy on, the smart contract address, the product name, the URL of your collection image, the price of your NFT, the amount, the ABI documents, and any other recommended functions or error messages that might appear during the minting process.

CategoryInformation Provided
Blockchain - Which blockchain to deploy on
Smart Contract Address
Product Name
URL of your collection image - the image display to your users
Price of your NFT - By default the price is set to be USD. If you wanna use other cryptocurrency, you can mentioned here. (We can also support dynamic pricing method)
Amount
ABI documents
Error types and error messages might appear during minting process (not required, but recommended)
Other functions in Smart Contract (not required, but recommended)
1. check the remain amount of NFT in contract
2. Check current minting price (dynamic pricing)

Generate an API key

You will need this API key to access Mirror World's payment service API call.

If you do not already have a developer account, please head over to https://app.mirrorworld.fun/auth/login to get started. A developer account grants you access to all the features needed to build with the Mirror World Smart SDK and it can be created within seconds. If you run into any issues creating an account, Mirror World has active communities on Telegram and Discord with people on the Mirror World team ready to help.

Access the Payment Service

To access the payment service, you need to call Mirror World's payment service API. You will need to provide the following information:

  • contract_address: Smart Contract Address
  • address: User's wallet address, which will receive the NFT
  • mint_amount: Number of NFTs
  • api_key: Mirror World API-key (Production)

API Example


https://nft-checkout.mirrorworld.fun/?collection_address={collection_address}&address={wallet_address}&mint_amount={amount}&api_key={api_key}

NFT Checkout Service Data Flow

Untitled


Checkout Demo

To try out the checkout process for NFT, you can visit our demo here:

https://checkout-demo.mirrorworld.fun/

Edit this page on GitHub

Copyright © Mirror World, Inc. 2023
On this page

Home

Integration

Guides

API Reference

Changelog