Skip to content

Commit

Permalink
NFT Test for gas profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
antico5 committed Nov 2, 2021
1 parent 9d253d2 commit 27b75d9
Show file tree
Hide file tree
Showing 10 changed files with 32,738 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nft_gas_test/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALCHEMY_API_KEY=
ROPSTEN_PRIVATE_KEY=
7 changes: 7 additions & 0 deletions nft_gas_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.env

#Hardhat files
cache
artifacts
dist
16 changes: 16 additions & 0 deletions nft_gas_test/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always",
"semi": true
}
}
]
}
58 changes: 58 additions & 0 deletions nft_gas_test/contracts/NFTest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: GPL-3.0

/*
Requirements:
- Must receive eth in exchange for an ERC20 token
- There is a recipient address that receives all incoming eth.
- Exchange rate is fixed. 1 eth = 1000 tokens
- Minimum investment is 0.01 eth and maximum is 5 eth.
- The ICO hardcap is 300 eth.
- An admin decides when the ICO starts and ends.
- The ICO ends when the hardcap is reached or end time is reached.
- The token will be tradeable only after a specific time set by the admin
*/

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract NFTest is ERC721("Test", "TEST") {
function mint(address to, uint256 tokenId) public {
_mint(to, tokenId);
}

function transfer(
address from,
address to,
uint256 tokenId
) public {
_transfer(from, to, tokenId);
}

function mintWithMerkleProof(
address to,
uint256 tokenId,
string[] calldata proof
) public {
_mint(to, tokenId);
_hashProof(proof);
}

function transferWithMerkleProof(
address from,
address to,
uint256 tokenId,
string[] calldata proof
) public {
_hashProof(proof);
_transfer(from, to, tokenId);
}

function _hashProof(string[] calldata proof) internal pure {
for (uint256 index = 0; index < proof.length; index++) {
keccak256(abi.encode(proof[index]));
}
}
}
41 changes: 41 additions & 0 deletions nft_gas_test/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { task } from "hardhat/config";
import "@nomiclabs/hardhat-waffle";
import "hardhat-gas-reporter"
import "hardhat-tracer"
import "@atixlabs/hardhat-time-n-mine"
import "@atixlabs/hardhat-time-n-mine/dist/src/type-extensions";

import dotenv from 'dotenv'
dotenv.config()

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (args, hre) => {
const accounts = await hre.ethers.getSigners();

for (const account of accounts) {
console.log(await account.address);
}
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

export default {
solidity: {
version: '0.8.7',
settings: {
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
}
},
networks: {
ropsten: {
url: `https://eth-ropsten.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
accounts: [`0x${process.env.ROPSTEN_PRIVATE_KEY}`],
},
},
};
Loading

0 comments on commit 27b75d9

Please sign in to comment.