-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
96 additions
and
53 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,3 @@ | ||
PRIVATE_KEY= | ||
GOVERNED_RECIPIENT_ADDRESS= | ||
GNOSISSCAN_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 |
---|---|---|
|
@@ -12,3 +12,5 @@ docs/ | |
|
||
# Dotenv file | ||
.env | ||
|
||
recipients.json |
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,30 @@ | ||
## Foundry | ||
# Seer Airdrop contracts | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
This repository contains smart contracts and scripts for distributing Seer credits to participants. | ||
|
||
Foundry consists of: | ||
## Prerequisites | ||
|
||
- **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. | ||
- [Foundry](https://book.getfoundry.sh/getting-started/installation) installed | ||
|
||
## Documentation | ||
## Environment Setup | ||
|
||
https://book.getfoundry.sh/ | ||
1. Clone this repository | ||
2. Create a `.env` file in the root directory with the following variables: | ||
|
||
## Usage | ||
|
||
### Build | ||
|
||
```shell | ||
$ forge build | ||
``` | ||
|
||
### Test | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
|
||
### Format | ||
|
||
```shell | ||
$ forge fmt | ||
``` | ||
|
||
### Gas Snapshots | ||
|
||
```shell | ||
$ forge snapshot | ||
``` | ||
|
||
### Anvil | ||
|
||
```shell | ||
$ anvil | ||
PRIVATE_KEY= # Your wallet's private key for deploying contracts | ||
GOVERNED_RECIPIENT_ADDRESS= # Address of the deployed GovernedRecipient contract (needed for adding recipients) | ||
GNOSISSCAN_API_KEY= # API key from https://gnosisscan.io to verify contracts | ||
``` | ||
|
||
### Deploy | ||
## Deploy contracts | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
`forge script script/Deploy.s.sol:Deploy --rpc-url gnosis --broadcast --verify -vvvv --etherscan-api-key gnosis` | ||
|
||
### Cast | ||
## Create recipients.json | ||
|
||
```shell | ||
$ cast <subcommand> | ||
``` | ||
Use the `recipients.json.dist` file as template. | ||
|
||
### Help | ||
## Add recipients | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
``` | ||
`forge script script/AddRecipients.s.sol:AddRecipients --rpc-url gnosis --broadcast -vvvv` |
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,6 @@ | ||
[ | ||
"0x0000000000000000000000000000000000000000", | ||
"0x0000000000000000000000000000000000000001", | ||
"0x0000000000000000000000000000000000000002", | ||
"0x0000000000000000000000000000000000000003" | ||
] |
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,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.13; | ||
|
||
import "../src/GovernedRecipient.sol"; | ||
import "../src/MultiDrop.sol"; | ||
import "../src/Token.sol"; | ||
import "forge-std/Script.sol"; | ||
|
||
interface Disperse { | ||
function disperseEther(address[] memory recipients, uint256[] memory values) external payable; | ||
} | ||
|
||
contract AddRecipients is Script { | ||
address disperse = address(0xD152f549545093347A162Dce210e7293f1452150); // gnosis chain address | ||
uint256 amount = 0.02 ether; | ||
|
||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
GovernedRecipient governedRecipient = GovernedRecipient(vm.envAddress("GOVERNED_RECIPIENT_ADDRESS")); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
string memory root = vm.projectRoot(); | ||
string memory path = string.concat(root, "/recipients.json"); | ||
string memory json = vm.readFile(path); | ||
address[] memory recipients = abi.decode(vm.parseJson(json), (address[])); | ||
|
||
uint256[] memory amounts = new uint256[](recipients.length); | ||
for(uint256 i = 0; i < recipients.length; i++) { | ||
amounts[i] = amount; | ||
} | ||
Disperse(disperse).disperseEther{value: amount * recipients.length}(recipients, amounts); | ||
|
||
governedRecipient.addRecipients(recipients); | ||
|
||
vm.stopBroadcast(); | ||
|
||
console.log("Added recipients:", recipients.length); | ||
} | ||
} |
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,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "../src/GovernedRecipient.sol"; | ||
import "../src/MultiDrop.sol"; | ||
import "forge-std/Script.sol"; | ||
|
||
contract Deploy is Script { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
GovernedRecipient governedRecipient = new GovernedRecipient(); | ||
MultiDrop multiDrop = new MultiDrop(governedRecipient); | ||
|
||
vm.stopBroadcast(); | ||
|
||
console.log("GovernedRecipient deployed to:", address(governedRecipient)); | ||
console.log("MultiDrop deployed to:", address(multiDrop)); | ||
} | ||
} |