This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Add example deploy script #50
Open
TheRightChoyce
wants to merge
2
commits into
holic:main
Choose a base branch
from
TheRightChoyce:DeployScript
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
DEPLOYER= | ||
DEPLOYER_PRIVATE_KEY= | ||
CHAIN_ID=5 | ||
CHAIN_NAME=goerli | ||
RPC_URL= | ||
ETHERSCAN_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity ^0.8.9; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
import {ExampleNFT} from "../src/ExampleNFT.sol"; | ||
|
||
/// @dev This is best run by calling "$ ./scripts/Deploy.sh" from the root of the "contracts" app! | ||
|
||
contract Deploy is Script { | ||
/// @dev Deployable contracts | ||
ExampleNFT public exampleNFT; | ||
|
||
// Renderer public renderer; -- uncomment if you have a renderer contract | ||
|
||
/// @notice Allows for easily loading ENV vars | ||
/// @dev The Solenv include path is relative to the project root, or whereever you run the shell command from | ||
// function setUp() external { | ||
// Solenv.config("./packages/contracts/.env.local"); | ||
// } | ||
|
||
function deployTokenContract() public { | ||
/// @dev Deploy the base contract with any inputs | ||
exampleNFT = new ExampleNFT(); | ||
} | ||
|
||
function deployRendererContract() public { | ||
/// @dev If you setup a renderer contract, easily deploy it alongside the base contract | ||
// renderer = new Renderer( | ||
// address(exampleNFT), | ||
// ); | ||
} | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
|
||
deployTokenContract(); | ||
// deployRendererContract(); | ||
|
||
/// @dev Update token contract to point to the renderer | ||
// exampleNFT.setRenderer(renderer); | ||
|
||
vm.stopBroadcast(); | ||
|
||
console.log("Deployed contract to ==> ", address(exampleNFT)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Expects jq to be installed | ||
|
||
# Run this from the root of the contract dir!!! | ||
# To test this deploy without actually deploy to a public network, remove the "broadcast" flag | ||
# If the verification fails, run this script again and remove the "broadcast" flag | ||
# If you are using Solenv, you must add the "--ffi" flag | ||
# if you get a permission denied error, ensure there is execute permisions on the file.. 755 or similiar | ||
|
||
source .env | ||
|
||
if [ -z "$CHAIN_ID" ]; then | ||
echo "CHAIN_ID is not set" | ||
exit 1 | ||
fi | ||
|
||
CONTRACT_NAME="ExampleNFT" | ||
DEPLOY_OUTPUT="deploys/$CHAIN_NAME/$CONTRACT_NAME.json" | ||
mkdir -p $(dirname $DEPLOY_OUTPUT) | ||
|
||
forge script script/Deploy.s.sol:Deploy -vvvv --chain-id $CHAIN_ID \ | ||
--rpc-url $RPC_URL \ | ||
--private-key $DEPLOYER_PRIVATE_KEY \ | ||
--broadcast \ | ||
--verify --etherscan-api-key $ETHERSCAN_API_KEY | ||
|
||
# Transaction 0 should be the first transaction you broadcast | ||
jq '{deployedTo: .transactions[0].contractAddress, deployer: .transactions[0].tx.from, transactionHash: .transactions[0].hash}' ./broadcast/Deploy.s.sol/$CHAIN_ID/run-latest.json > $DEPLOY_OUTPUT |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what do you think about replacing the
contracts/deploy.sh
with this one?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 think both are unnecessary : )
Do you want to try out the new deploy script a few times, and if it looks good, one of us pushes an update to remove the existing one?
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.
Can you share more about why both are unnecessary? The shell script is/was partly there to deploy the contract (now replaced by this solidity script 🙏 ) but also partly there to track the addresses for each contract so that the app, etc. can import them for wiring up contract interactions in the frontend. Is there another approach you're thinking for the latter step?
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 think I misunderstood the question / answered it poorly : )
I thought you referring to having both the deploy.sh file in the project root and also having one in the scripts folder. I think having at least one shell script is still necessary, but having two that do the same thing is not necessary. With anything that requires multiple flags or options to remember, I love have a easy script file to wrap all that up into a single command.