-
Notifications
You must be signed in to change notification settings - Fork 944
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
Optimism and base networks verification #996
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be just a me problem or maybe macos problem? not sure what I am doing wrong tested it on my new mac too and get same thing :( :
Would love if others could tes itt.
Here the contract I tried deploying :
Example contract
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
// Useful for debugging. Remove when deploying to a live network.
import "hardhat/console.sol";
/**
* A smart contract that allows changing a state variable of the contract and tracking the changes
* It also allows the owner to withdraw the Ether in the contract
* @author BuidlGuidl
*/
contract YourContract {
// State Variables
address public immutable owner;
string public greeting = "Building Unstoppable Apps!!!";
uint256 public constant PREMIUM_PRICE = 0.01 ether;
uint256 public constant MAX_GREETING_LENGTH = 140;
uint256 public totalCounter = 0;
mapping(address => bool) public isPremium;
mapping(address => uint256) public userGreetingCounter;
mapping(address => uint256) public lastGreetingTime;
// Events
event GreetingChange(
address indexed greetingSetter,
string newGreeting,
bool isPremium,
uint256 timestamp
);
event PremiumPurchased(address indexed user, uint256 amount);
// Constructor: Called once on contract deployment
constructor(address _owner) {
owner = _owner;
}
// Modifiers
modifier isOwner() {
require(msg.sender == owner, "Not the Owner");
_;
}
modifier validGreeting(string memory _greeting) {
require(bytes(_greeting).length > 0, "Greeting cannot be empty");
require(bytes(_greeting).length <= MAX_GREETING_LENGTH, "Greeting too long");
_;
}
/**
* Function to become a premium user
*/
function purchasePremium() public payable {
require(!isPremium[msg.sender], "Already premium");
require(msg.value == PREMIUM_PRICE, "Incorrect payment amount");
isPremium[msg.sender] = true;
emit PremiumPurchased(msg.sender, msg.value);
}
/**
* Function that allows anyone to change the greeting
* Premium users can set greetings more frequently
*/
function setGreeting(string memory _newGreeting) public validGreeting(_newGreeting) {
// Check time constraints for non-premium users
if (!isPremium[msg.sender]) {
require(
block.timestamp >= lastGreetingTime[msg.sender] + 1 days,
"Non-premium users can only set greeting once per day"
);
}
console.log("Setting new greeting '%s' from %s", _newGreeting, msg.sender);
greeting = _newGreeting;
totalCounter += 1;
userGreetingCounter[msg.sender] += 1;
lastGreetingTime[msg.sender] = block.timestamp;
emit GreetingChange(
msg.sender,
_newGreeting,
isPremium[msg.sender],
block.timestamp
);
}
/**
* View function to get user stats
*/
function getUserStats(address _user) public view returns (
uint256 greetingCount,
bool userIsPremium,
uint256 timeUntilNextGreeting
) {
greetingCount = userGreetingCounter[_user];
userIsPremium = isPremium[_user];
if (!userIsPremium && lastGreetingTime[_user] > 0) {
uint256 nextAvailableTime = lastGreetingTime[_user] + 1 days;
timeUntilNextGreeting = block.timestamp >= nextAvailableTime ?
0 : nextAvailableTime - block.timestamp;
}
}
/**
* Function that allows the owner to withdraw all the Ether in the contract
*/
function withdraw() public isOwner {
uint256 balance = address(this).balance;
require(balance > 0, "No funds to withdraw");
(bool success, ) = owner.call{value: balance}("");
require(success, "Failed to send Ether");
}
/**
* Function that allows the contract to receive ETH
*/
receive() external payable {}
}
It works for me (deploy & verify):
It was just a conspiration for make the verify fail before the CTF :P Maybe could you temporary tweak the hardhat-deploy lib to see if you can get more info. e.g:
|
Works fine on my macos 🤷♂️ , tried with your contract too |
maybe you switched from a branch with different deps versions and forgot to update? |
@technophile-04 have you tried base/baseSepolia? Also, could you try to use VPN with different countries? |
Ohh I think found the bug. the problem is that hardhat-deploy has reserved the name The above problem was occurring to me because I had an
A solution might be that we change this to
So while setting up |
Great find!
Looks like a bug 🤨
Changed it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rin-st!
Damn, good catch. It tried to kill our CTF haha |
Description
Adds possibility to use
yarn verify
with contracts onoptimism
,optimismSepolia
,base
andbaseSepolia
networksTested all four, verification works great for me
part of #965
These networks are chosen because they are most popular ones, and also we need
optimism
for SRE extensions. Please lmk if I need to add/change somethingAdditional Information