Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei2308 committed Dec 4, 2024
0 parents commit 8bb7603
Show file tree
Hide file tree
Showing 21 changed files with 1,433 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Show Forge version
run: |
forge --version
- name: Run Forge fmt
run: |
forge fmt --check
id: fmt

- name: Run Forge build
run: |
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test -vvv
id: test
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
56 changes: 56 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-include .env

.PHONY: all test clean deploy fund help install snapshot format anvil

DEFAULT_ANVIL_KEY := 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

help:
@echo "Usage:"
@echo " make deploy [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\""
@echo ""
@echo " make fund [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\""

all: clean remove install update build

# Clean the repo
clean :; forge clean

# Remove modules
remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules"

install :; forge install cyfrin/[email protected] --no-commit && forge install smartcontractkit/[email protected] --no-commit && forge install foundry-rs/[email protected] --no-commit && forge install transmissions11/solmate@v6 --no-commit

# Update Dependencies
update:; forge update

build:; forge build

test :; forge test

snapshot :; forge snapshot

format :; forge fmt

anvil :; anvil -m 'test test test test test test test test test test test junk' --steps-tracing --block-time 1

NETWORK_ARGS := --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) --broadcast

ifeq ($(findstring --network sepolia,$(ARGS)),--network sepolia)
NETWORK_ARGS := --rpc-url $(SEPOLIA_RPC_URL) --private-key $(PRIVATE_KEY) --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY) -vvvv
endif

deploy:
@forge script script/DeployRaffle.s.sol:DeployRaffle $(NETWORK_ARGS)

createSubscription:
@forge script script/Interactions.s.sol:CreateSubscription $(NETWORK_ARGS)

addConsumer:
@forge script script/Interactions.s.sol:AddConsumer $(NETWORK_ARGS)

fundSubscription:
@forge script script/Interactions.s.sol:FundSubscription $(NETWORK_ARGS)
deploy-sepolia:
@forge script script/DeployRaffle.s.sol:DeployRaffle --rpc-url $(SEPOLIA_RPC_URL) --account default --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY) -vvvv
deploy-anvil:
@forge script script/DeployRaffle.s.sol:DeployRaffle --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) --broadcast
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## Foundry

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

Foundry consists of:

- **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

```shell
$ forge build
```

### Test

```shell
$ forge test
```

### Format

```shell
$ forge fmt
```

### Gas Snapshots

```shell
$ forge snapshot
```

