Skip to content

Commit

Permalink
first AA test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yassirakh committed Feb 28, 2024
1 parent edb6c10 commit b839072
Show file tree
Hide file tree
Showing 16 changed files with 2,348 additions and 45 deletions.
62 changes: 62 additions & 0 deletions packages/hardhat/contracts/MutantsNft.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";

contract MutantsNft is ERC721URIStorage {
event NftMinted(
address indexed minter,
uint256 indexed tokenId,
string tokenUri
);

uint256 private tokenCounter;
uint256 private supply = 25;

constructor() ERC721("Mutant", "MUT") {
tokenCounter = 1;
}

function mintNft() public {
require(tokenCounter < supply + 1, "SoldOut");
uint256 newItemId = tokenCounter;
tokenCounter = tokenCounter + 1;
_safeMint(msg.sender, newItemId);
// _setTokenUri(newItemId, string.concat(TOKEN_URI_PREFIX, Strings.toString(newItemId), '.json'));
_setTokenURI(
newItemId,
string.concat(Strings.toString(newItemId), ".json")
);
emit NftMinted(
msg.sender,
newItemId,
string.concat(_baseURI(), Strings.toString(newItemId), ".json")
);
}

function _baseURI() internal pure override returns (string memory) {
return
"https://scarlet-far-urial-455.mypinata.cloud/ipfs/QmdTwTjtYxFHHio8NuP6nZPBfqZ1UvB46jMseyhUniPiEe/";
}

function getTokenCounter() public view returns (uint256) {
return tokenCounter;
}

function getSupply() public view returns (uint256) {
return supply;
}

function getTokenOwners(
uint256[] memory tokenIds
) public view returns (address[] memory) {
address[] memory tokensToOwners = new address[](tokenIds.length);
for (uint i = 0; i < tokenIds.length; i++) {
tokensToOwners[i] = ERC721._ownerOf(tokenIds[i]);
}
return tokensToOwners;
}
}
10 changes: 5 additions & 5 deletions packages/hardhat/deploy/00_deploy_your_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEn
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;

await deploy("YourContract", {
await deploy("MutantsNft", {
from: deployer,
// Contract constructor arguments
args: [deployer],
args: [],
log: true,
// autoMine: can be passed to the deploy function to make the deployment process faster on local networks by
// automatically mining the contract deployment transaction. There is no effect on live networks.
autoMine: true,
});

// Get the deployed contract to interact with it after deploying.
const yourContract = await hre.ethers.getContract<Contract>("YourContract", deployer);
console.log("👋 Initial greeting:", await yourContract.greeting());
const yourContract = await hre.ethers.getContract<Contract>("MutantsNft", deployer);
console.log("👋 Initial greeting:", await yourContract.getAddress());
};

export default deployYourContract;

// Tags are useful if you have multiple deploy files and only want to run one of them.
// e.g. yarn deploy --tags YourContract
deployYourContract.tags = ["YourContract"];
deployYourContract.tags = ["MutantsNft"];
1 change: 1 addition & 0 deletions packages/hardhat/deployments/sepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
Loading

0 comments on commit b839072

Please sign in to comment.