GithubHelp home page GithubHelp logo

creator-core-solidity's Introduction

manifoldxyz-creator-core-solidity

The Manifold Creator Core Contracts

A library for extendible creator contracts.

  • Implementation for ERC721
  • Implementation for ERC1155

The Manifold Creator Core contracts provide creators with the ability to deploy an ERC721/ERC1155 NFT smart contract with basic minting functionality, on-chain royalties and permissioning. Additionally, they provide a framework for extending the functionality of the smart contract by installing extension applications.

These contracts are used in the Manifold Studio.

This enables creators to use the same underlying Manifold Creator Core contract to continue creating new and innovative NFT's and experiences.

See our developer documentation and blog post for more information.

Go here for example applications that have been added to Manifold Creator Core contracts.

Overview

Installation

$ npm install @manifoldxyz/creator-core-solidity

Usage

Once installed, you can use the contracts in the library by importing them:

pragma solidity ^0.8.0;

import "@manifoldxyz/creator-core-solidity/contracts/ERC721Creator.sol";

contract MyContract is ERC721Creator  {
    constructor() ERC721Creator ("MyContract", "MC") {
    }
}

The available contracts are:

  • ERC721Creator
  • ERC721CreatorUpgradeable - A transparent proxy upgradeable version of ERC721Creator
  • ERC721CreatorEnumerable - Note that using enumerable significantly increase mint costs by around 2x
  • ERC1155Creator

Manifold Studio currently makes use of ERC721Creator and ERC1155Creator

Extension Applications

The most powerful aspect of Manifold Creator Core contracts is the ability to extend the functionality of your smart contract by adding new Extension Applications (Apps). Apps have the ability to override the following functionality for any token created by that App:

ERC721

  • mint
  • tokenURI
  • transferFrom/safeTransferFrom pre-transfer check
  • burn pre-burn check
  • define royalties for extension minted tokens

ERC1155

  • mint
  • uri
  • safeTransferFrom pre-transfer check
  • burn pre-burn check
  • define royalties for extension minted tokens

In order to create an app, you'll need to implement one or more interfaces within contracts/extensions, deploy the new app and register it to the main Creator Core contract using the registerExtension function (which is only accessible to the contract owner or admins).

Example applications can be found here.

Running the package unit tests

forge test

creator-core-solidity's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

creator-core-solidity's Issues

No contract addresses

There are no contract addresses to show where the Manifold Creator contract implementations are deployed.

max code size exceeded

I'm trying to follow the README example and I'm getting a deployment error:

ProviderError: max code size exceeded

Screen Shot 2022-05-07 at 5 29 21 PM

Here's my contract:

pragma solidity ^0.8.0;

import "@manifoldxyz/creator-core-solidity/contracts/ERC721Creator.sol";

contract Greeter is ERC721Creator {
    constructor() ERC721Creator("MyContract", "MC") {}
}

deploy script

async function main() {
  const Greeter = await hre.ethers.getContractFactory("Greeter");
  const greeter = await Greeter.deploy();

  await greeter.deployed();

  console.log("Greeter deployed to:", greeter.address);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Can you help?

Support EIP-4906 Metadata Update event for ERC721

EIP-4906 allows for the following events to be fired to signal to consumers that the JSON metadata for a token or set of tokens has changed.

event MetadataUpdate(uint256 _tokenId);
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);

It would be great if the creator core interfaces could support this to be triggered either by an extension or an admin. For instance, when the claim is updated for LazyMintable, the extension could call back into the creator contract to trigger a refresh of all tokens in the contract. Additionally, custom extensions or admins who are controlling metadata with other off-chain methods could manually trigger this when metadata is changed.

This functionality is natively supported by OpenSea to trigger a refresh of the metadata for the specified token ids.

Most Gas Efficient Way to Deploy Programmatically (Max Size Exceeded)

Hi, noticing that when I try creating a contract that is an ERC1155Creator, I run into the problem of max size exceeded. This was the source code below. I tried use an optimizer with less runs and that seems to work but wondering if I'm missing something:

pragma solidity ^0.8.0;

import "@manifoldxyz/creator-core-solidity/contracts/ERC1155Creator.sol";

contract TestContract is ERC1155Creator  {
    constructor() ERC1155Creator("TestContract", "MC") {
    }
}

If I wanted to programmatically create many contracts like this, how would you suggest doing so? I'm wondering if importing directly from NPM package is more costly than importing the files myself. The context here is I'm trying to create a similar UX to manifold studios, but wondering the best way to go about it.

`ERC721Creator` is not compilable with latest OpenZeppelin version

It looks like in the latest OpenZeppelin (4.8.x) they have change the signature of a function.

It still works in v4.7.x

The function _beforeTokenTransfer() has an extra parameter.

So, if I try and compile code using ERC721Creator I get this compile error:

TypeError: Function has override specified but does not override anything.
  --> @manifoldxyz/creator-core-solidity/contracts/ERC721Creator.sol:27:95:
   |
27 |     function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
   |                                                                                               ^^^^^^^^

Versions:

"@openzeppelin/contracts": "^4.8.1",
"@manifoldxyz/creator-core-solidity": "^2.0.2",

Error - Initializable: contract is already initialized

I first used your contract as a submodule and got this error in my hardhat unit tests:

    const ERC1155Impl: ContractFactory = await ethers.getContractFactory(
      "ERC1155CreatorImplementation"
    );
    const implementationContract = await ERC1155Impl.deploy();
    await implementationContract.deployTransaction.wait();
    await implementationContract.initialize("Name", "Symbol"); // error: Initializable: contract is already initialized

Then just to verify the error, I cloned this repo, deployed ERC1155CreatorImplementation to Goerli and verified the contract using Foundry. I then went to etherscan and tried to initialize the contract, but then I got this error (which I also could double and triple check with Tenderly).

forge create --rpc-url https://eth-goerli.g.alchemy.com/v2/rpc_key --private-key private_key --verify contracts/ERC1155CreatorImplementation.sol:ERC1155CreatorImplementation --etherscan-api-key api_key

In foundry.toml I added:

solc = "0.8.16"
optimizer = true
optimizer_runs = 1

If I had to guess, it has to do with OpenZeppelin deprecating isContract() which now instead should be like address(this).code.length == 0, and perhaps there's a mismatch between versions?

Please let me know if you can reproduce.

Setbasetokenuri not working

See issue in forum. . Writing to the proxy function goes through, but the base url never changes. Also on a separate contract, setTokenUri is not working, and is giving the error "invalid tokenId" when I am using a correct token Id.

Creator contracts contain dead code in their runtime bytecode, can be optimized

Hi,
We (Dedaub) recently reported a solc issue which results in the inclusion of functions that are used only during contract construction to the runtime bytecode. We ran some experiments at scale to assess the bug's impact of and found thousands of deployments of contracts extending your Creator proxies.

You can read more details in our medium post. Bottom line is 500 of the 800 bytes of the deployed bytecode of your contracts is dead code, increasing your deployment costs. Alternatively, the --via-ir pipeline is not affected by that bug and produces a bytecode of 258 bytes.

totalSupply()

I can't find a totalSupply() function like in other contracts, how do you get the totalSupply with Manifold contracts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.