### 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
```
148 changes: 148 additions & 0 deletions broadcast/DeployRaffle.s.sol/11155111/run-1733077503.json

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions broadcast/DeployRaffle.s.sol/11155111/run-1733077863.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"transactions": [
{
"hash": "0xafb904ff55c54fb7a79e661f225a3d42a8de690dacd810f01687f7ec00c00abd",
"transactionType": "CREATE",
"contractName": null,
"contractAddress": "0x4dc500aae81ca39f34b831d187ecb91f784e7f5e",
"function": null,
"arguments": null,
"transaction": {
"from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78",
"gas": "0x1350b3",
"value": "0x0",
"input": "0x61012060405234801561001157600080fd5b506040516111d73803806111d7833981016040819052610030916101dd565b8333806000816100875760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600080546001600160a01b0319166001600160a01b03848116919091179091558116156100b7576100b781610134565b5050506001600160a01b0381166100e15760405163d92e233d60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b039290921691909117905560809590955260a0939093524260045560c0525060e05263ffffffff16610100526005805460ff60a01b19169055610253565b336001600160a01b0382160361018c5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640161007e565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b60008060008060008060c087890312156101f657600080fd5b86516020880151604089015191975095506001600160a01b038116811461021c57600080fd5b80945050606087015192506080870151915060a087015163ffffffff8116811461024557600080fd5b809150509295509295509295565b60805160a05160c05160e05161010051610f3a61029d60003960006104e3015260006104b10152600061048e015260006105e601526000818160f101526103140152610f3a6000f3fe6080604052600436106100dd5760003560e01c806379ba50971161007f5780638ea98117116100595780638ea981171461023d5780639eccacf61461025d578063e55ae4e81461027d578063f2fde38b1461029d57600080fd5b806379ba5097146101d85780638da5cb5b146101ed5780638e7ea5b21461021f57600080fd5b80632cfcc539116100bb5780632cfcc5391461016d57806337899770146101755780634585e33b1461018a5780636e04ff0d146101aa57600080fd5b806309bc33a7146100e2578063115cbaf5146101245780631fe543e31461014b575b600080fd5b3480156100ee57600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b6040519081526020015b60405180910390f35b34801561013057600080fd5b50600554600160a01b900460ff1660405161011b9190610b9d565b34801561015757600080fd5b5061016b610166366004610bc5565b6102bd565b005b61016b610312565b34801561018157600080fd5b50600454610111565b34801561019657600080fd5b5061016b6101a5366004610c44565b6103ff565b3480156101b657600080fd5b506101ca6101c5366004610ccc565b6105de565b60405161011b929190610dc3565b3480156101e457600080fd5b5061016b61067e565b3480156101f957600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200161011b565b34801561022b57600080fd5b506005546001600160a01b0316610207565b34801561024957600080fd5b5061016b610258366004610de6565b610728565b34801561026957600080fd5b50600254610207906001600160a01b031681565b34801561028957600080fd5b50610207610298366004610e16565b61081a565b3480156102a957600080fd5b5061016b6102b8366004610de6565b61084a565b6002546001600160a01b031633146103025760025460405163073e64fd60e21b81523360048201526001600160a01b0390911660248201526044015b60405180910390fd5b61030d83838361085e565b505050565b7f000000000000000000000000000000000000000000000000000000000000000034101561035357604051633e48252960e01b815260040160405180910390fd5b6001600554600160a01b900460ff16600181111561037357610373610b87565b0361039157604051636eac21ed60e01b815260040160405180910390fd5b6003805460018101825560009182527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180546001600160a01b0319163390811790915560405190917f634f3211e3a4e43fee5a21ad9f87ca153b300fc78b1c557a2057dbe9c63bcb4791a2565b6000610419604051806020016040528060008152506105de565b5090508061046f57600354600554479190600160a01b900460ff16600181111561044557610445610b87565b60405163e059521b60e01b81526004810193909352602483019190915260448201526064016102f9565b6005805460ff60a01b1916600160a01b1790556040805160c0810182527f000000000000000000000000000000000000000000000000000000000000000081527f000000000000000000000000000000000000000000000000000000000000000060208083019190915260018284018190527f000000000000000000000000000000000000000000000000000000000000000063ffffffff1660608401526080830152825190810190925260008083529160a082019061052e9061099e565b9052600254604051634d8e1c2f60e11b81529192506000916001600160a01b0390911690639b1c385e90610566908590600401610e2f565b6020604051808303816000875af1158015610585573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a99190610e8c565b60405190915081907fcd6e45c8998311cab7e9d4385596cac867e20a0587194b954fa3a731c93ce78b90600090a25050505050565b6000606060007f0000000000000000000000000000000000000000000000000000000000000000600454426106139190610ea5565b10159050600080600554600160a01b900460ff16600181111561063857610638610b87565b6003549114915047151590151583801561064f5750825b80156106585750815b80156106615750805b604080516020810190915260008152909890975095505050505050565b6001546001600160a01b031633146106d15760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b60448201526064016102f9565b60008054336001600160a01b0319808316821784556001805490911690556040516001600160a01b0390921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6000546001600160a01b0316331480159061074e57506002546001600160a01b03163314155b1561079f57336107666000546001600160a01b031690565b60025460405163061db9c160e01b81526001600160a01b03938416600482015291831660248301529190911660448201526064016102f9565b6001600160a01b0381166107c65760405163d92e233d60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd1a6a14209a385a964d036e404cb5cfb71f4000cdb03c9366292430787261be69060200160405180910390a150565b60006003828154811061082f5761082f610ecc565b6000918252602090912001546001600160a01b031692915050565b610852610a0f565b61085b81610a64565b50565b6003546000908383838161087457610874610ecc565b905060200201356108859190610ee2565b905060006003828154811061089c5761089c610ecc565b600091825260208083209190910154600580546001600160a81b0319166001600160a01b039092169182179055604080519384529183019182905291519192506108e99160039190610b0d565b50426004556040516001600160a01b038216907f5b690ec4a06fe979403046eaeea5b3ce38524683c3001f662c8b5a829632f7df90600090a26000816001600160a01b03164760405160006040518083038185875af1925050503d806000811461096f576040519150601f19603f3d011682016040523d82523d6000602084013e610974565b606091505b50509050806109965760405163ba31c4f360e01b815260040160405180910390fd5b505050505050565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa826040516024016109d791511515815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915292915050565b6000546001600160a01b03163314610a625760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b60448201526064016102f9565b565b336001600160a01b03821603610abc5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c6600000000000000000060448201526064016102f9565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b828054828255906000526020600020908101928215610b62579160200282015b82811115610b6257825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190610b2d565b50610b6e929150610b72565b5090565b5b80821115610b6e5760008155600101610b73565b634e487b7160e01b600052602160045260246000fd5b6020810160028310610bbf57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600060408486031215610bda57600080fd5b83359250602084013567ffffffffffffffff80821115610bf957600080fd5b818601915086601f830112610c0d57600080fd5b813581811115610c1c57600080fd5b8760208260051b8501011115610c3157600080fd5b6020830194508093505050509250925092565b60008060208385031215610c5757600080fd5b823567ffffffffffffffff80821115610c6f57600080fd5b818501915085601f830112610c8357600080fd5b813581811115610c9257600080fd5b866020828501011115610ca457600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215610cde57600080fd5b813567ffffffffffffffff80821115610cf657600080fd5b818401915084601f830112610d0a57600080fd5b813581811115610d1c57610d1c610cb6565b604051601f8201601f19908116603f01168101908382118183101715610d4457610d44610cb6565b81604052828152876020848701011115610d5d57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000815180845260005b81811015610da357602081850181015186830182015201610d87565b506000602082860101526020601f19601f83011685010191505092915050565b8215158152604060208201526000610dde6040830184610d7d565b949350505050565b600060208284031215610df857600080fd5b81356001600160a01b0381168114610e0f57600080fd5b9392505050565b600060208284031215610e2857600080fd5b5035919050565b60208152815160208201526020820151604082015261ffff60408301511660608201526000606083015163ffffffff80821660808501528060808601511660a0850152505060a083015160c080840152610dde60e0840182610d7d565b600060208284031215610e9e57600080fd5b5051919050565b81810381811115610ec657634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052603260045260246000fd5b600082610eff57634e487b7160e01b600052601260045260246000fd5b50069056fea26469706673582212208d128a794902666ab1415ad95343826351c4273ebd5be6a2f4a4623bcf69b71964736f6c63430008130033000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000009ddfaca8183c41ad55329bdeed9f6a8d53168b1b787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677aef68324494b75c7dca155e901818bd494f400704caad97d21d4a46584a2b25c30000000000000000000000000000000000000000000000000000000000007a120",
"nonce": "0x9",
"chainId": "0xaa36a7"
},
"additionalContracts": [],
"isFixedGasLimit": false
},
{
"hash": "0xda3131c87e9e982238f0291277bff1793c6468b10a1c70c4a12c111912a73cff",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b",
"function": "addConsumer(uint256,address)",
"arguments": [
"111500668155860965098338768718180110939098399012303677892162632160562400877616",
"0x4Dc500aAe81Ca39f34b831d187ecB91F784E7F5E"
],
"transaction": {
"from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78",
"to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b",
"gas": "0x21fa6",
"value": "0x0",
"input": "0xbec4c08cf68324494b75c7dca155e901818bd494f400704caad97d21d4a46584a2b25c300000000000000000000000004dc500aae81ca39f34b831d187ecb91f784e7f5e",
"nonce": "0xa",
"chainId": "0xaa36a7"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x116a7c8",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"transactionHash": "0xafb904ff55c54fb7a79e661f225a3d42a8de690dacd810f01687f7ec00c00abd",
"transactionIndex": "0x130",
"blockHash": "0xde3ed26c6c9e21ad7c80dc8c3d9577aa5039ce86d56114b20634460da88e431d",
"blockNumber": "0x6dbaa3",
"gasUsed": "0xedb9e",
"effectiveGasPrice": "0x7fc93b9d",
"from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78",
"to": null,
"contractAddress": "0x4dc500aae81ca39f34b831d187ecb91f784e7f5e"
},
{
"status": "0x1",
"cumulativeGasUsed": "0x1181b82",
"logs": [
{
"address": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b",
"topics": [
"0x1e980d04aa7648e205713e5e8ea3808672ac163d10936d36f91b2c88ac1575e1",
"0xf68324494b75c7dca155e901818bd494f400704caad97d21d4a46584a2b25c30"
],
"data": "0x0000000000000000000000004dc500aae81ca39f34b831d187ecb91f784e7f5e",
"blockHash": "0xde3ed26c6c9e21ad7c80dc8c3d9577aa5039ce86d56114b20634460da88e431d",
"blockNumber": "0x6dbaa3",
"transactionHash": "0xda3131c87e9e982238f0291277bff1793c6468b10a1c70c4a12c111912a73cff",
"transactionIndex": "0x131",
"logIndex": "0xab",
"removed": false
}
],
"logsBloom": "0x00000000000000000000000000000080000000008020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000008000000000000000000000000000000000000000000000000002000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000",
"type": "0x2",
"transactionHash": "0xda3131c87e9e982238f0291277bff1793c6468b10a1c70c4a12c111912a73cff",
"transactionIndex": "0x131",
"blockHash": "0xde3ed26c6c9e21ad7c80dc8c3d9577aa5039ce86d56114b20634460da88e431d",
"blockNumber": "0x6dbaa3",
"gasUsed": "0x173ba",
"effectiveGasPrice": "0x7fc93b9d",
"from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78",
"to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b",
"contractAddress": null
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1733077863,
"chain": 11155111,
"commit": "9ed1329"
}
Loading

0 comments on commit 8bb7603

Please sign in to comment.