metalithio / niftex-gr8-hackathon

0 stars 0 forks source link

Bounty: Minimize the gas cost of deploying many ERC20s #1

Open jmahhh opened 3 years ago

jmahhh commented 3 years ago

Challenge Description NIFTEX is a platform to fractionalize Non-Fungible Tokens (NFTs), unlocking a host of benefits that were unavailable to the NFT space previously.

Part of NFT fractionalization involves the deployment of an ERC20 registry representing fractions (“Shards”) of the NFT. NIFTEX ERC20 registries are capped, mintable, burnable and pausable, and currently cost approximately 2m gas to deploy using OpenZeppelin libraries. One registry must be deployed per fractionalization. This tends to get very expensive especially with high gas prices.

Submission Requirements

Price Bounty

Judging Criteria The submission with the highest % reduction in gas costs wins! Note that if any crucial flaws invalidating the pattern due to security issues or otherwise are found, the submission will be disqualified.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.001 ETH (0.61 USD @ $614.06/ETH) attached to it.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 5.0 ETH (2568.92 USD @ $536.63/ETH) has been submitted by:


gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 5.0 ETH (13444.51 USD @ $2688.9/ETH) has been submitted by:

  1. @cosmictomato
  2. @amxx
  3. @developerfred

@jmahhh please take a look at the submitted work:


gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 4 months, 1 week ago. Please review their action plans below:

1) developerfred has started work.

I'm going to use best practises to reduce the cost of implementing the contract by 50% 2) cosmictomato has started work.

This is a minimal ERC20 Token based on OpenZeppelin contracts that is "capped, mintable, burnable and pausable" as defined in requirements, paired with an eip-1167 minimal proxy implementation to reduce gas costs of deploying many ERC20 contracts.

Deployment flow is as follows:

1) A copy of Contract NiftexERC20 is deployed

2) A copy of Contract NiftexERC20Factory is deployed, with the address of the above contract as the constructor

3) Any additional ERC20 contracts can be deployed by the owner of the contract created in step (2), by calling function "deploy" with appropriate arguments (as implemented these are the token name, symbol, max number of tokens i.e. "mintLimit", and the desired owner of the new contract, although the contract can easily be modified to include more arguments)

Tested on Remix (https://remix.ethereum.org/) the reported gas costs are:

2400206 gas transaction cost (1741774 gas execution cost) for step (1) deployment of NiftexERC20

823720 gas transaction cost (579796 gas execution cost) for step (2) deployment of NiftexERC20Factory

162412 gas transaction cost (138068 gas execution cost) for step (3) deployment of new NiftexERC20 contract through call to "deploy" function of NiftexERC20Factory contract

Given the details provided, I believe this more than fulfills the goal of a 2x reduction in deployment costs. The reported test results from Remix represent a reduction of more than 93% in the gas costs, or a ~14.78x reduction in gas costs. Adding more features to the ERC20 contract should change this result based on whether storage usage is expanded or not. Implementation of additional functions without increasing storage usage should actually improve the quoted figure, while adding more flexible storage usage will decrease the improvements in gas usage.

Note that whatever contract you end up building off of this should have all of its constructor logic placed inside of the "init" function to ensure that all minimal proxies are correctly initialized.

You can check out Uniswap for a similar implementation of the same idea. 3) amxx has started work.

See the Readme.md file

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 5.0 ETH (13444.51 USD @ $2688.9/ETH) attached to this issue has been approved & issued to @cosmictomato.