Skip to main content

Creating a Contract

All 1155 contracts created from Zora are deployed by calling a central factory contract. When calling this factory it will deploy a minimal proxy contract that is upgradeable. All upgrades are opt-in and must be done manually on a per contract basis by the user.

Calling the Factory Contract#

The createContract function on the factory is responsible for deploying a new 1155 contract. The setupActions parameter allows for multiple actions to be called when deploying the contract. Such as creating a token and sale in the same transaction as deploying the contract.

  • contractURI: The URI for the contract metadata
  • name: The name of the contract
  • defaultRoyaltyConfiguration: The default royalty configuration for the contract
  • defaultAdmin: The default admin for the contract
  • setupActions: The actions to perform on the new contract upon initialization (optional)
function createContract(    string memory contractURI,    string calldata name,    ICreatorRoyaltiesControl.RoyaltyConfiguration memory defaultRoyaltyConfiguration,    address defaultAdmin,    bytes[] calldata setupActions) external returns (address)

The contract supports multicall so multiple functions can be called to set up the contract in a single transaction.

Royalty Configuration#

The defaultRoyaltyConfiguration sets contract-wide royalties. Note, that royalties can also be set at the token level. The parameter can be passed in with the following details:

  • royaltyMintSchedule: 1/N tokens are minted to the royalty recipient
  • royaltyBPS: The royalty amount in basis points for secondary sales.
  • royaltyRecipient: The address that will receive the royalty payments.
struct RoyaltyConfiguration {    uint32 royaltyMintSchedule;    uint32 royaltyBPS;    address royaltyRecipient;}

Supply Royalty#

When selling a token, a creator has the opportunity to reserve a certain percentage of the tokens minted for themselves. The tokens are minted to them as the mints occur using the royaltyMintSchedule.

getRoyalties can be called on a contract to view the royalty info a specific token. Calling it with tokenId 0 will return the contract level information.

function getRoyalties(uint256 tokenId) public view returns (RoyaltyConfiguration memory)  

Contract URI#

The Contract URI contains contract specific details. This metadata is stored in a JSON file on IPFS. The uri is retrieved via the contractURI() call on the contract.

type CollectionMetadata = {  name?: string  description?: string  image?: string  imageURI?: string  animation_url?: string  animationURI?: string  seller_fee_basis_points?: string  seller_fee_recipient?: string  storefront?: {    theme?: StorefrontTheme  }}

Setup Actions#

An optional param that is encoded function data that can be passed in and can call a separate function within the contract. This allows creating a token and setting permissions in the same transaction of creating the contract. Actions that can be called:

  • Creating a token
  • Setting the salesConfig
  • Granting permissions/minter role
  • Admin minting tokens