Our PDK generators will accept a Patchwork project configuration file as input and will generate the same name solidity contract as output in the current working directory.

Here’s an example Patchwork project configuration:

patchwork.config.ts
import { Feature, FunctionConfig, ProjectConfig } from "@patchworkdev/common/types";

const exampleConfig: ProjectConfig = {
    name: "ExampleProjectConfig",
    scopes: [
        {
            name: "test",
            owner: "0x222222cf1046e68e36E1aA2E0E07105eDDD1f08E",
            whitelist: true,
            userAssign: false,
            userPatch: false,
            bankers: ["0x000000254729296a45a3885639AC7E10F9d54979", "AccountPatch"],
            operators: ["0x000000111129296a45a3885639AC7E10F9d54979", "AccountPatch"],
        }
    ],
    contracts: {
        AccountPatch: {
            scopeName: "test",
            name: "AccountPatch",
            symbol: "AP",
            baseURI: "https://mything/my/",
            schemaURI: "https://mything/my-metadata.json",
            imageURI: "https://mything/my/{tokenID}.png",
            fields: [
                {
                    id: 1,
                    key: "name",
                    type: "char32",
                    description: "Name",
                    functionConfig: FunctionConfig.ALL,
                },
                {
                    id: 2,
                    key: "patches",
                    type: "literef",
                    description: "Contract2",
                    arrayLength: 4,
                }
            ],
            features: [Feature.ACCOUNTPATCH],
            fragments: ["SecondContract"]
        },
        SecondContract: {
            scopeName: "test",
            name: "SecondContract",
            symbol: "SC",
            baseURI: "https://mysecondthing/my/",
            schemaURI: "https://mysecondthing/my-metadata.json",
            imageURI: "https://mysecondthing/my/{tokenID}.png",
            fields: [
                {
                    id: 1,
                    key: "description",
                    type: "char32",
                    description: "Description",
                    functionConfig: FunctionConfig.ALL,
                }
            ],
            features: [Feature.PATCH, Feature.FRAGMENTSINGLE],
            fragments: []
        }
    },
    plugins: [{ name: "ponder" },{ name: "react" }],
};

export default exampleConfig;

From this file, we can generate Solidity boilerplate, indexer schemas, React hooks and more.

Project configuration

NameDescription
nameThe name of your app
scopesScope configuration records
contractsContract configuration records
contractRelationsContract relations records
networksNetwork configuration records

Contract configuration

NameDescription
scopeNameThe scope name of the contract
nameThe ERC-721 Name of the contract
symbolThe ERC-721 symbol of the contract
baseURIThe base URI
schemaURIThe schema URI
imageURIThe image URI
featuresList of features
fieldsList of fields

Contract fields

NameDescription
idThe field ID (must be unique)
keyThe field key (must be unique)
typeThe field Type (Must be in field type enum)
arrayLengthThe array length (1 is default, 0 is dynamic and >1 is a static array)
descriptionThe field description

Contract field types

NameDescription
booleanA boolean type (true or false)
int8An 8-bit signed integer.
int16A 16-bit signed integer.
int32A 32-bit signed integer.
int64A 64-bit signed integer.
int128A 128-bit signed integer.
int256A 256-bit signed integer.
uint8An 8-bit unsigned integer.
uint16A 16-bit unsigned integer.
uint32A 32-bit unsigned integer.
uint64A 64-bit unsigned integer.
uint128A 128-bit unsigned integer.
uint256A 256-bit unsigned integer.
char8An 8-character string (64 bits).
char16A 16-character string (128 bits).
char32A 32-character string (256 bits).
char64A 64-character string (512 bits).
bytes8A fixed-length byte array of 8 bytes (64 bits).
bytes16A fixed-length byte array of 16 bytes (128 bits).
bytes32A fixed-length byte array of 32 bytes (256 bits).
literefA 64-bit Literef reference to a patchwork fragment.
addressA 160-bit address.
stringA dynamically-sized string.

Contract features

NameDescription
FRAGMENTMULTIA multi-assignable fragment
FRAGMENTSINGLEA single-assignable fragment
PATCHA 721 patch
PATCHACCOUNTAn account patch
PATCH1155An 1155 patch
MINTABLEMintable
REVERSIBLEReversible (patch)