Coder Social home page Coder Social logo

company-dao-solidity's People

Contributors

stanwolverine avatar

Stargazers

 avatar

Watchers

 avatar

company-dao-solidity's Issues

Optimize ERC1155KnownTokens contract

Goal:

  • This contract is for tracking tokens that can be minted.
  • for a given token id, say 1, we need to check if token with id 1 can be minted or not

Current Mechanism:

  • We are storing mintable tokens in mapping(uint256 => string) private _tokens;
  • _tokens also store tokenName as string

Problem:

  • We are storing tokenName as string on-chain, which is not needed.
  • tokenName can be stored in metadata of token
  • This is increasing gas cost.

Proposal:

  • We can just store numbers as mintable token ids i.e. [1, 2, 3].
  • In above example, token ids 1, 2 and 3 are mintable, but token id 4 is not.
  • To optimize above more:
  • We can only store one number and increment it when we need to add another mintable token
  • example, if number = 3, then we can think it like - approved_token_ids => 0 < tokenId <= number
  • as per above equation, tokenIds = [1, 2, 3] are mintable and tokenIds = [0, 4, 5] are not mintable.

Code Refactoring v1

  • add await txn.wait() after contract state change call
  • setup chai custom matchers with mocha OR chai instead of hardhat, because setup with hardhat will only work when we run tests with hardhat.
  • remove onlyOwner modifier from functions with internal visibility

Membership NFT metadata storage

  • create contract to handle storage of uri of membership nfts

  • requirements:

  1. store ipfs uris
  2. add uri after contract has been deployed
  3. get uri of a token
  4. get uris of tokens? (not sure right now)

Note: contract should be gas friendly, make needed optimizations

Integrate ERC1155KnownTokens with ERC1155URIStorage

  • integrate ERC1155KnownTokens with ERC1155URIStorage via another minting contract
  • owner shouldn't be able to approve token (_addToken) without setting token URI (_setURI) , if a new token is being approved, then we have to also set uri for it.
  • owner can also change URI for token.

create ERC1155MaxSupply

  • create ERC1155MaxSupply contract to handle max supply of token with id id.
  • this contract will inherit openzeppelin's ERC1155TotalSupply contract to track already minted token with id id

Restrict mintable Token IDs

Prevent user to mint token with any token id.

  • In openzeppelin ERC1155 contract, _mint function can be called with any number as token id. This will mint new NFT with given token Id.
  • We need some way to prevent user to mint NFT with any number as id.
  • User should be able to mint only token with known and approved token ids.

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.