It is essential to provide Paper with a way to assess whether a user is eligible to mint accurately. We will call the eligibilityMethod to check if a user is eligible to mint prior to prompting the user for their payment details to prevent them from paying. We also call this method throughout our flow to ensure the item is still available.

📘

The eligibilityMethod is only applicable when using a custom smart contract (contracts registered with the CUSTOM_CONTRACT type).

If eligible, return an empty string.

Otherwise, you can return a string dictating the error and we'll surface it to the user.

Examples of checking for "eligibility" include, but are not limited to:

  • Making sure there is a remaining supply
  • Making sure the quantity the user is trying to claim is equal to or lower than the remaining supply
  • Making sure the user is on the allowlist if there is one.

Example JSON

In the following example, we will call a function in your smart contract named checkClaimEligibility with the template parameters $WALLET as the toAddress and $QUANTITY as the quantity.

📘

For more information on the Template parameters. Click here

Use this format when passing in a eligibilityMethod to any of the APIs.

{
  "name": "checkClaimEligibility",
  "args": {
    "toAddress": "$WALLET",
    "quantity": "$QUANTITY"
  }
}

Example Smart Contract Implementation

The following is an example implementation of an eligibilityMethod on Solidity that checks to ensure the drop is live and that there is sufficient supply to mint the desired quantity. Note that the empty string return indicates that the user is eligible to mint the desired quantity.

This example does not show a sample allowlist. You may implement an allowlist with any format you wish on the contract, as long as the eligibilityMethod makes the necessary checks against the allowlist.

function checkClaimEligibility(uint256 quantity) external view returns (string memory){
  if (paused) {
    return "not live yet";
  } else if (quantity > maxMintAmountPerTx) {
    return "max mint amount per transaction exceeded";
  } else if (totalSupply() + quantity > maxSupply) {
    return "not enough supply";
  }
  return "";
}

Type

checkClaimEligibility is typed as a ReadMethodCallType. For your reference, the full TypeScript typing is as follows:

export type ReadMethodCallType = {
  name: string;
  args?: ArgumentMapType;
};

type ArgumentMapType = {
  [key: string]:
    | string
    | null
    | number
    | boolean
    | Array<ArgumentMapType>
    | ArgumentMapType;
};

Where do I provide the eligibilityMethod?

Checkout SDK intents and Checkout Links intents

Pass it along in the API when creating the intent for either the Checkout Link Intent or Checkout SDK Intent

Checkout Links

📘

See our Checkout Link builder for an example of how the eligibilityMethod query parameter is sent.

The eligibilityMethod object (in the shape above) should be provided as a query parameter that is JSON-stringified and base64-encoded.

Here's a simple Typescript implementation:

const eligibilityMethod = {
  name: "checkClaimEligibility",
  args: {
    toAddress: "$WALLET",
    quantity: "$QUANTITY"
  }
}
const eligibilityMethodQuery = btoa(JSON.stringify(eligibilityMethod))
const checkoutUrl = `https://paper.xyz/checkout/${checkoutId}?eligibilityMethod=${eligibilityMethodQuery}`