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

Commit

Permalink
WIP: Modular contract documentation [DO NOT MERGE] (#528)
Browse files Browse the repository at this point in the history
* Initial implementation of modular contract documentation

- Implemented overview, how it works, get started docs
- Updated sidebar to reflect the new naming and links

* created the documents for the directory of core-contracts

* created file structure for extension contracts

* created documentation for extension contracts

* updated sidebar to reflect the new changes

* fix: correctly implemments the right icon for modular contracts
  • Loading branch information
GWSzeto authored Jul 27, 2024
1 parent 1e76340 commit 668f05c
Show file tree
Hide file tree
Showing 130 changed files with 1,515 additions and 582 deletions.
Binary file added bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"escape-string-regexp": "^5.0.0",
"flexsearch": "^0.7.43",
"github-slugger": "^2.0.0",
"lucide-react": "^0.286.0",
"lucide-react": "^0.416.0",
"next": "^14.2.3",
"nextjs-toploader": "^1.6.12",
"node-html-parser": "^6.1.13",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

186 changes: 0 additions & 186 deletions src/app/contracts/build/get-started/page.mdx

This file was deleted.

26 changes: 0 additions & 26 deletions src/app/contracts/build/overview/page.mdx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { createMetadata } from "@doc";

export const metadata = createMetadata({
title: "thirdweb Modular Contracts",
description:
"Modular Contract provides a framework to build custom smart contracts more efficiently by offering a set of pre-built base contracts and reusable components, better known as extensions.",
image: {
title: "thirdweb Modular Contracts",
icon: "solidity",
},
});

# ERC-1155 Core

## Supported Callback Functions

| Function | Mode |
|----------------------|-------------|
| `beforeMintERC1155` | REQUIRED |
| `beforeTransferERC1155` | OPTIONAL |
| `beforeBatchTransferERC1155` | OPTIONAL |
| `beforeBurnERC1155` | OPTIONAL |
| `beforeApproveForAll`| OPTIONAL |
| `onTokenURI` | REQUIRED |
| `beforeBatchMintERC1155` | REQUIRED |

## Supported Interfaces

| Interface | ID |
|------------------|-------------|
| `ERC165` | `0x01ffc9a7`|
| `ERC1155` | `0xd9b67a26`|
| `ERC1155MetadataURI` | `0x0e89341c`|
| `ERC-7572` | `0xe8a3d485`|
| `ERC-173` | `0x7f5828d0`|

## Functions Supported

| Function | Description |
|-------------------------|-----------------------------------------------------------------------------|
| `constructor` | Initializes the contract with parameters for name, symbol, metadata URI, owner, extensions, and extension data. |
| `name` | Returns the name of the NFT Collection. |
| `symbol` | Returns the symbol of the NFT Collection. |
| `contractURI` | Returns the contract metadata URI. |
| `totalSupply` | Returns the total supply of a tokenId of the NFT collection. |
| `uri` | Returns the token metadata of an NFT. |
| `supportsInterface` | Checks if the contract implements an interface with the given interface ID. |
| `getSupportedCallbackFunctions` | Returns the supported callback functions. |
| `setContractURI` | Sets the contract metadata URI. Callable only by the contract admin. |
| `mint` | Mints tokens with a given tokenId to a specified address, calling the beforeMint hook. |
| `batchMint` | Batch mints tokens to a specified address, calling the beforeBatchMint hook. |
| `burn` | Burns a specified amount of tokens, calling the beforeBurn hook if it exists.|
| `safeTransferFrom` | Transfers ownership of an NFT, calling the beforeTransfer hook if it exists.|
| `safeBatchTransferFrom` | Batch transfers ownership of NFTs, calling the beforeBatchTransfer hook if it exists. |
| `setApprovalForAll` | Approves or revokes approval from an operator to transfer all NFTs. Calls the beforeApproveForAll hook if it exists. |

50 changes: 50 additions & 0 deletions src/app/contracts/modular-contracts/core-contracts/erc-20/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { createMetadata } from "@doc";

export const metadata = createMetadata({
title: "thirdweb Modular Contracts",
description:
"Modular Contract provides a framework to build custom smart contracts more efficiently by offering a set of pre-built base contracts and reusable components, better known as extensions.",
image: {
title: "thirdweb Modular Contracts",
icon: "solidity",
},
});

# ERC-20 Core

## Supported Callback Functions

| Function | Mode |
|----------------------|------------|
| `beforeMintERC20` | REQUIRED |
| `beforeTransferERC20`| OPTIONAL |
| `beforeBurnERC20` | OPTIONAL |
| `beforeApproveERC20` | OPTIONAL |

## Supported Interfaces

| Interface | ID |
|-----------------|-------------|
| `ERC165` | `0x01ffc9a7`|
| `ERC-7572` | `0xe8a3d485`|
| `ERC-173` | `0x7f5828d0`|
| `ERC20` | `0x36372b07`|

## Functions Supported

| Function | Description |
|-------------------------|-----------------------------------------------------------------------------|
| `constructor` | Initializes the contract with parameters for name, symbol, metadata URI, owner, extensions, and extension data. |
| `name` | Returns the name of the token. |
| `symbol` | Returns the symbol of the token. |
| `contractURI` | Returns the contract metadata URI. |
| `getSupportedCallbackFunctions` | Returns the supported callback functions. |
| `supportsInterface` | Checks if the contract implements an interface with the given interface ID. |
| `setContractURI` | Sets the contract metadata URI. Callable only by the contract admin. |
| `mint` | Mints tokens to a specified address, calling the beforeMint hook. |
| `burn` | Burns a specified amount of tokens, calling the beforeBurn hook if it exists.|
| `transfer` | Transfers tokens to a specified address, calling the beforeTransfer hook if it exists. |
| `transferFrom` | Transfers tokens from one address to another, calling the beforeTransfer hook if it exists. |
| `approve` | Approves a spender to spend tokens on behalf of an owner, calling the beforeApprove hook if it exists. |
| `permit` | Sets allowance based on token owner's signed approval, calling the beforeApprove hook if it exists. |

Loading

0 comments on commit 668f05c

Please sign in to comment.