3mint
  • 👋Welcome to 3mint
  • 💻3mint Platform
    • Introduction
    • Deploy a contract
    • Upload your NFT data
    • Create checkout links
    • Add customers
    • Monitor your links
  • ⌨️Developer Guides
    • Introduction
    • Contracts
      • Contract Architecture
      • End-to-end Example
    • Mint
      • How To
      • End-to-end Example
      • Code Snippets
    • Wallets
      • End-to-end Example
      • Mobile Pass
        • Creating Passes
    • Token Gating
      • End-to-end Example
      • Code Snippets
  • 📖API Reference
    • Overview
    • Contracts
      • Deploy Contract
      • Get Contract
    • Collectibles
      • Get All Templates
      • Mint Collectible
    • Wallets
      • Create Wallet
      • Get Wallet
    • Customers
      • Create Customer
      • Get Customer
      • Delete Customer
    • Claim Links
      • Create Link
      • Update Link
    • Token Gating
      • Create Gate
  • ❓FAQ
    • Web3 101
    • Platform
Powered by GitBook
On this page
  • Verify Ownership
  • Creating a Pass
  1. Developer Guides
  2. Wallets
  3. Mobile Pass

Creating Passes

Sending a request to our platform will generate a wallet pass for mobile devices

PreviousMobile PassNextToken Gating

Last updated 2 years ago

Verify Ownership

3mint Wallet

We validate users who own a 3mint wallet automatically by leveraging their existing authentication. You can skip to the section, otherwise you must generate a signature for other crypto wallets.

Other Wallets

To create a mobile pass associated with the user's crypto wallet or NFT, their ownership must be proven. This is achieved by requesting the user to sign a message from their wallet.

We require the message to sign to be in the following format:

`Sign this message to generate a mobile pass with 3mint.io\n${userPublicAddress}\n${Date.now()}`;

The message contains the user's public wallet address and a timestamp to ensure every signed message is unique.

Using the message, a user must sign it using their crypto wallet, such as MetaMask or Coinbase wallets. This process will generate the signature which allows anyone to decrypt it using the user's associated public key for verification.

The user's wallet is responsible for signing the message and can be achieved using a web3 library such as to trigger the action. It will initiate a signing request for the user's wallet, then it is up to the user to interact and follow the wallet prompts:

// Initialize
const provider = new ethers.providers.Web3Provider(window.ethereum);

// Connect
const publicAddresses = await provider.send("eth_requestAccounts", []);

// Sign
const message = `Sign this message to generate a mobile pass with 3mint.io\n${publicAddresses[0]}\n${Date.now()}`;
const signer = provider.getSigner();
const signature = await signer.signMessage(message);

Creating a Pass

Now that we have a signature that proves the user's ownership of the wallet or NFT, we can create a request to generate a mobile pass:

const payload = {
    "userAddress": publicAddresses[0], // From previous step
    "chain": {
        "name": "evm",
        "network": 80001 // Polygon Mumbai
    },
    "signatureMessage": message, // From previous step; not required for 3mint wallet users
    "signature": signature, // From previous step; not required for 3mint wallet users
    "image": "https://path-to-image",
    "nft": { // Optional
        "contractInterface": "0xd9b67a26", // ERC-1155 = 0xd9b67a26, ERC-721 = 0x80ac58cd
        "contractAddress": "***",
        "tokenId": "***"
    },
    "pass": { // Apple example, customize as needed =>
        "description": "3mint NFT Pass",
        "logoText": "MY EVENTS",
        "labelColor": "rgb(255,153,0)",
        "backgroundColor": "rgb(0,0,128)",
        "foregroundColor": "rgb(255,255,204)",
        "appLaunchURL": "httsp://3mint.io",
        "auxiliaryFields": [
            {
                "key": "1",
                "label": "Aux 1",
                "value": "Abc"
            },
            {
                "key": "2",
                "label": "Aux 2",
                "value": "Def"
            },
            {
                "key": "3",
                "label": "Aux 3",
                "value": "Xyz"
            }
        ],
        "backFields": [
            {
                "key": "4",
                "label": "Back 1",
                "value": "Abc"
            },
            {
                "key": "5",
                "label": "Back 2",
                "value": "Def"
            },
            {
                "key": "6",
                "label": "Back 3",
                "value": "Xyz"
            }
        ],
        "headerFields": [
            {
                "key": "7",
                "label": "Header 1",
                "value": "Abc"
            },
            {
                "key": "8",
                "label": "Header 2",
                "value": "Def"
            },
            {
                "key": "9",
                "label": "Header 3",
                "value": "Xyz"
            }
        ],
        "primaryFields": [
            {
                "key": "10",
                "label": "Primary 1",
                "value": "Abc"
            },
            {
                "key": "11",
                "label": "Primary 2",
                "value": "Def"
            },
            {
                "key": "12",
                "label": "Primary 3",
                "value": "Xyz"
            }
        ],
        "secondaryFields": [
            {
                "key": "13",
                "label": "Secondary 1",
                "value": "Abc"
            },
            {
                "key": "14",
                "label": "Secondary 2",
                "value": "Def"
            },
            {
                "key": "15",
                "label": "Secondary 3",
                "value": "Xyz"
            }
        ],
        "associatedStoreIdentifiers": [0]
    }
}

With this payload, you can send the request to our 3mint endpoint, ensure your account is authenticated by providing the 3mint API key in the request header:

const response = await fetch('https://api.3mint.io/nft/pass', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    "X-API-KEY": '***'
  },
  body: JSON.stringify(payload)
});

const result = await response.json();

The result will contain the pass details including a URL for the user to download the pass to their Apple or Google wallet:

{
    "id": "***",
    "createdAt": "2023-03-01T14:43:24.528384+00:00",
    "delegation": null,
    "expireAction": null,
    "expiredAt": null,
    "externalId": null,
    "lastScannedAt": null,
    "ownerAddress": "***",
    "platform": "apple",
    "chain": {
        "name": "evm",
        "network": "80001"
    },
    "registrations": [],
    "nfts": [
        {
            "id": "***",
            "contractAddress": "***",
            "tokenId": "***",
            "contractInterface": "0xd9b67a26"
        }
    ],
    "buffer": {...},
    "fileURL": "https://api.3mint.io/api/link/laWZp4I0RRRGJQpme2hbRzcGJbaX34Yx"
}

The fileURL value can be offered as a link for the users to tap from their mobile device. It will prompt the user to add the pass to their Apple or Google wallet:

QR Code

const url = QRCode.toDataURL(response.fileURL);
...
<img src={url} width="250" height="250" alt="QR Code for Mobile Pass" />

You may create a QR code using a library, such as , to display it for the user to scan with their mobile camera by passing in the file URL from the previous response:

⌨️
qrcode
ether.js
"Creating a pass"