h1f0x / ERC2981

EIP-2981 solution

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERC-2981 Royalties:

Basing EIP-2981 into ERC-2981

After using https://eips.ethereum.org/EIPS/eip-2981 as the final standard, I have taken IERC2981.sol and forged this into ERC2981.sol and ERC2981Collection.sol

ERC2981.sol (for public minters)

By using a Struct we are attempting to use closer to a 21k gas fee (full 2^256 slot).

mappedRoyalties.receiver - address for royalties
mappedRoyalties.percentage - uint for pecentage (yes can change to permille)

mapping(uint256 => mappedRoyalties) royalty - mapping per tokenId

_setRoyalties(uint, address, uint) internal - sets the mapping

royaltyInfo(uint, address) - override of IERC2981.sol

  • returns mappedRoyalties.receiver
  • returns value to be sent from sale

ERC2981Collection.sol (for public minters)

Designed more for x amount of minters for an artist collection.
By using 2 variables, royaltyAddress and royaltyPercent more gas intensive, but should be a one time setting.

_setRoyalties(address, uint) internal - sets the two variable

royaltyInfo(uint, address) - override of IERC2981.sol

  • returns royaltyAddress
  • returns value to be sent from sale

Requirements: (for testing)

  1. Node.js - Latest
  2. NPM - Latest
  3. Truffle - Latest (npm install -g truffle)
  4. hdwallet-provider - Latest (npm install -g @truffle/hdwallet-provider)
  5. truffle-plugin-verify - Latest (npm install -g truffle-plugin-verify)
  6. Infura API-Key
  7. Ftmscan API-Key
  8. mnemonic for generation of Private Key
  9. .env setup:
  • MNEMONIC=""
  • INFURA_API_KEY=
  • FTMSCAN_API_KEY=
  1. dotenv - Latest (npm install -g dotenv)
  2. git - Latest (if you plan on developing with us)
  3. create .gitignore
  • add .env

Currently under testing phase

About

EIP-2981 solution

License:MIT License


Languages

Language:Solidity 90.0%Language:JavaScript 10.0%