Skip to content

Commit 819d192

Browse files
committed
Initialize the project
0 parents  commit 819d192

1,970 files changed

Lines changed: 380948 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
### Salt used to deploy the contracts. Recommended to use the same salt across different chains.
2+
CREATE2_SALT=0x0000000000000000000000000000000000000000000000000000000000000000
3+
4+
### The owner of the deployed contract.
5+
OWNER=
6+
7+
### The signer of the deployed contract.
8+
SIGNER=
9+
10+
### The treasury of the deployed contract.
11+
TREASURER=
12+
13+
### The chain to deploy to, specified by chain name (e.g. CHAIN=gravity_sepolia)
14+
CHAIN=gravity_sepolia
15+
16+
### RPCs for each chain ID
17+
RPC_MAINNET=https://mainnet.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c
18+
RPC_SEPOLIA=https://rpc.sepolia.org
19+
RPC_BSC=https://bsc-dataseed.bnbchain.org
20+
RPC_BSC_TESTNET=https://bsc-testnet.bnbchain.org
21+
RPC_BASE=https://mainnet.base.org
22+
RPC_GRAVITY_ALPHA_MAINNET=https://rpc.gravity.xyz
23+
RPC_GRAVITY_ALPHA_TESTNET_SEPOLIA=https://rpc-sepolia.gravity.xyz
24+
RPC_POLYGON=https://polygon-rpc.com
25+
RPC_ARBITRUM=https://arb1.arbitrum.io/rpc
26+
27+
### Etherscan API keys for each chain ID
28+
ETHERSCAN_API_KEY_MAINNET=
29+
ETHERSCAN_API_KEY_SEPOLIA=
30+
ETHERSCAN_API_KEY_BSC=
31+
ETHERSCAN_API_KEY_BSC_TESTNET=
32+
ETHERSCAN_API_KEY_BASE=
33+
ETHERSCAN_API_KEY_POLYGON=
34+
ETHERSCAN_API_KEY_ARBITRUM=
35+
36+
# Etherscan API URLs for each chain
37+
ETHERSCAN_API_URL_MAINNET=https://api.etherscan.io/api
38+
ETHERSCAN_API_URL_SEPOLIA=https://api-sepolia.etherscan.io/api
39+
ETHERSCAN_API_URL_BSC=https://api.bscscan.com/api
40+
ETHERSCAN_API_URL_BSC_TESTNET=https://api-testnet.bscscan.com/api
41+
ETHERSCAN_API_URL_BASE=https://api.basescan.org/api
42+
ETHERSCAN_API_URL_GRAVITY_ALPHA_MAINNET=https://explorer.gravity.xyz/api
43+
ETHERSCAN_API_URL_GRAVITY_ALPHA_TESTNET_SEPOLIA=https://explorer-sepolia.gravity.xyz/api
44+
ETHERSCAN_API_URL_POLYGON=https://api.polygonscan.com/api
45+
ETHERSCAN_API_URL_ARBITRUM=https://api.arbiscan.io/api
46+
47+
## Contract Deployer Private Key
48+
PRIVATE_KEY=

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
env:
10+
FOUNDRY_PROFILE: ci
11+
12+
jobs:
13+
check:
14+
strategy:
15+
fail-fast: true
16+
17+
name: Foundry project
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
submodules: recursive
23+
24+
- name: Install Foundry
25+
uses: foundry-rs/foundry-toolchain@v1
26+
with:
27+
cache: false
28+
29+
- name: Run Forge tests
30+
run: |
31+
forge test -vvv
32+
id: test

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
broadcast/
7+
# Docs
8+
docs/
9+
10+
# Dotenv file
11+
.env
12+
13+
lcov.info
14+
15+
.idea/

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/openzeppelin-foundry-upgrades"]
5+
path = lib/openzeppelin-foundry-upgrades
6+
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
7+
[submodule "lib/openzeppelin-contracts-upgradeable"]
8+
path = lib/openzeppelin-contracts-upgradeable
9+
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
10+
[submodule "lib/openzeppelin-contracts"]
11+
path = lib/openzeppelin-contracts
12+
url = https://github.com/OpenZeppelin/openzeppelin-contracts

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# EVM Vesting Earndrop
2+
3+
**EVM Vesting Earndrop** 是一个基于以太坊的智能合约项目,支持代币的分阶段发放和空投功能。该项目使用 [Foundry](https://book.getfoundry.sh/) 作为开发工具,提供高效的测试、部署和格式化工具。
4+
5+
## 功能
6+
7+
- **分阶段发放 (Vesting)**: 支持按时间段分发代币。
8+
- **空投 (Airdrop)**: 基于 Merkle 树验证的空投功能。
9+
- **权限管理**: 提供灵活的权限控制,包括管理员和签名者角色。
10+
11+
## 技术栈
12+
13+
- **Solidity**: 智能合约开发语言。
14+
- **Foundry**: 高效的以太坊开发工具链。
15+
- **OpenZeppelin**: 提供安全的智能合约库。
16+
17+
## 安装
18+
19+
确保已安装以下工具:
20+
21+
- [Foundry](https://book.getfoundry.sh/getting-started/installation.html)
22+
- [Node.js](https://nodejs.org/) (可选,用于前端集成)
23+
24+
克隆项目并安装依赖:
25+
26+
```shell
27+
$ git clone https://github.com/your-repo/evm_vesting_earndrop.git
28+
$ cd evm_vesting_earndrop
29+
$ forge install
30+
```
31+
32+
## 使用
33+
34+
### 构建项目
35+
36+
```shell
37+
$ forge build
38+
```
39+
40+
### 运行测试
41+
42+
```shell
43+
$ forge test
44+
```
45+
46+
47+
### 部署合约
48+
49+
使用 `Makefile` 提供的命令部署合约:
50+
51+
```shell
52+
$ make deploy_vesting_earndrop
53+
```
54+
55+
### 格式化代码
56+
57+
```shell
58+
$ forge fmt
59+
```
60+
61+
62+
63+
## 合约权限说明
64+
65+
- **Owner**: 合约的所有者,拥有以下权限:
66+
- 设置签名者地址 (`setSigner`)。
67+
- 设置资金管理员地址 (`setTreasurer`)。
68+
- **Admin**: 管理特定的 Earndrop,包括激活、撤销。
69+
- **安全限制**:
70+
- 签名者和资金管理员地址不能为零地址。
71+
- 未经授权的操作将抛出 `Unauthorized` 错误。
72+
73+
## 目录结构
74+
75+
```
76+
├── src
77+
│ └── VestingEarndrop.sol # 主合约
78+
├── test
79+
│ └── VestingEarndrop.t.sol # 测试文件
80+
├── script
81+
│ └── Deploy.s.sol # 部署脚本
82+
├── Makefile # 构建和部署命令
83+
├── foundry.toml # Foundry 配置文件
84+
└── README.md # 项目说明
85+
```
86+
87+
## 文档
88+
89+
- [Foundry 官方文档](https://book.getfoundry.sh/)
90+
- [OpenZeppelin 文档](https://docs.openzeppelin.com/)
91+
92+
## 贡献
93+
94+
欢迎提交 Issue 或 Pull Request 来改进本项目。
95+

deployments/1625.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"GALXE_VESTING_EARNDROP": "0x253C83C825F9Bac7F17EEc48af7F703ca49B8cf5"
3+
}

foundry.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[profile.default]
2+
src = "src"
3+
libs = ["lib"]
4+
solc = "0.8.24"
5+
ffi = true
6+
ast = true
7+
build_info = true
8+
via_ir = true
9+
extra_output = ["storageLayout"]
10+
fs_permissions = [
11+
{ access = "read", path = "./out" },
12+
{ access = "read-write", path = "./deployments" },
13+
]
14+
15+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
16+
17+
[fmt]
18+
sort_imports = true
19+
tab_width = 2
20+
21+
[rpc_endpoints]
22+
mainnet = "${RPC_MAINNET}"
23+
sepolia = "${RPC_SEPOLIA}"
24+
bsc = "${RPC_BSC}"
25+
bsc_testnet = "${RPC_BSC_TESTNET}"
26+
gravity-alpha-mainnet = "${RPC_GRAVITY_ALPHA_MAINNET}"
27+
gravity_alpha_testnet_sepolia = "${RPC_GRAVITY_ALPHA_TESTNET_SEPOLIA}"
28+
base = "${RPC_BASE}"
29+
arbitrum = "${RPC_ARBITRUM}"
30+
sei = "${RPC_SEI_EVM}"
31+
32+
[etherscan]
33+
mainnet = { key = "${ETHERSCAN_API_KEY_MAINNET}", url = "${ETHERSCAN_API_URL_MAINNET}" }
34+
sepolia = { key = "${ETHERSCAN_API_KEY_SEPOLIA}", url = "${ETHERSCAN_API_URL_SEPOLIA}" }
35+
bsc = { key = "${ETHERSCAN_API_KEY_BSC}", url = "${ETHERSCAN_API_URL_BSC}" }
36+
bsc_testnet = { key = "${ETHERSCAN_API_KEY_BSC_TESTNET}", url = "${ETHERSCAN_API_URL_BSC_TESTNET}" }
37+
gravity-alpha-mainnet = { key = "no-op", chain = "1625", url = "https://explorer.gravity.xyz/api" }
38+
gravity_alpha_testnet_sepolia = { key = "", chain = "13505", url = "${ETHERSCAN_API_URL_GRAVITY_ALPHA_TESTNET_SEPOLIA}" }
39+
base = { key = "${ETHERSCAN_API_KEY_BASE}", url = "${ETHERSCAN_API_URL_BASE}" }

lib/forge-std/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/Vm.sol linguist-generated
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Foundry
17+
uses: foundry-rs/foundry-toolchain@v1
18+
with:
19+
version: nightly
20+
21+
- name: Print forge version
22+
run: forge --version
23+
24+
# Backwards compatibility checks:
25+
# - the oldest and newest version of each supported minor version
26+
# - versions with specific issues
27+
- name: Check compatibility with latest
28+
if: always()
29+
run: |
30+
output=$(forge build --skip test)
31+
if echo "$output" | grep -q "Warning"; then
32+
echo "$output"
33+
exit 1
34+
fi
35+
36+
- name: Check compatibility with 0.8.0
37+
if: always()
38+
run: |
39+
output=$(forge build --skip test --use solc:0.8.0)
40+
if echo "$output" | grep -q "Warning"; then
41+
echo "$output"
42+
exit 1
43+
fi
44+
45+
- name: Check compatibility with 0.7.6
46+
if: always()
47+
run: |
48+
output=$(forge build --skip test --use solc:0.7.6)
49+
if echo "$output" | grep -q "Warning"; then
50+
echo "$output"
51+
exit 1
52+
fi
53+
54+
- name: Check compatibility with 0.7.0
55+
if: always()
56+
run: |
57+
output=$(forge build --skip test --use solc:0.7.0)
58+
if echo "$output" | grep -q "Warning"; then
59+
echo "$output"
60+
exit 1
61+
fi
62+
63+
- name: Check compatibility with 0.6.12
64+
if: always()
65+
run: |
66+
output=$(forge build --skip test --use solc:0.6.12)
67+
if echo "$output" | grep -q "Warning"; then
68+
echo "$output"
69+
exit 1
70+
fi
71+
72+
- name: Check compatibility with 0.6.2
73+
if: always()
74+
run: |
75+
output=$(forge build --skip test --use solc:0.6.2)
76+
if echo "$output" | grep -q "Warning"; then
77+
echo "$output"
78+
exit 1
79+
fi
80+
81+
# via-ir compilation time checks.
82+
- name: Measure compilation time of Test with 0.8.17 --via-ir
83+
if: always()
84+
run: forge build --skip test --contracts test/compilation/CompilationTest.sol --use solc:0.8.17 --via-ir
85+
86+
- name: Measure compilation time of TestBase with 0.8.17 --via-ir
87+
if: always()
88+
run: forge build --skip test --contracts test/compilation/CompilationTestBase.sol --use solc:0.8.17 --via-ir
89+
90+
- name: Measure compilation time of Script with 0.8.17 --via-ir
91+
if: always()
92+
run: forge build --skip test --contracts test/compilation/CompilationScript.sol --use solc:0.8.17 --via-ir
93+
94+
- name: Measure compilation time of ScriptBase with 0.8.17 --via-ir
95+
if: always()
96+
run: forge build --skip test --contracts test/compilation/CompilationScriptBase.sol --use solc:0.8.17 --via-ir
97+
98+
test:
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- name: Install Foundry
104+
uses: foundry-rs/foundry-toolchain@v1
105+
with:
106+
version: nightly
107+
108+
- name: Print forge version
109+
run: forge --version
110+
111+
- name: Run tests
112+
run: forge test -vvv
113+
114+
fmt:
115+
runs-on: ubuntu-latest
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Install Foundry
120+
uses: foundry-rs/foundry-toolchain@v1
121+
with:
122+
version: nightly
123+
124+
- name: Print forge version
125+
run: forge --version
126+
127+
- name: Check formatting
128+
run: forge fmt --check

0 commit comments

Comments
 (0)