floornfts / mobile-minting

Enable instant onchain delivery with in-app purchases. MintTemplates teach Mobile Minting to mint on new platforms.
MIT License
8 stars 8 forks source link

What is Mobile Minting?

Mobile Minting unlocks mobile payments for onchain purchases and powers minting in the Floor app.

πŸ“± Users pay in-app with In-App Purchases

⛓️ A fleet of signers instantly deliver NFTs onchain

For users: no πŸŒ‰ Bridging, no ⛽️ Gas fees - just the tap of a button!

mm

Example Mobile Minting user experience.


What is this repository?

This repository is a public, contributable collection of Ingestors that teach Mobile Minting how to support mints from new platforms.

Historically, only Floor could choose what mints users could mint through Floor based on our roadmap, or partnerships, now anyone can build support for any minting platform / product and (provided it meets some safety & reliability checks) it can be included in Mobile Minting.

This library is included in Floor's platform and executed in a sandboxed environment for indexing mints.


Adding a new platform to Mobile Minting

Today, Mobile Minting supports the following creator platforms:

Platform Chains Create from URL Create from onchain address Supports Quantity
Zora Base, Zora βœ… βœ… βœ…
Highlight Base βœ… βœ… βœ…
Rodeo Base βœ… βœ… βœ…
Manifold Base βœ… ❌ ❌
FXHash Base βœ… βœ… ❌
Rarible Base βœ… βœ… ❌
Foundation Base, ETH βœ… ❌ ❌
Prohibition Daily Base βœ… βœ… ❌
Transient Labs Base βœ… βœ… ❌

Adding a new platform to Mobile Minting is easy - you just have to write a MintIngestor!

MintIngestor functionality

A MintIngestor has a simple job:

Transform a URL or contract address into a valid MintTemplate, iff it represents a supported mint by the ingestor

template


What is a MintTemplate?

A MintTemplate is a standard format for expressing the details of a mint. It's used to populate the marketing page, pricing, and ultimately fulfill the item onchain.

mint-template

Mapping of MintTemplate fields to an in-app mint.

Once you generate a MintTemplate, Floor will do all the additional work to get the mint live:

The full process looks something like this...

mint-template-flow


Writing your first MintIngestor

We recommend consulting example complete ingestor PRs e.g. #1: Prohibition Daily.

You will create a new folder in src/ingestors for your new Ingestor.

export class MyMintIngestor implements MintIngestor {
  async supportsUrl(resources: MintIngestorResources, url: string): Promise<boolean> {
    // check if URL is supported by your ingestor
  }

  async supportsContract(resources: MintIngestorResources, contract: MintContractOptions): Promise<boolean> {
    // check if the contract is supported by the ingestor
  }

  async createMintTemplateForUrl(resources: MintIngestorResources, url: string): Promise<MintTemplate> {
    // create the mint template for your URL
  }

  async createMintForContract(resources: MintIngestorResources, contract: MintContractOptions): Promise<MintTemplate> {
    // create the mint template for your contract
  }
}

For building the MintTemplate, we recommend using the MintTemplateBuilder which will ensure validation and give handy builder methods.

In this example we make a template, relying on getMintMetadataFromSomewhere() and getMintContractDetailsFromSomewhere() to fetch the marketing & onchain data respectively. We'll touch on those later.

  const mintBuilder = new MintTemplateBuilder()
      .setOriginalUrl(url)
      .setMintInstructionType(MintInstructionType.EVM_MINT)
      .setPartnerName('MyMints');

  const { name, description, image } = await getMintMetadataFromSomewhere();
  mintBuilder.setName(name).setDescription(description).setFeaturedImageUrl(image);

  const { contractAddress, priceWei } = await getMintContractDetailsFromSomewhere();
  mintBuilder.setMintInstructions({
      chainId: '8453',
      contractAddress,
      contractMethod: 'mint',
      contractParams: '[address, 1]',
      abi: YOUR_ABI_FILE_IMPORT,
      priceWei: totalPriceWei,
    });

Note: You will typically want to implement either createMintForContract or createMintTemplateForUrl, and then call that one from the other.

You can then build the MintTemplate from the builder.

  return mintBuilder.build();

Note that mintBuilder.build() will throw if the MintTemplate does not meet validation requirements.


Getting outside resources

Your MintIngestor is passed a resources object in it's sandboxed environment.

async createMintTemplateForUrl(url: string, resources: MintIngestorResources): Promise<MintTemplate>

This resources object contains properties:

You can use these to fetch resources you need.

Note: You will need to set up a locally Alchemy key for testing, and YOU MUST NOT attempt to import resources not passed in the resources object


Local Setup

In order to use the Alchemy instance on resources, you will need to set a local Alchemy key.

This repo uses Yarn to manage dependencies & execution.

When you pull the repository, setup can be completed (and confirmed) using:

yarn
yarn test


Trying out your Mint Ingestor

You can try your mint ingestory using yarn dry-run -- this will:

yarn dry-run <minterSlug> <inputType> <input>

<minterSlug>: The key for the ingestor in ALL_MINT_INGESTORS <inputType>: url or contract <input>: A full URL for url, or a colon delimited fullly qualified address for `contract

Examples:

yarn dry-run prohibition-daily url https://daily.prohibition.art/mint/8453/0x896037d93a231273070dd5f5c9a72aba9a3fe920
yarn dry-run prohibition-daily contract 8453:0x896037d93a231273070dd5f5c9a72aba9a3fe920
yarn dry-run some-erc-1155-ingestor contract 8453:contractAddress:tokenId

Submitting a Mobile Minting Ingestor

Once you've written a Mobile Minting Ingestor, it needs to be Pull Requested to this repository to be included in the production Floor Mobile Minting ingestion fleet.

Before you submit

Submitting a Mint Ingestor

Open a Pull Request against this repo with your new Ingestor, as well as any comments / questions.

We're excited to see new platforms supported, so will quickly jump to help!

Hopes and dreams

Mobile Minting started out entirely internal & this is our first experiment in decentralizing it & making it more accessible.

In time, we hope to continue down this path, but for now all ingestors will be reviewed by the Floor engineering team & accepted on the basis of safety, cost & other considerations by Floor.

We hope to see people (other companies!?) emerge for whom Mobile Minting, and a unified standard for expressing onchain mints is useful, and look forward to working with them to continue this mission.

Questions?

Open an issue, or email developers@floor.fun