Skip to content

Commit

Permalink
Merge branch 'main' into feature/RC721-14-Test-what-is-the-MAX-amount…
Browse files Browse the repository at this point in the history
…-that-you-can-mint-in-ONE-TRX-with-the-ERC721F-use-the-Freemint-implementation
  • Loading branch information
HansRobrecht committed Sep 20, 2022
2 parents 3ae6f44 + fcadc6d commit 17d2b00
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ See the [open issues](https://github.com/FrankNFT-labs/ERC721F/issues) for a ful
Just import the file directly from Gitlab like this:
![Usage](https://github.com/FrankNFT-labs/ERC721F/blob/main/docs/images/ERC721F_usage.png)

This can then be used in your contract as following:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9 <0.9.0;
import "https://github.com/FrankNFT-labs/ERC721F/blob/v4.7.0/contracts/token/ERC721/ERC721FCOMMON.sol";
contract Example is ERC721F {
constructor() ERC721F("Example", "Example") {}
/**
* Mint your tokens here.
*/
function mint(uint256 numberOfTokens) external {
require(msg.sender==tx.origin,"No Contracts allowed.");
uint256 supply = totalSupply();
for(uint256 i; i < numberOfTokens;){
_mint( msg.sender, supply + i ); // no need to use safeMint as we don't allow contracts.
unchecked{ i++;}
}
}
}
```


<!-- CONTRIBUTING -->

Expand All @@ -41,6 +65,25 @@ Don't forget to give the project a star! Thanks again!
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

### Running tests locally
1. Copy .env.example and rename to .env
2. `npm install`
3. `npx hardhat compile`
4. `npx hardhat test`

> **Warning**
> Since hardhat only compiles a single path at once, you'll probably fail every single test that's executed on solutions located in /examples. This is because those artifacts haven't been created yet.
These can be created by changing the the sources path in hardhat.config.js to "./examples" and executing step 3 again.

**Note:** `npx hardhat clean` removes the created artifacts

#### Running a single test
`npx hardhat test ./test/token/ERC721/GasUsage.test.js`

#### Testing gas consumption
- Enable the creation of a gas report by setting `REPORT_GAS` to `true` in `.env`
- Toggle the creation of a gas report file by (un)commenting `outputFile` in `hardhat.config.js`
- Change the total runs and toggle the optimizer by changing the `solidity` `optimizer` values in `hardhat.config.js`

[license-shield]: https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge
[license-url]: https://github.com/FrankNFT-labs/ERC721F/blob/main/LICENSE
18 changes: 18 additions & 0 deletions contracts/token/ERC721/ERC721FCOMMON.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ contract ERC721FCOMMON is ERC721F, ERC721Payable, ERC2981 {
constructor(string memory name_, string memory symbol_) ERC721F(name_, symbol_) {
}

/**
* @notice Indicates whether this contract supports an interface
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* @return `true` if the contract implements `interfaceID` or is 0x2a55205a, `false` otherwise
*/
function supportsInterface(bytes4 _interfaceId)
public
view
Expand All @@ -25,6 +34,10 @@ contract ERC721FCOMMON is ERC721F, ERC721Payable, ERC2981 {
super.supportsInterface(_interfaceId);
}

/**
* @dev it will update the royalties for token
* @param _royalties is new percentage of royalties. It should be more than 0 and least 90
*/
function setRoyalties(uint16 _royalties) external onlyOwner {
require(
_royalties != 0 && _royalties < 90,
Expand All @@ -36,6 +49,11 @@ contract ERC721FCOMMON is ERC721F, ERC721Payable, ERC2981 {
emit RoyaltiesUpdated(_royalties);
}

/**
* @notice Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
* @param _tokenId is the token being sold and should exist.
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice)
public
view
Expand Down

0 comments on commit 17d2b00

Please sign in to comment.