PNPL Smart Contract Integration (EVM)
Integrate MersoPNPL for installment-based NFT purchases.
Overview
PNPL integration allows your players to purchase NFTs with 50% upfront and the remaining 50% in weekly installments. This requires integrating both the MersoPNPL contract and supporting WrappedNFTs in your game.
Integration Requirements
-
✓
ERC721/ERC1155 ComplianceYour NFT collection must follow standard ERC721 or ERC1155 interfaces.
-
✓
Marketplace IntegrationYour marketplace must be able to call the MersoPNPL contract.
-
✓
wNFT RecognitionYour game must recognize WrappedNFTs as valid in-game assets with equal functionality.
Contract Interface
MersoPNPL Interface
Solidity
interface IMersoPNPL {
// Purchase an NFT with PNPL
function buyTokenFrom(
address originalCollection,
uint256 tokenId,
uint256 tokenPrice,
address tokenAddress
) external;
// Check if a collection is allowed
function isAllowedCollection(
address collection
) external view returns (bool);
// Get user's active loans
function getUserLoans(
address user
) external view returns (LoanInfo[] memory);
}
Integration Example
Frontend Integration
JavaScript
import { ethers } from 'ethers';
import MersoPNPL_ABI from './abis/MersoPNPL.json';
const MERSO_PNPL_ADDRESS = '0x...'; // Provided during onboarding
async function purchaseWithPNPL(collection, tokenId, price, paymentToken) {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
// 1. Approve payment token
const tokenContract = new ethers.Contract(paymentToken, ERC20_ABI, signer);
const upfrontAmount = price.div(2); // 50% upfront
await tokenContract.approve(MERSO_PNPL_ADDRESS, upfrontAmount);
// 2. Execute PNPL purchase
const mersoContract = new ethers.Contract(MERSO_PNPL_ADDRESS, MersoPNPL_ABI, signer);
const tx = await mersoContract.buyTokenFrom(
collection,
tokenId,
price,
paymentToken
);
await tx.wait();
console.log('PNPL purchase complete! wNFT minted to user.');
}
WrappedNFT Support
Your game must recognize WrappedNFTs and treat them as functionally equivalent to original NFTs:
JavaScript
// In your game's NFT validation logic
const ORIGINAL_COLLECTION = '0x...';
const WRAPPED_COLLECTION = '0x...'; // Provided by Merso
function isValidGameAsset(nftContract, tokenId) {
// Accept both original and wrapped NFTs
return (
nftContract === ORIGINAL_COLLECTION ||
nftContract === WRAPPED_COLLECTION
);
}