Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished week4 task #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
127 changes: 0 additions & 127 deletions README.md

This file was deleted.

34 changes: 34 additions & 0 deletions contracts/Lock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;

// Uncomment this line to use console.log
// import "hardhat/console.sol";

contract Lock {
uint public unlockTime;
address payable public owner;

event Withdrawal(uint amount, uint when);

constructor(uint _unlockTime) payable {
require(
block.timestamp < _unlockTime,
"Unlock time should be in the future"
);

unlockTime = _unlockTime;
owner = payable(msg.sender);
}

function withdraw() public {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);

require(block.timestamp >= unlockTime, "You can't withdraw yet");
require(msg.sender == owner, "You aren't the owner");

emit Withdrawal(address(this).balance, block.timestamp);

owner.transfer(address(this).balance);
}
}
26 changes: 0 additions & 26 deletions contracts/MyNFT.sol

This file was deleted.

22 changes: 22 additions & 0 deletions contracts/SimpleNFT.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

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

contract SimpleNFT is ERC721 {
uint256 private _nextTokenId;

constructor() ERC721("SimpleNFT", "SNFT") {
_nextTokenId = 0;
}

function safeMint(address to) public {
uint256 tokenId = _nextTokenId;
_nextTokenId++;
_safeMint(to, tokenId);
}

function totalSupply() public view returns (uint256) {
return _nextTokenId;
}
}
31 changes: 31 additions & 0 deletions deploy/01-deploy-simple-nft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { ethers } = require("hardhat");

module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

console.log("Deploying SimpleNFT contract with account:", deployer);

const simpleNFT = await deploy("SimpleNFT", {
from: deployer,
args: [],
log: true,
waitConfirmations: 1,
});

console.log("SimpleNFT deployed to:", simpleNFT.address);

// Verify the contract on Etherscan
if (network.name !== "hardhat") {
try {
await hre.run("verify:verify", {
address: simpleNFT.address,
constructorArguments: [],
});
} catch (error) {
console.error("Error verifying contract:", error);
}
}
};

module.exports.tags = ["SimpleNFT"];
1 change: 1 addition & 0 deletions deployments/sepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
Loading