-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from shapeshift/deployment-scripts
- Loading branch information
Showing
11 changed files
with
161 additions
and
49 deletions.
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
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,5 @@ | ||
ETHERSCAN_API_KEY="" # this must be an arbiscan api key | ||
FOX_TOKEN_ADDRESS="" | ||
PRIVATE_KEY="" | ||
RPC_URL="https://arbitrum-mainnet.infura.io/v3/<INFURA_API_KEY>" | ||
VERIFIER_URL="https://api.arbiscan.io/api" |
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,5 @@ | ||
ETHERSCAN_API_KEY="" # this must be an arbiscan api key | ||
FOX_TOKEN_ADDRESS="" | ||
PRIVATE_KEY="" | ||
RPC_URL="https://arbitrum-sepolia.infura.io/v3/<INFURA_API_KEY>" | ||
VERIFIER_URL="https://api-sepolia.arbiscan.io/api" |
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,5 @@ | ||
ETHERSCAN_API_KEY="not-required" | ||
FOX_TOKEN_ADDRESS="0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d" | ||
PRIVATE_KEY="" | ||
RPC_URL="http://localhost:8545" | ||
VERIFIER_URL="not-required" |
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,5 @@ | ||
ETHERSCAN_API_KEY="" | ||
FOX_TOKEN_ADDRESS="0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d" | ||
PRIVATE_KEY="" | ||
RPC_URL="https://mainnet.infura.io/v3/<INFURA_API_KEY>" | ||
VERIFIER_URL="https://api.etherscan.io/api" |
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,5 @@ | ||
ETHERSCAN_API_KEY="" | ||
FOX_TOKEN_ADDRESS="" | ||
PRIVATE_KEY="" | ||
RPC_URL="https://sepolia.infura.io/v3/<INFURA_API_KEY>" | ||
VERIFIER_URL="https://api-sepolia.etherscan.io/api" |
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 |
---|---|---|
@@ -1,66 +1,74 @@ | ||
## Foundry | ||
# rFOX | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
## Setup | ||
|
||
Foundry consists of: | ||
1. Install foundry https://book.getfoundry.sh/getting-started/installation | ||
2. Install slither `brew install slither-analyzer` | ||
3. Set up .env files: | ||
1. Copy an example .env file for your chosen environment: | ||
```shell | ||
cp .env.<your-chosen-env>.example .env.<your-chosen-env> | ||
``` | ||
2. Fill in the needed env vars there | ||
|
||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||
### Private key | ||
|
||
## Documentation | ||
|
||
https://book.getfoundry.sh/ | ||
|
||
## Usage | ||
|
||
### Build | ||
To derive a private key 0 from your mnemonic: | ||
|
||
```shell | ||
$ forge build | ||
cast wallet derive-private-key <YOUR_MNEMONIC> 0 | ||
``` | ||
|
||
### Test | ||
### Faucets | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
**Arbitrum sepolia** | ||
|
||
### Format | ||
Grab some ETH: | ||
https://www.l2faucet.com/arbitrum | ||
|
||
```shell | ||
$ forge fmt | ||
``` | ||
Grab some USDC: | ||
https://faucet.circle.com/ | ||
|
||
### Gas Snapshots | ||
## Deploying | ||
|
||
```shell | ||
$ forge snapshot | ||
``` | ||
### Local deployment | ||
Deploying locally is different to deploying directly to a network for 2 reasons: | ||
1. Its being deployed to a fork of another network (typically ethereum mainnet) rather than a real network. | ||
2. There's no local instance of etherscan, so etherscan verification is skipped. | ||
### Anvil | ||
When deploying locally, it's necessary to start a local fork before deploying: | ||
|
||
```shell | ||
$ anvil | ||
# RPC_URL for your env can be accessible with `source .env.<your-chosen-env`. | ||
anvil --rpc-url $RPC_URL | ||
``` | ||
|
||
### Deploy | ||
### Deployment steps | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
cd foundry | ||
### Cast | ||
# Install | ||
forge install | ||
```shell | ||
$ cast <subcommand> | ||
# Deploy | ||
./deploy.sh --env <your-chosen-env> | ||
# Test the proxy contract has been deployed with the correct version. | ||
# RPC_URL for your env can be accessible with `source .env.<your-chosen-env`. | ||
cast call <CONTRACT_PROXY_ADDRESS> "version()(uint256)" --rpc-url $RPC_URL | ||
``` | ||
|
||
### Help | ||
### Manually verifying | ||
|
||
If contract verification fails for any reason, you can verify without re-deploying: | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
forge verify-contract \ | ||
--verifier etherscan \ | ||
--verifier-url https://api-sepolia.arbiscan.io/api \ | ||
--compiler-version "v0.8.25" \ | ||
--etherscan-api-key $ARBISCAN_API_KEY \ | ||
$CONTRACT_IMPLEMENTATION_ADDRESS \ | ||
src/FoxStakingV1.sol:FoxStakingV1 | ||
``` |
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,54 @@ | ||
#!/bin/bash | ||
|
||
# Load generic environment variables | ||
source .env | ||
|
||
# Parse command line options | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--env) ENVIRONMENT="$2"; shift ;; # Shift past the value | ||
*) echo "Unknown parameter passed: $1"; exit 1 ;; | ||
esac | ||
shift # Shift past the current key or value | ||
done | ||
|
||
# Path to the environment file | ||
ENV_FILE=".env.$ENVIRONMENT" | ||
|
||
# Check if the environment file exists | ||
if [ ! -f "$ENV_FILE" ]; then | ||
echo "Environment file $ENV_FILE does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Source environment variables | ||
source $ENV_FILE | ||
|
||
# Echo back the environment for verification | ||
echo "Deploying to $ENVIRONMENT environment with settings from '$ENV_FILE'..." | ||
|
||
# Deployment-related commands | ||
echo "Running deployment tasks..." | ||
|
||
# Clean the build directory | ||
forge clean | ||
|
||
if [ "$ENVIRONMENT" = "local" ]; then | ||
# Local environment-specific commands (no etherscan verification) | ||
FOX_TOKEN_ADDRESS="$FOX_TOKEN_ADDRESS" forge script script/DeployFoxStaking.s.sol:DeployFoxStaking \ | ||
--fork-url $RPC_URL \ | ||
--private-key $PRIVATE_KEY \ | ||
--broadcast \ | ||
-vvvvv | ||
else | ||
# All other environments use etherscan verification (which automatically reroutes to arbiscan as needed) | ||
FOX_TOKEN_ADDRESS="$FOX_TOKEN_ADDRESS" forge script script/DeployFoxStaking.s.sol:DeployFoxStaking \ | ||
--rpc-url $RPC_URL \ | ||
--private-key $PRIVATE_KEY \ | ||
--broadcast \ | ||
-vvvvv \ | ||
--verify \ | ||
--verifier etherscan \ | ||
--verifier-url $VERIFIER_URL \ | ||
--etherscan-api-key $ETHERSCAN_API_KEY | ||
fi |
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,25 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.25; | ||
|
||
import "forge-std/Script.sol"; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
import {FoxStakingV1} from "../src/FoxStakingV1.sol"; | ||
|
||
contract DeployFoxStaking is Script { | ||
address foxTokenAddress; | ||
|
||
function setUp() public { | ||
foxTokenAddress = vm.envAddress("FOX_TOKEN_ADDRESS"); | ||
} | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
address foxStakingProxy = Upgrades.deployUUPSProxy( | ||
"FoxStakingV1.sol", | ||
abi.encodeCall(FoxStakingV1.initialize, (foxTokenAddress)) | ||
); | ||
vm.stopBroadcast(); | ||
console.log("Contract deployed at:", foxStakingProxy); | ||
} | ||
} |