Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Signature Minting Documentation (#886)
Browse files Browse the repository at this point in the history
* initial structure

* overview

* how it works

* getting started

* add references to overview

* add missing import

* create tiles rather than bullets
  • Loading branch information
ciaranightingale authored Sep 15, 2023
1 parent 9b9aa53 commit e63730a
Show file tree
Hide file tree
Showing 6 changed files with 630 additions and 1 deletion.
207 changes: 207 additions & 0 deletions docs/onboarding/24 Signature Minting/0 Overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
---
slug: /signature-minting
title: Overview
hide_title: true
---

import QuickstartCard from "@components/QuickstartCard";
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

# Signature Minting

Signature Minting, also known as "on-demand minting," allows a contract administrator to grant users the ability to mint tokens from a contract that implements one of the extensions: [`ERC721SignatureMint`](/solidity/extensions/erc721signaturemint), [`ERC1155SignatureMint`](/solidity/extensions/erc1155signaturemint) or [`ERC20SignatureMint`](/solidity/extensions/erc20signaturemint). This action requires a cryptographic signature and is limited to wallets assigned the **`MINTER`** role.

This allows you to conditionally generate signatures based on some condition/criteria, or allow a user to mint tokens with admin or user-specified metadata.

## Features

- **Ownership Verification**: By requiring a signature, the system can ensure that the entity trying to mint a token has the right to do so.
- **Data Integrity**: The cryptographic signature ensures that if the transaction data is altered, the signature becomes invalid.
- **Enhanced Security**: Only **`MINTER`**-designated wallets can generate signatures, and only entities with the correct signature can mint tokens.
- **Smart Contract Control**: By incorporating signature verification within the smart contract, you can add additional security logic around the minting process.
- **Reduced Risk of Human Error**: Automated systems that require cryptographic signatures for minting are generally less prone to human error than manual methods.
- **Custom metadata:** In the case of minting NFTs with signature minting, you can allow users to add custom artwork for their NFT metadata.
- **Whitelisting:** Decide on a case-by-case basis whether a user can claim and what their claim conditions are.

## Use Cases

Signature minting facilitates a range of use cases including, but not limited to:

- [Allowing NFT holders to mint for free](https://blog.thirdweb.com/guides/signature-drop/)
- [Creating a community-made NFT collection](https://blog.thirdweb.com/guides/mint-nft-unique-code/)
- [Restricted mints to users who are GitHub contributors](https://blog.thirdweb.com/guides/allow-github-contributors-to-mint-an-nft/)
- [Restricted mints to Discord members](https://github.com/thirdweb-example/community-rewards)
- Allowing users to add custom artwork for their NFTs metadata
- Marking NFT metadata with user-specific or off-chain information

## Signature Minting in the Solidity SDK

### Base Contracts

<div className="row" style={{ marginBottom: 24 }}>
<div className="col col--4" style={{ marginTop: 8 }}>
<QuickstartCard
name="ERC721 Signature Mint Base Contract"
link="/solidity/base-contracts/erc721signaturemint"
image="/assets/product/sdk.png"
/>
</div>
<div className="col col--4" style={{ marginTop: 8 }}>
<QuickstartCard
name="ERC1155 Signature Mint Base Contract"
link="/solidity/base-contracts/erc1155signaturemint"
image="/assets/product/sdk.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="ERC20 Signature Mint Base Contract"
link="/solidity/base-contracts/erc20signaturemint"
image="/assets/product/sdk.png"
/>
</div>
</div>

### Extensions

Add signature minting to your smart contract by using the following extensions:

<div className="row" style={{ marginBottom: 24 }}>
<div className="col col--4" style={{ marginTop: 8 }}>
<QuickstartCard
name="ERC721 Signature Mint Extension"
link="/solidity/extensions/erc721signaturemint"
image="/assets/product/sdk.png"
/>
</div>
<div className="col col--4" style={{ marginTop: 8 }}>
<QuickstartCard
name="ERC1155 Signature Mint Extension"
link="/solidity/extensions/erc1155signaturemint"
image="/assets/product/sdk.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="ERC20 Signature Mint Extension"
link="/solidity/extensions/erc20signaturemint"
image="/assets/product/sdk.png"
/>
</div>
</div>

## Pre-Built Contracts Implementing Signature Minting

<div className="row" style={{ marginBottom: 24 }}>
<div className="col col--12" style={{ marginTop: 8 }}>
<QuickstartCard
name="Signature Drop Pre-Built Contract"
link="/pre-built-contracts/signature-drop"
image="/assets/product/contracts.png"
/>
</div>
</div>

Example use cases that the thirdweb pre-built contracts solve:

1. **Self-Minting**: For example, a user can mint their Twitter profile picture as an NFT on their own contract.
2. **Audience Minting**:
- **Pre-defined Content**: The admin pre-determines the nature of tokens, such as in a 10k NFT drop.
- **Dynamic Content**: Tokens are not pre-defined, enabling real-time customization like a course completion certificate with the participant's name.

By implementing Signature Minting, you are adopting a scalable, secure, and versatile mechanism for minting digital assets.

## Using Signature Minting in the SDKs

### ERC721SignatureMint

<div className="row" style={{ marginBottom: 12 }}>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="TypeScript"
link="/typescript/sdk.erc721signaturemint"
image="/assets/languages/typescript.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Python"
link="/python/python.erc721signaturemint"
image="/assets/languages/python.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Go"
link="/go/erc721_signature_minting"
image="/assets/languages/go.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Unity"
link="/unity/erc721signaturemint"
image="/assets/languages/unity.webp"
/>
</div>
</div>

### ERC1155SignatureMint

<div className="row" style={{ marginBottom: 12 }}>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="TypeScript"
link="/typescript/sdk.erc1155signaturemint"
image="/assets/languages/typescript.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Python"
link="/python/python.erc1155signaturemint"
image="/assets/languages/python.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Go"
link="/go/erc1155_signature_minting"
image="/assets/languages/go.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Unity"
link="/unity/erc1155signaturemint"
image="/assets/languages/unity.webp"
/>
</div>
</div>

### ERC20SignatureMint

<div className="row" style={{ marginBottom: 12 }}>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="TypeScript"
link="/typescript/sdk.erc20signaturemint"
image="/assets/languages/typescript.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Python"
link="/python/python.erc20signaturemint"
image="/assets/languages/python.png"
/>
</div>
<div className="col col--4" style={{ padding: 8 }}>
<QuickstartCard
name="Unity"
link="/unity/erc20signaturemint"
image="/assets/languages/unity.webp"
/>
</div>
</div>
47 changes: 47 additions & 0 deletions docs/onboarding/24 Signature Minting/1 How it Works.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
slug: /signature-minting/how-it-works
title: How it Works
hide_title: true
---

# How it Works

The 'signature minting' mechanism is a way for a contract admin to authorize an external party's request to mint tokens on the admin's contract.

Any wallet with the `ADMIN` role can sign a ['payload' or 'mint request'](#terms) that specifies e.g. what address should the tokens be minted to, what price should be collected in exchange for the minted tokens, the metadata, etc.

Any external party can then present the payload, along with the signature generated from a contract admin to the smart contract that implements a `SignatureMint` extension. Tokens will then be minted according to the information specified in the payload.

## Signature Minting Technical Steps

Contracts that have signature minting enabled have to inherit from the `SignatureMint` extension.

- Deploying a contract, either via Explore or a custom contract, that inherits from one of the `SignatureMint` extensions.
- An **`ADMIN`** role wallet generates a signed payload that outlines the specifics of the minting request, typalling using the [SDK](typescript/sdk.erc721signaturemint). For details on payload fields, refer to the **[Terms section](#terms)** below.
- A wallet, typically belonging to a user, invokes the **`mintWithSignature`** function using the supplied payload to mint the token. This is easiest when performed using the (Contract SDK)[/sdk].

## Terms

- `MintRequest` or Payload

The fields in `MintRequest` are what make up a payload or 'mint request'. This is the payload that a contract admin signs off, to be used by an external party to mint tokens on the admin's contract.

When any external party presents a payload to the contract implementing the 'signature minting' extension,
tokens are minted exactly according to the information specified in the presented `MintRequest`.

```solidity
struct MintRequest {
address to;
address royaltyRecipient;
uint256 royaltyBps;
address primarySaleRecipient;
uint256 tokenId;
string uri;
uint256 quantity;
uint256 pricePerToken;
address currency;
uint128 validityStartTimestamp;
uint128 validityEndTimestamp;
bytes32 uid;
}
```
Loading

1 comment on commit e63730a

@vercel
Copy link

@vercel vercel bot commented on e63730a Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.