Basic Envious Preset

Description

This preset provides a basic implementation of ERC721Envious with the added functionality of utilizing IBondDepository and INoteKeeper. The ERC721Enumerable extension is used in this example, so the _disperse function is based on the totalSupply of this extension. Although the current smart contract will implement five extensions, its resulting size is approximately 23.59 KiB as determined by 1337 optimization runs.

Hint

During the development process, Debian and truffle were utilized.

ERC721EnviousPreset

ERC721EnviousPreset is a combination of AccessControlEnumerable, ERC721Burnable, ERC721Pausable, ERC721Enumerable, ERC721Envious.

Implemented roles:

  • Minter_Role allows for token minting

  • Pauser_Role grants permissions to pauseNFT transfers

  • Ghosty_Role is capable of modifying modify Envious-specific variables

Hint

By default, the smart contract deployer will be assigned the Minter_Role, Pauser_Role, and Ghosty_Role.

receive

receive() external payable

receive function routes incoming transfers of the native coin towards dispersing the value of msg.value.

baseURI

function baseURI() external view virtual returns (string memory)

baseURI is a getter function for the baseURI.

baseURI function returns baseURI for the entire collection.

tokenURI

function tokenURI(uint256 tokenId) public view virtual override returns (string memory)

tokenURI is a getter function for a particular tokenURI.

tokenURI function returns tokenURI for a specific NFT.

_Arguments_

Name

Type

Description

tokenId

uint256

unique token identifier

mint

function mint(address to) public virtual override

mint function generates a new token. mint function can be triggered by the account with Minter_Role only.

_Arguments_

Name

Type

Description

to

address

receiver of new NFT

pause

function pause() external virtual

pause function halts all transfers of NFTs in the collection. pause function can be activated by the account with the Pauser_Role only.

unpause

function unpause() external virtual

unpause function resumes all NFT transfers in the collection. unpause function can be triggered by the account with the Pauser_Role only.

setGhostAddresses

function setGhostAddresses(address ghostToken, address ghostBonding) public virtual

setGhostAddresses function modifies the underlying ghost-related addresses. setGhostAddresses function can be triggered by the account with the Ghosty_Role only.

_Arguments_

Name

Type

Description

ghostToken

address

address of a non-rebasing bonding token

ghostBonding

address

address of a bonding smart contract

Gas Report

The complete test results can be found in the ./gas reporter/ERC721EnviouspPreset.txt file. The actual tests are available in the ./tests/ERC721EnviousPreset.test.js file.

·-----------------------------------------------------|---------------------------|--------------|----------------------------·
|         Solc version: 0.8.4+commit.c7e474f2         ·  Optimizer enabled: true  ·  Runs: 1337  ·  Block limit: 6718946 gas  │
······················································|···························|··············|·····························
|  Methods                                                                                                                    │
························|·····························|·············|·············|··············|··············|··············
|  Contract             ·  Method                     ·  Min        ·  Max        ·  Avg         ·  # calls     ·  eur (avg)  │
························|·····························|·············|·············|··············|··············|··············
|  BadToken             ·  approve                    ·      46201  ·      46213  ·       46211  ·          12  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  BadToken             ·  mint                       ·          -  ·          -  ·       70691  ·           6  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  BaseToken            ·  approve                    ·      29180  ·      46244  ·       46079  ·         104  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  BaseToken            ·  burn                       ·          -  ·          -  ·       26889  ·           1  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  BaseToken            ·  mint                       ·      51185  ·      68321  ·       67972  ·         109  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  BaseToken            ·  transfer                   ·          -  ·          -  ·       46608  ·           1  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  DAI                  ·  approve                    ·      29149  ·      46213  ·       45965  ·          69  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  DAI                  ·  burn                       ·          -  ·          -  ·       27704  ·           1  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  DAI                  ·  mint                       ·      70713  ·      70749  ·       70714  ·          69  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  approve                    ·      26628  ·      51081  ·       44728  ·         216  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  burn                       ·      48532  ·      66848  ·       62738  ·          21  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  changeCommissions          ·      28680  ·      68480  ·       47782  ·         748  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  changeCommunityAddresses   ·      29310  ·      69134  ·       49192  ·         720  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  claimDiscountedCollateral  ·      55765  ·     244786  ·      209562  ·          14  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  collateralize              ·      74616  ·     682712  ·      193841  ·         101  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  disperse                   ·      72718  ·     403232  ·      150497  ·          27  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  getDiscountedCollateral    ·     158329  ·     206611  ·      187426  ·          23  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  grantRole                  ·      31608  ·     101218  ·       90625  ·          46  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  harvest                    ·      81301  ·     312987  ·      132263  ·          14  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  mint                       ·     155730  ·     167530  ·      162693  ·         571  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  pause                      ·          -  ·          -  ·       47048  ·          20  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  renounceRole               ·      27123  ·      36464  ·       32906  ·          21  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  revokeRole                 ·      31643  ·      48470  ·       39263  ·          21  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  safeTransferFrom           ·      33631  ·     103781  ·       86934  ·         104  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  safeTransferFrom           ·      34307  ·     104899  ·       87796  ·         104  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  setApprovalForAll          ·      26408  ·      46320  ·       45372  ·         189  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  setGhostAddresses          ·      69177  ·      69189  ·       69188  ·          24  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  transferFrom               ·      33274  ·      96376  ·       82939  ·          56  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  ERC721EnviousPreset  ·  uncollateralize            ·      61761  ·     298701  ·      111653  ·          42  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  RebaseToken          ·  approve                    ·      29135  ·      46235  ·       45986  ·          69  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  RebaseToken          ·  initialize                 ·      94307  ·      94319  ·       94318  ·          68  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  RebaseToken          ·  transfer                   ·          -  ·          -  ·       34665  ·           1  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  StakingMock          ·  fund                       ·          -  ·          -  ·       61607  ·          69  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  TetherToken          ·  approve                    ·      26344  ·      46244  ·       45955  ·          69  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  TetherToken          ·  burn                       ·          -  ·          -  ·       26907  ·           1  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  TetherToken          ·  mint                       ·          -  ·          -  ·       68219  ·          69  ·          -  │
························|·····························|·············|·············|··············|··············|··············
|  Deployments                                        ·                                          ·  % of limit  ·             │
······················································|·············|·············|··············|··············|··············
|  BadToken                                           ·          -  ·          -  ·     1140859  ·        17 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  BaseToken                                          ·     775391  ·     775475  ·      775423  ·      11.5 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  BlackHole                                          ·          -  ·          -  ·      321368  ·       4.8 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  BondingMock                                        ·    1114858  ·    1114870  ·     1114868  ·      16.6 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  DAI                                                ·          -  ·          -  ·     1148998  ·      17.1 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  ERC721EnviousPreset                                ·          -  ·          -  ·     5478148  ·      81.5 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  ERC721ReceiverMock                                 ·     285979  ·     286027  ·      286014  ·       4.3 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  RebaseToken                                        ·          -  ·          -  ·     1711816  ·      25.5 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  StakingMock                                        ·     246573  ·     246585  ·      246585  ·       3.7 %  ·          -  │
······················································|·············|·············|··············|··············|··············
|  TetherToken                                        ·          -  ·          -  ·      758083  ·      11.3 %  ·          -  │
·-----------------------------------------------------|-------------|-------------|--------------|--------------|-------------·