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

Update dependencies and scripts. Also added a test file. #4

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
25 changes: 9 additions & 16 deletions contracts/BuyMeACoffee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ contract BuyMeACoffee {
string name,
string message
);

// Memo struct.
struct Memo {
address from;
uint256 timestamp;
string name;
string message;
}

// Address of contract deployer. Marked payable so that
// we can withdraw to this address later.
address payable owner;
address payable public owner;

// List of all memos received from coffee purchases.
Memo[] memos;
Expand All @@ -45,25 +45,18 @@ contract BuyMeACoffee {
* @param _name name of the coffee purchaser
* @param _message a nice message from the purchaser
*/
function buyCoffee(string memory _name, string memory _message) public payable {
function buyCoffee(
string memory _name,
string memory _message
) public payable {
// Must accept more than 0 ETH for a coffee.
require(msg.value > 0, "can't buy coffee for free!");

// Add the memo to storage!
memos.push(Memo(
msg.sender,
block.timestamp,
_name,
_message
));
memos.push(Memo(msg.sender, block.timestamp, _name, _message));

// Emit a NewMemo event with details about the memo.
emit NewMemo(
msg.sender,
block.timestamp,
_name,
_message
);
emit NewMemo(msg.sender, block.timestamp, _name, _message);
}

/**
Expand Down
27 changes: 20 additions & 7 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-waffle");
require("dotenv").config()
// This is essential to have global access to ethers.js
require('@nomicfoundation/hardhat-toolbox');
require('dotenv').config();

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

const GOERLI_URL = process.env.GOERLI_URL;
const SEPOLIA_URL = process.env.SEPOLIA_URL;
const POLYGONZK_URL = process.env.POLYGONZK_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;

/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.4",
solidity: '0.8.24',
networks: {
goerli: {
networkCheckTimeout: 10000,
url: GOERLI_URL,
accounts: [PRIVATE_KEY]
}
}
accounts: [PRIVATE_KEY],
},
sepolia: {
networkCheckTimeout: 10000,
url: SEPOLIA_URL,
accounts: [PRIVATE_KEY],
},
polygonZk: {
networkCheckTimeout: 10000,
url: POLYGONZK_URL,
accounts: [PRIVATE_KEY],
},
},
};
Loading