πŸ’§ ERC-1155

Deploy and mint ERC-1155 tokens

Overview

The CoCreate API provides functionality for ERC-1155 contract deployment & management, including creating new ERC-1155 contracts, minting, transferring, setting royalty fees, and managing token transfer restrictions.

ERC-1155 Model

The CoCreate API uses a model that includes the following attributes:

FieldDescriptionTypeOptional
idA unique identifier for identifying the ERC-1155 contract within Co:Create. Generated by Co:Create platform and returned upon successful contract deployment.stringNo
contract addressA unique identifier for identifying the ERC-1155 contract within the Polygon blockchain ecosystem. Generated by Co:Create platform and returned upon successful contract deployment.stringNo
nameThe token name of the contract.stringNo
symbolThe token symbol of the contract.stringNo
base_uriThe base uri of the contract. This should have a trailing slash. The URL for each token is base_uri + token_id.stringNo
royalty_basis_pointsThe royalty basis points for the contract. This is the percentage of the sale price that the creator will receive. Example: 1000 basis points correspond to a 10% royalty.numberYes
royalty_address_recipientThe wallet address that will receive the royalty payments.stringYes
transfer_restrictedIf true, the tokens are transfer restricted. If false, the tokens are transferable. Default is false.booleanYes
transfer_allowlistThe list of wallet addresses that are allowed to transfer the tokens. This is only used if transfer_restricted is true. Default is an empty list.[string]Yes

Methods

The CoCreate API provides the following methods for creating & managing ERC-1155 tokens:

NameMethodDescription
Deploy New ERC1155 ContractPOSTCreate and deploy a new ERC-1155 contract.
List ERC1155 ContractsGETGet a list of all ERC-1155 contracts for an organization.
Patch ERC1155 ContractPATCHManage any config on the ERC-1155 contract, e.g., transfer restrictions.
Mint ERC1155 TokenPOSTMint ERC-1155 tokens to a specified wallet address.
Transfer ERC1155 TokenPOSTTransfer ERC-1155 tokens from one wallet address to another.

Guide

Create a new ERC-1155 contract

To create a new ERC-1155 contract, make a POST request to the ERC1155 API.

Example request:

curl --request POST \
  --url https://api.testcocrt.xyz/alpha/erc1155 \
  --header 'Authorization: Bearer <YOUR_KEY_HERE>' \
  --data '{ "name": "Karma Points", "symbol": "KRMA"}'

Example response:

{
  "data": {
    "contract_address": "0x30391925aB782008FEBE2fbf05Ea043ec966831c",
    "created_at": "2023-02-23T06:57:11.352161+00:00",
    "id": "b49da6ec-d7bb-43f3-919c-3fce33b5de22",
    "name": "Karma Points",
    "symbol": "KRMA"
  }
}

Mint ERC-1155 to a user

To mint ERC-1155, make a POST request to the Mint method of the ERC1155 API.

The body parameters for wallet_addresses, token_ids, and mint_quantities are all specified as arrays. To mint tokens to a single user, specify the arrays as an array of 1.

πŸ“˜

Specify token IDs with ERC-1155

When minting ERC-1155 tokens, you need to specify the token IDs which you would like to mint to the user, since multiple users can hold the same token IDs & amounts.

curl --request POST \
     --url https://api.cocrt.xyz/alpha/erc1155/mint \
     --header 'Authorization: Bearer YOUR_API_KEY_HERE' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "wallet_addresses": [
    "0xaaa5623dc643ae463e4bf65dd267bf668750152b",
    "0xbb6fdb5252825ef15207e7973b94598e7c221e35",
    "0xd6e3b62b8b78f7bab557017de19b3eb1a5e55aab"
  ],
  "erc1155_id": "cd777366-6288-4aec-ae34-9cf72d6b44f4",
  "token_ids": [
    1,
    2,
    2
  ],
  "mint_quantities": [
    100,
    200,
    300
  ]
}
'

Example response:

{
  "data": {
    "erc1155_id": "9795f10e-dfe7-42b5-aac9-c296605ad81c",
    "contract_address": "0x9fd5c6b178395b1c628eb2cd8ffdf2ec92b4e351",
    "batch_mint_result": {
      "0xaaa5623dc643ae463e4bf65dd267bf668750152b": {
        "1": 100
      },
      "0xbb6fdb5252825ef15207e7973b94598e7c221e35": {
        "2": 200
      },
      "0xd6e3b62b8b78f7bab557017de19b3eb1a5e55aab": {
        "2": 300
      }
    }
  }
}

πŸ‘

Get Help

If you get stuck at any time, reach out to us on Discord or contact us via email at [email protected].