-
Notifications
You must be signed in to change notification settings - Fork 10
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
Change the branch name to canvasOnchain and also write a readme file in the hardhat folder for description #32
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@Abidoyesimze is attempting to deploy a commit to the BuidlGuidl Team on Vercel. A member of the Team first needs to authorize 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.
The filename is not matching the contract name
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.
[RESOLVED]
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.
here it's called canvasOnChain
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.
Check everything to be sure it's the same name everywhere
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.
[RESOLVED]
packages/hardhat/hardhat.config.ts
Outdated
@@ -33,7 +34,7 @@ const config: HardhatUserConfig = { | |||
}, | |||
], | |||
}, | |||
defaultNetwork: "localhost", | |||
defaultNetwork: "sepolia", |
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.
I usually don't change this, because unwarned people might deploy to the incorrect network by mistake. When I want to deploy to another network I add the flag on the command:
yarn deploy --network sepolia
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.
[RESOLVED]
packages/hardhat/hardhat.config.ts
Outdated
@@ -54,7 +55,7 @@ const config: HardhatUserConfig = { | |||
accounts: [deployerPrivateKey], | |||
}, | |||
sepolia: { | |||
url: `https://rpc2.sepolia.org`, | |||
url: `https://eth-sepolia.g.alchemy.com/v2/FIQ1qwifmra7ZqdkVHnZ2lHQAKG8j4Yd`, |
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.
As a general rule, never include an API key in the code of a GitHub repository. Instead, use the .env file. Alternatively, you can use public RPCs, such as those available here: https://chainlist.org/chain/11155111.
packages/hardhat/package.json
Outdated
@@ -7,6 +7,7 @@ | |||
"check-types": "tsc --noEmit --incremental", | |||
"compile": "hardhat compile", | |||
"deploy": "hardhat deploy", | |||
"deploy:canvas": "hardhat run deploy/canvasOnchain.ts --network sepolia", |
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.
do we really need another script? Isn't the deploy
script deploying everything that is on the deploy
folder?
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.
Will make changes to that it's when i'm having issue with the network but forget to remove it later on
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.
[RESOLVED]
packages/nextjs/scaffold.config.ts
Outdated
@@ -10,7 +10,7 @@ export type ScaffoldConfig = { | |||
|
|||
const scaffoldConfig = { | |||
// The networks on which your DApp is live | |||
targetNetworks: [chains.optimism], | |||
targetNetworks: [chains.sepolia], |
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.
Did you deploy BatchRegistry to sepolia as well?
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.
I am unable to even deploy to sepolia now the gas is high right now
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.
[RESOLVED]
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.
I have made all the changes but still having issue deploying sepolia is too high and when trying to use optimism it's giving me issue i don't understand pls can you help me to deploy it from your side
@Abidoyesimze there's still some things called CanvasOnChain and others PixelCanvas |
packages/hardhat/Readme.md
Outdated
getCanvasSnapshot(): Returns entire canvas state | ||
|
||
3. Initialization | ||
Test the CanvasOnchain contract |
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.
Test the CanvasOnchain contract | |
Test the PixelCanvas contract |
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.
[RESOLVED]
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 filename
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.
updated
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.
[RESOLVED]
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 a lot for the whole effort and the smart contract!
Looking forward to see how it is then implemented in the front end :)
Below you'll find comments, please let me know if you have any questions.
(I haven't reviewed the test file).
packages/hardhat/hardhat.config.ts
Outdated
@@ -54,7 +55,7 @@ const config: HardhatUserConfig = { | |||
accounts: [deployerPrivateKey], | |||
}, | |||
sepolia: { | |||
url: `https://rpc2.sepolia.org`, | |||
url: `https://eth-sepolia.g.alchemy.com/v2/FIQ1qwifmra7ZqdkVHnZ2lHQAKG8j4Yd`, |
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.
As a general rule, never include an API key in the code of a GitHub repository. Instead, use the .env file. Alternatively, you can use public RPCs, such as those available here: https://chainlist.org/chain/11155111.
yarn.lock
Outdated
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.
Since you are adding @nomicfoundation/hardhat-network-helpers, that should be the only change made here.
packages/hardhat/hardhat.config.ts
Outdated
@@ -7,6 +7,7 @@ import "@typechain/hardhat"; | |||
import "hardhat-gas-reporter"; | |||
import "solidity-coverage"; | |||
import "@nomicfoundation/hardhat-verify"; | |||
import "@nomicfoundation/hardhat-network-helpers"; |
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.
Why would we need this import here?
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.
updated
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.
Why make things more complicated than necessary :)
There is already a deploy script named 00_deploy_your_contract.ts
file which you can use.
Take the following code, copy it and adapt it for your contract:
await deploy("BatchRegistry", { from: deployer, // Contract constructor arguments args: [deployer, BATCH_NUMBER], log: true, // autoMine: speeds up deployment on local networks by auto-mining the deployment transaction. No effect on live networks. autoMine: true, });
Currently, the contracts are not being copied to the deployedContract.ts file in the Next.js project as they should. (Deploy scripts need to run before 99_generateTsAbis.ts.)
Let me know if you have any questions!
for (uint256 x = 10; x < 20; x++) { | ||
for (uint256 y = 10; y < 50; y++) { | ||
canvas[x][y] = Pixel({ | ||
author: owner(), |
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.
You could also use in the initialization msg.sender as the author.
} | ||
|
||
// 2D Mapping to store pixels | ||
Pixel[CANVAS_WIDTH][CANVAS_HEIGHT] public canvas; |
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.
Use a mapping here instead. That is more gas-efficient and flexible, storing the whole array from the beginning a is not the ideal solution. The key advantages of a mapping compared to a fixed-size array are:
- Lower Deployment Cost: There's no need to initialize the entire array, reducing upfront costs.
- Higher Gas Efficiency: It only stores modified pixels, making it ideal for canvases where most pixels remain unchanged
Consider what additional functions we might not need if we switch to using a mapping.
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 for the changes!
You still need to add a deploy script (important for reviewers to deploy and test it themselves).
Also, just a small comment below about the withdraw and how to send ether.
In general, please ensure your PR has a clear and descriptive title and description (file out the template form). For example, "Change the branch name to canvasOnchain and write a README file in the Hardhat folder for description" would be more suitable as a commit message. That's what this course is also about :)
require(balance > 0, "No funds to withdraw"); | ||
|
||
// Transfer the balance to the owner | ||
payable(owner()).transfer(balance); |
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.
Not anymore the recommenced way to send ether.
https://www.cyfrin.io/glossary/sending-ether-transfer-send-call-solidity-code-example
yarn.lock
Outdated
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.
No changes to this file.
// const batchRegistry = await hre.ethers.getContract<Contract>("BatchRegistry", deployer); | ||
// console.log("\nBatchRegistry deployed to:", await batchRegistry.getAddress()); | ||
// console.log("Remember to update the allow list!\n"); |
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.
we still need to deploy the BatchRegistry, right?
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.
I actually don't have idea about it that's why i commented it out till @phipsae replied
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.
As a reviewer of the PR, I would first test it in my local environment, which involves deploying all the contracts (including batchRegistry). Therefore, you should add the deployment of your new contract to the existing script (so you leave the script as it is and add the additional deploy code).
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.
See below my comments.
As soon as you have the deploy script, I will look at the contract.
Thank you!
package.json
Outdated
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.
No changes to this file, pls.
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.
See my comment in the conversation.
Leave the script as it is, just add the deploy contract block to it (like it is done for batch registry).
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 for the contract! I deployed the contract to optimism and made a few changes so we can finally merge it.
For next time, it would be great if you could run yarn deploy before pushing the code. It didn't work because you were passing an argument into the constructor, but the contract doesn’t accept one. :))
Description
Concise description of proposed changes, We recommend using screenshots and videos for better description
Additional Information
Related Issues
Closes #{issue number}
Note: If your changes are small and straightforward, you may skip the creation of an issue beforehand and remove this section. However, for medium-to-large changes, it is recommended to have an open issue for discussion and approval prior to submitting a pull request.
Your ENS/address: 0x6BF7d6b94282BD48ff458599aDafA268BcB009FF