Off-chain minting

What is off-chain minting?

Minting ERC-721 on-chain has become increasingly expensive as Ethereum and gas prices have risen. A traditional ERC-721 minting costs today between 100,000 to 200,000 gas per asset. These prices are prohibitively expensive for many use cases. Off-chain minting solves this problem.

off chain minting

Step 1: The application sends a minting request.

Off-chain minting is a StarkEx operation enabling the off-chain creation of assets. It consists of assigning a new assetId and an amount that describes the asset to a specific StarkKey.

This asset is created off-chain and does not have yet an on-chain representation. The assetId is encoded in a compressed form called the Minting Blob, which is required in order to withdraw on-chain. For the assetId definition, see starkex-specific-concepts.adoc#mintable-erc721 in StarkEx Specific Concepts.

The Minting Blob is not stored on-chain and should be received out of band.

Step 2: StarkEx checks the validity of the minting request.

To ensure that StarkEx cannot create any arbitrary assetId (for instance, minting a large amount of ETH), off-chain minting can only create a mintable assetId if it respects the following conditions:

  • The operation does not overwrite an existing Vault

  • Bit 251 of the assetId must be 1

Technically, the operation is defined as the change from an empty account to an account containing an StarkKey, a mintable assetId and an amount.

The operator cannot remint the same asset.

Step 3: Withdraw And mint

To be fully non-custodial, a mintable asset must be paired with an on-chain contract in which the asset will be minted. When your user withdraws from off-chain to on-chain, your application is required to do the following:

  1. Call withdrawAndMint

  2. Provide the mintingBlob to enable the asset contract to create the token.