-
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.
wip: contract deployment via forge and make
- Loading branch information
1 parent
d7b9920
commit 7326cb1
Showing
4 changed files
with
120 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
LOCAL_RPC_URL="http://localhost:8545" | ||
MAINNET_RPC_URL="https://mainnet.infura.io/v3/<your-infura-api-key>" | ||
SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/<your-infura-api-key>" | ||
ARBITRUM_ONE_RPC_URL="https://arbitrum-mainnet.infura.io/v3/<your-infura-api-key>" | ||
ARBITRUM_SEPOLIA_RPC_URL="https://arbitrum-sepolia.infura.io/v3/<your-infura-api-key>" | ||
|
||
LOCAL_PRIVATE_KEY="" | ||
ETHEREUM_PRIVATE_KEY="" | ||
ARBITRUM_PRIVATE_KEY="" | ||
|
||
# NOTE: Dont add quotes around the addresses, parsing will fail. | ||
MAINNET_FOX_TOKEN_ADDRESS=0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d | ||
SEPOLIA_FOX_TOKEN_ADDRESS= | ||
ARBITRUM_ONE_FOX_TOKEN_ADDRESS= | ||
ARBITRUM_SEPOLIA_FOX_TOKEN_ADDRESS= | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
-include .env | ||
|
||
.PHONY: all test clean help install anvil | ||
|
||
help: | ||
@echo "Usage: make [target]" | ||
@echo "" | ||
@echo "Targets:" | ||
@echo " all - Build the project" | ||
@echo " test - Run the tests" | ||
@echo " clean - Clean the project" | ||
@echo " deploy-mainnet - Deploy the contracts to local testnet" | ||
@echo " deploy-mainnet - Deploy the contracts to ethereum mainnet" | ||
@echo " deploy-sepolia - Deploy the contracts to ethereum sepolia testnet" | ||
@echo " deploy-arbitrum-one - Deploy the contracts to arbitrum one" | ||
@echo " deploy-arbitrum-sepolia - Deploy the contracts to arbitrum sepolia testnet" | ||
@echo " help - Show this help message" | ||
@echo " install - Install the project dependencies" | ||
@echo " anvil - Start the Anvil server" | ||
|
||
all: clean install build | ||
|
||
clean :; forge clean | ||
|
||
install :; forge install | ||
|
||
build :; forge build | ||
|
||
format :; forge fmt | ||
|
||
anvil :; anvil --fork-url $(MAINNET_RPC_URL) | ||
|
||
.PHONY: deploy-local deploy-mainnet deploy-sepolia deploy-arbitrum-one deploy-arbitrum-sepolia | ||
|
||
_deploy: | ||
forge script script/DeployFoxStaking.s.sol:DeployFoxStaking --broadcast -vvvvv $(NETWORK_ARGS) | ||
|
||
# Deploy the contract to local fork of mainnet. | ||
# Be sure to have a local fork of mainnet running via `make anvil`. | ||
deploy-local: export FOX_TOKEN_ADDRESS=$(MAINNET_FOX_TOKEN_ADDRESS) | ||
deploy-local: export NETWORK_ARGS=--fork-url $(LOCAL_RPC_URL) --private-key $(LOCAL_PRIVATE_KEY) | ||
deploy-local: | ||
${MAKE} _deploy | ||
|
||
# TODO: rewrite following local firk example above | ||
# deploy-mainnet: | ||
# FOX_TOKEN_ADDRESS := $(MAINNET_FOX_TOKEN_ADDRESS) | ||
# NETWORK_ARGS := --rpc-url $(MAINNET_RPC_URL) --private-key $(ETHEREUM_PRIVATE_KEY) --verify | ||
# ${MAKE} _deploy | ||
|
||
# deploy-sepolia: | ||
# FOX_TOKEN_ADDRESS := $(SEPOLIA_FOX_TOKEN_ADDRESS) | ||
# NETWORK_ARGS := --rpc-url $(SEPOLIA_RPC_URL) --private-key $(ETHEREUM_PRIVATE_KEY) --verify | ||
# ${MAKE} _deploy | ||
|
||
# deploy-arbitrum-one: | ||
# FOX_TOKEN_ADDRESS := $(ARBITRUM_ONE_FOX_TOKEN_ADDRESS) | ||
# NETWORK_ARGS := --rpc-url $(ARBITRUM_ONE_RPC_URL) --private-key $(ARBITRUM_PRIVATE_KEY) --verify | ||
# ${MAKE} _deploy | ||
|
||
# deploy-arbitrum-sepolia: | ||
# FOX_TOKEN_ADDRESS := $(ARBITRUM_SEPOLIA_FOX_TOKEN_ADDRESS) | ||
# NETWORK_ARGS := --rpc-url $(ARBITRUM_SEPOLIA_RPC_URL) --private-key $(ARBITRUM_PRIVATE_KEY) --verify | ||
# ${MAKE} _deploy |
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,23 @@ | ||
## 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` | ||
|
||
- **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. | ||
|
||
## Documentation | ||
|
||
https://book.getfoundry.sh/ | ||
|
||
## Usage | ||
|
||
### Build | ||
## Deploying | ||
|
||
```shell | ||
$ forge build | ||
``` | ||
|
||
### Test | ||
cd foundry | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
# Start a local fork | ||
make anvil | ||
|
||
### Format | ||
|
||
```shell | ||
$ forge fmt | ||
``` | ||
|
||
### Gas Snapshots | ||
|
||
```shell | ||
$ forge snapshot | ||
``` | ||
# Deploy to the local fork | ||
make install | ||
make clean | ||
make deploy-local | ||
|
||
### Anvil | ||
|
||
```shell | ||
$ anvil | ||
``` | ||
|
||
### Deploy | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
|
||
### Cast | ||
|
||
```shell | ||
$ cast <subcommand> | ||
``` | ||
|
||
### Help | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
# Test the contract deployed | ||
cast call $CONTRACT_ADDRESS "version()(uint256)" --rpc-url $LOCAL_RPC_URL | ||
``` |
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); | ||
} | ||
} |