diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..762a296 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85198aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Compiler files +cache/ +out/ + +# Ignores development broadcast logs +!/broadcast +/broadcast/*/31337/ +/broadcast/**/dry-run/ + +# Docs +docs/ + +# Dotenv file +.env diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..877ccc7 --- /dev/null +++ b/Makefile @@ -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/foundry-devops@0.2.2 --no-commit && forge install smartcontractkit/chainlink-brownie-contracts@1.1.1 --no-commit && forge install foundry-rs/forge-std@v1.8.2 --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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9265b45 --- /dev/null +++ b/README.md @@ -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 --private-key +``` + +### Cast + +```shell +$ cast +``` + +### Help + +```shell +$ forge --help +$ anvil --help +$ cast --help +``` diff --git a/broadcast/DeployRaffle.s.sol/11155111/run-1733077503.json b/broadcast/DeployRaffle.s.sol/11155111/run-1733077503.json new file mode 100644 index 0000000..0a632c4 --- /dev/null +++ b/broadcast/DeployRaffle.s.sol/11155111/run-1733077503.json @@ -0,0 +1,148 @@ +{ + "transactions": [ + { + "hash": "0xa0c3983ddcc38258bf9f583a67cc4133efcbf1d86e228ecac7dbd5d8c1e8fc6c", + "transactionType": "CALL", + "contractName": null, + "contractAddress": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "function": "createSubscription()", + "arguments": [], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "gas": "0x25056", + "value": "0x0", + "input": "0xa21a23e4", + "nonce": "0x5", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0xc14e18747adbced52c3e42eb8c9f884f8813c708afcd6206739aa1df6eca037b", + "transactionType": "CALL", + "contractName": null, + "contractAddress": "0x779877a7b0d9e8603169ddbd7836e478b4624789", + "function": "transferAndCall(address,uint256,bytes)", + "arguments": [ + "0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B", + "3000000000000000000", + "0x5452a027b7857930812c2e3d8734eae69ab40b6988060af7eae2e771632f793f" + ], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x779877a7b0d9e8603169ddbd7836e478b4624789", + "gas": "0x1c1ff", + "value": "0x0", + "input": "0x4000aea00000000000000000000000009ddfaca8183c41ad55329bdeed9f6a8d53168b1b00000000000000000000000000000000000000000000000029a2241af62c0000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000205452a027b7857930812c2e3d8734eae69ab40b6988060af7eae2e771632f793f", + "nonce": "0x6", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0x77dc0357ba9ed593611478cfa61873b26ea417e4e4b59d755cb66cdb69c7b94f", + "transactionType": "CREATE", + "contractName": "Raffle", + "contractAddress": "0xec2afe183419fc1a8a7756ba738e7728e97f1bfb", + "function": null, + "arguments": [ + "10000000000000000", + "30", + "0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B", + "0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae", + "38140266090486667793314437766644211572919829264054297995813946772874603755839", + "500000" + ], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "gas": "0x2323b9", + "value": "0x0", + "input": "0x6101206040523480156200001257600080fd5b506040516200242e3803806200242e8339818101604052810190620000389190620004a7565b83338060008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603620000ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000a590620005a4565b60405180910390fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614620001355762000134816200025760201b60201c565b5b505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036200019f576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505085608081815250508460a08181525050426004819055508260c081815250508160e081815250508063ffffffff166101008163ffffffff16815250506000600560146101000a81548160ff02191690836001811115620002465762000245620005c6565b5b021790555050505050505062000667565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603620002c8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620002bf9062000645565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127860405160405180910390a350565b600080fd5b6000819050919050565b620003a0816200038b565b8114620003ac57600080fd5b50565b600081519050620003c08162000395565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003f382620003c6565b9050919050565b6200040581620003e6565b81146200041157600080fd5b50565b6000815190506200042581620003fa565b92915050565b6000819050919050565b62000440816200042b565b81146200044c57600080fd5b50565b600081519050620004608162000435565b92915050565b600063ffffffff82169050919050565b620004818162000466565b81146200048d57600080fd5b50565b600081519050620004a18162000476565b92915050565b60008060008060008060c08789031215620004c757620004c662000386565b5b6000620004d789828a01620003af565b9650506020620004ea89828a01620003af565b9550506040620004fd89828a0162000414565b94505060606200051089828a016200044f565b93505060806200052389828a01620003af565b92505060a06200053689828a0162000490565b9150509295509295509295565b600082825260208201905092915050565b7f43616e6e6f7420736574206f776e657220746f207a65726f0000000000000000600082015250565b60006200058c60188362000543565b9150620005998262000554565b602082019050919050565b60006020820190508181036000830152620005bf816200057d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000600082015250565b60006200062d60178362000543565b91506200063a82620005f5565b602082019050919050565b6000602082019050818103600083015262000660816200061e565b9050919050565b60805160a05160c05160e05161010051611d7b620006b360003960006106bb0152600061068a01526000610664015260006107ef015260008181610328015261042b0152611d7b6000f3fe6080604052600436106100dd5760003560e01c806379ba50971161007f5780638ea98117116100595780638ea981171461026a5780639eccacf614610293578063e55ae4e8146102be578063f2fde38b146102fb576100dd565b806379ba5097146101fd5780638da5cb5b146102145780638e7ea5b21461023f576100dd565b80632cfcc539116100bb5780632cfcc53914610161578063378997701461016b5780634585e33b146101965780636e04ff0d146101bf576100dd565b806309bc33a7146100e2578063115cbaf51461010d5780631fe543e314610138575b600080fd5b3480156100ee57600080fd5b506100f7610324565b604051610104919061123b565b60405180910390f35b34801561011957600080fd5b5061012261034c565b60405161012f91906112cd565b60405180910390f35b34801561014457600080fd5b5061015f600480360381019061015a919061138d565b610363565b005b610169610429565b005b34801561017757600080fd5b50610180610597565b60405161018d919061123b565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b89190611443565b6105a1565b005b3480156101cb57600080fd5b506101e660048036038101906101e191906115d1565b6107e7565b6040516101f49291906116b4565b60405180910390f35b34801561020957600080fd5b506102126108a9565b005b34801561022057600080fd5b50610229610a3e565b6040516102369190611725565b60405180910390f35b34801561024b57600080fd5b50610254610a67565b6040516102619190611725565b60405180910390f35b34801561027657600080fd5b50610291600480360381019061028c919061176c565b610a91565b005b34801561029f57600080fd5b506102a8610c72565b6040516102b591906117f8565b60405180910390f35b3480156102ca57600080fd5b506102e560048036038101906102e09190611813565b610c98565b6040516102f29190611725565b60405180910390f35b34801561030757600080fd5b50610322600480360381019061031d919061176c565b610ce0565b005b60007f0000000000000000000000000000000000000000000000000000000000000000905090565b6000600560149054906101000a900460ff16905090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104195733600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040517f1cf993f4000000000000000000000000000000000000000000000000000000008152600401610410929190611840565b60405180910390fd5b610424838383610cf4565b505050565b7f0000000000000000000000000000000000000000000000000000000000000000341015610483576040517f3e48252900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018081111561049657610495611256565b5b600560149054906101000a900460ff1660018111156104b8576104b7611256565b5b036104ef576040517f6eac21ed00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff167f634f3211e3a4e43fee5a21ad9f87ca153b300fc78b1c557a2057dbe9c63bcb4760405160405180910390a2565b6000600454905090565b60006105bb604051806020016040528060008152506107e7565b5090508061062a5747600380549050600560149054906101000a900460ff1660018111156105ec576105eb611256565b5b6040517fe059521b00000000000000000000000000000000000000000000000000000000815260040161062193929190611869565b60405180910390fd5b6001600560146101000a81548160ff021916908360018111156106505761064f611256565b5b021790555060006040518060c001604052807f000000000000000000000000000000000000000000000000000000000000000081526020017f00000000000000000000000000000000000000000000000000000000000000008152602001600161ffff1681526020017f000000000000000000000000000000000000000000000000000000000000000063ffffffff168152602001600163ffffffff16815260200161070c604051806020016040528060001515815250610f27565b81525090506000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639b1c385e836040518263ffffffff1660e01b815260040161076e91906119d7565b6020604051808303816000875af115801561078d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b19190611a0e565b9050807fcd6e45c8998311cab7e9d4385596cac867e20a0587194b954fa3a731c93ce78b60405160405180910390a25050505050565b6000606060007f00000000000000000000000000000000000000000000000000000000000000006004544261081c9190611a6a565b10159050600080600181111561083557610834611256565b5b600560149054906101000a900460ff16600181111561085757610856611256565b5b149050600080471190506000806003805490501190508380156108775750825b80156108805750815b80156108895750805b955085604051806020016040528060008152509550955050505050915091565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610939576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093090611afb565b60405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610a99610a3e565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614158015610b225750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b15610b915733610b30610a3e565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040517f061db9c1000000000000000000000000000000000000000000000000000000008152600401610b8893929190611b1b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610bf7576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fd1a6a14209a385a964d036e404cb5cfb71f4000cdb03c9366292430787261be681604051610c679190611725565b60405180910390a150565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060038281548110610cae57610cad611b52565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610ce8610fbf565b610cf18161104f565b50565b600060038054905083836000818110610d1057610d0f611b52565b5b90506020020135610d219190611bb0565b9050600060038281548110610d3957610d38611b52565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905080600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600560146101000a81548160ff02191690836001811115610dcd57610dcc611256565b5b0217905550600067ffffffffffffffff811115610ded57610dec6114a6565b5b604051908082528060200260200182016040528015610e1b5781602001602082028036833780820191505090505b5060039080519060200190610e3192919061117b565b50426004819055508073ffffffffffffffffffffffffffffffffffffffff167f5b690ec4a06fe979403046eaeea5b3ce38524683c3001f662c8b5a829632f7df60405160405180910390a260008173ffffffffffffffffffffffffffffffffffffffff1647604051610ea290611c12565b60006040518083038185875af1925050503d8060008114610edf576040519150601f19603f3d011682016040523d82523d6000602084013e610ee4565b606091505b5050905080610f1f576040517fba31c4f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa82604051602401610f5b9190611c52565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461104d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104490611cb9565b60405180910390fd5b565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036110bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b490611d25565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127860405160405180910390a350565b8280548282559060005260206000209081019282156111f4579160200282015b828111156111f35782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061119b565b5b5090506112019190611205565b5090565b5b8082111561121e576000816000905550600101611206565b5090565b6000819050919050565b61123581611222565b82525050565b6000602082019050611250600083018461122c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6002811061129657611295611256565b5b50565b60008190506112a782611285565b919050565b60006112b782611299565b9050919050565b6112c7816112ac565b82525050565b60006020820190506112e260008301846112be565b92915050565b6000604051905090565b600080fd5b600080fd5b61130581611222565b811461131057600080fd5b50565b600081359050611322816112fc565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261134d5761134c611328565b5b8235905067ffffffffffffffff81111561136a5761136961132d565b5b60208301915083602082028301111561138657611385611332565b5b9250929050565b6000806000604084860312156113a6576113a56112f2565b5b60006113b486828701611313565b935050602084013567ffffffffffffffff8111156113d5576113d46112f7565b5b6113e186828701611337565b92509250509250925092565b60008083601f84011261140357611402611328565b5b8235905067ffffffffffffffff8111156114205761141f61132d565b5b60208301915083600182028301111561143c5761143b611332565b5b9250929050565b6000806020838503121561145a576114596112f2565b5b600083013567ffffffffffffffff811115611478576114776112f7565b5b611484858286016113ed565b92509250509250929050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6114de82611495565b810181811067ffffffffffffffff821117156114fd576114fc6114a6565b5b80604052505050565b60006115106112e8565b905061151c82826114d5565b919050565b600067ffffffffffffffff82111561153c5761153b6114a6565b5b61154582611495565b9050602081019050919050565b82818337600083830152505050565b600061157461156f84611521565b611506565b9050828152602081018484840111156115905761158f611490565b5b61159b848285611552565b509392505050565b600082601f8301126115b8576115b7611328565b5b81356115c8848260208601611561565b91505092915050565b6000602082840312156115e7576115e66112f2565b5b600082013567ffffffffffffffff811115611605576116046112f7565b5b611611848285016115a3565b91505092915050565b60008115159050919050565b61162f8161161a565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561166f578082015181840152602081019050611654565b60008484015250505050565b600061168682611635565b6116908185611640565b93506116a0818560208601611651565b6116a981611495565b840191505092915050565b60006040820190506116c96000830185611626565b81810360208301526116db818461167b565b90509392505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061170f826116e4565b9050919050565b61171f81611704565b82525050565b600060208201905061173a6000830184611716565b92915050565b61174981611704565b811461175457600080fd5b50565b60008135905061176681611740565b92915050565b600060208284031215611782576117816112f2565b5b600061179084828501611757565b91505092915050565b6000819050919050565b60006117be6117b96117b4846116e4565b611799565b6116e4565b9050919050565b60006117d0826117a3565b9050919050565b60006117e2826117c5565b9050919050565b6117f2816117d7565b82525050565b600060208201905061180d60008301846117e9565b92915050565b600060208284031215611829576118286112f2565b5b600061183784828501611313565b91505092915050565b60006040820190506118556000830185611716565b6118626020830184611716565b9392505050565b600060608201905061187e600083018661122c565b61188b602083018561122c565b611898604083018461122c565b949350505050565b6000819050919050565b6118b3816118a0565b82525050565b6118c281611222565b82525050565b600061ffff82169050919050565b6118df816118c8565b82525050565b600063ffffffff82169050919050565b6118fe816118e5565b82525050565b600082825260208201905092915050565b600061192082611635565b61192a8185611904565b935061193a818560208601611651565b61194381611495565b840191505092915050565b600060c08301600083015161196660008601826118aa565b50602083015161197960208601826118b9565b50604083015161198c60408601826118d6565b50606083015161199f60608601826118f5565b5060808301516119b260808601826118f5565b5060a083015184820360a08601526119ca8282611915565b9150508091505092915050565b600060208201905081810360008301526119f1818461194e565b905092915050565b600081519050611a08816112fc565b92915050565b600060208284031215611a2457611a236112f2565b5b6000611a32848285016119f9565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611a7582611222565b9150611a8083611222565b9250828203905081811115611a9857611a97611a3b565b5b92915050565b600082825260208201905092915050565b7f4d7573742062652070726f706f736564206f776e657200000000000000000000600082015250565b6000611ae5601683611a9e565b9150611af082611aaf565b602082019050919050565b60006020820190508181036000830152611b1481611ad8565b9050919050565b6000606082019050611b306000830186611716565b611b3d6020830185611716565b611b4a6040830184611716565b949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611bbb82611222565b9150611bc683611222565b925082611bd657611bd5611b81565b5b828206905092915050565b600081905092915050565b50565b6000611bfc600083611be1565b9150611c0782611bec565b600082019050919050565b6000611c1d82611bef565b9150819050919050565b611c308161161a565b82525050565b602082016000820151611c4c6000850182611c27565b50505050565b6000602082019050611c676000830184611c36565b92915050565b7f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000600082015250565b6000611ca3601683611a9e565b9150611cae82611c6d565b602082019050919050565b60006020820190508181036000830152611cd281611c96565b9050919050565b7f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000600082015250565b6000611d0f601783611a9e565b9150611d1a82611cd9565b602082019050919050565b60006020820190508181036000830152611d3e81611d02565b905091905056fea2646970667358221220348b6784d9a8e1179af586835486a78ffb16adc24635f01701e3332f1ac3577864736f6c63430008130033000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000009ddfaca8183c41ad55329bdeed9f6a8d53168b1b787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae5452a027b7857930812c2e3d8734eae69ab40b6988060af7eae2e771632f793f000000000000000000000000000000000000000000000000000000000007a120", + "nonce": "0x7", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0x8219407b810c60d0d66c1fc4f635ebeef0633e7b35dce76ad28033ce1a89b751", + "transactionType": "CALL", + "contractName": null, + "contractAddress": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "function": "addConsumer(uint256,address)", + "arguments": [ + "38140266090486667793314437766644211572919829264054297995813946772874603755839", + "0xEc2AFE183419fc1A8a7756BA738e7728e97F1Bfb" + ], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "gas": "0x21fc9", + "value": "0x0", + "input": "0xbec4c08c5452a027b7857930812c2e3d8734eae69ab40b6988060af7eae2e771632f793f000000000000000000000000ec2afe183419fc1a8a7756ba738e7728e97f1bfb", + "nonce": "0x8", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [ + { + "status": "0x1", + "cumulativeGasUsed": "0x5272e2", + "logs": [ + { + "address": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "topics": [ + "0x1d3015d7ba850fa198dc7b1a3f5d42779313a681035f77c8c03764c61005518d", + "0xf68324494b75c7dca155e901818bd494f400704caad97d21d4a46584a2b25c30" + ], + "data": "0x00000000000000000000000095fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "blockHash": "0x19a35a45637184a614d5724c8f7d80cdad5a600f99e0738b07bc3ffac9275b21", + "blockNumber": "0x6dba8b", + "transactionHash": "0xa0c3983ddcc38258bf9f583a67cc4133efcbf1d86e228ecac7dbd5d8c1e8fc6c", + "transactionIndex": "0x58", + "logIndex": "0x42", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000000000000008020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000008000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000", + "type": "0x2", + "transactionHash": "0xa0c3983ddcc38258bf9f583a67cc4133efcbf1d86e228ecac7dbd5d8c1e8fc6c", + "transactionIndex": "0x58", + "blockHash": "0x19a35a45637184a614d5724c8f7d80cdad5a600f99e0738b07bc3ffac9275b21", + "blockNumber": "0x6dba8b", + "gasUsed": "0x1acd8", + "effectiveGasPrice": "0x7d808228", + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "contractAddress": null + }, + { + "status": "0x1", + "cumulativeGasUsed": "0x6f4750", + "logs": [], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "transactionHash": "0x77dc0357ba9ed593611478cfa61873b26ea417e4e4b59d755cb66cdb69c7b94f", + "transactionIndex": "0x5d", + "blockHash": "0x19a35a45637184a614d5724c8f7d80cdad5a600f99e0738b07bc3ffac9275b21", + "blockNumber": "0x6dba8b", + "gasUsed": "0x1b07ca", + "effectiveGasPrice": "0x7d808228", + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": null, + "contractAddress": "0xec2afe183419fc1a8a7756ba738e7728e97f1bfb" + } + ], + "libraries": [], + "pending": [], + "returns": {}, + "timestamp": 1733077503, + "chain": 11155111, + "commit": "9ed1329" +} \ No newline at end of file diff --git a/broadcast/DeployRaffle.s.sol/11155111/run-1733077863.json b/broadcast/DeployRaffle.s.sol/11155111/run-1733077863.json new file mode 100644 index 0000000..a243c80 --- /dev/null +++ b/broadcast/DeployRaffle.s.sol/11155111/run-1733077863.json @@ -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" +} \ No newline at end of file diff --git a/broadcast/DeployRaffle.s.sol/11155111/run-1733336585.json b/broadcast/DeployRaffle.s.sol/11155111/run-1733336585.json new file mode 100644 index 0000000..2b90da0 --- /dev/null +++ b/broadcast/DeployRaffle.s.sol/11155111/run-1733336585.json @@ -0,0 +1,106 @@ +{ + "transactions": [ + { + "hash": "0xd65a9daecfe5a146af295011d0c0967e419fd8a1726923c883678e84df392e6b", + "transactionType": "CREATE", + "contractName": "Raffle", + "contractAddress": "0xd28ebaebef523db361c6fe8266b3c6001454b4c3", + "function": null, + "arguments": [ + "10000000000000000", + "30", + "0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B", + "0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae", + "92929868081786283001051859072688436333659780913164620031290002461021448262939", + "500000" + ], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "gas": "0x13937d", + "value": "0x0", + "input": "0x61012060405234801561001157600080fd5b5060405161121c38038061121c833981016040819052610030916101dd565b8333806000816100875760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600080546001600160a01b0319166001600160a01b03848116919091179091558116156100b7576100b781610134565b5050506001600160a01b0381166100e15760405163d92e233d60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b039290921691909117905560809590955260a0939093524260045560c0525060e05263ffffffff16610100526005805460ff60a01b19169055610253565b336001600160a01b0382160361018c5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640161007e565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b60008060008060008060c087890312156101f657600080fd5b86516020880151604089015191975095506001600160a01b038116811461021c57600080fd5b80945050606087015192506080870151915060a087015163ffffffff8116811461024557600080fd5b809150509295509295509295565b60805160a05160c05160e05161010051610f786102a4600039600061052101526000818161029701526104ef015260006104cc0152600061062401526000818160fc01526103520152610f786000f3fe6080604052600436106100e85760003560e01c806379ba50971161008a5780639eccacf6116100595780639eccacf614610268578063de3d9fb714610288578063e55ae4e8146102bb578063f2fde38b146102db57600080fd5b806379ba5097146101e35780638da5cb5b146101f85780638e7ea5b21461022a5780638ea981171461024857600080fd5b80632cfcc539116100c65780632cfcc5391461017857806337899770146101805780634585e33b146101955780636e04ff0d146101b557600080fd5b806309bc33a7146100ed578063115cbaf51461012f5780631fe543e314610156575b600080fd5b3480156100f957600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b6040519081526020015b60405180910390f35b34801561013b57600080fd5b50600554600160a01b900460ff166040516101269190610bdb565b34801561016257600080fd5b50610176610171366004610c03565b6102fb565b005b610176610350565b34801561018c57600080fd5b5060045461011c565b3480156101a157600080fd5b506101766101b0366004610c82565b61043d565b3480156101c157600080fd5b506101d56101d0366004610d0a565b61061c565b604051610126929190610e01565b3480156101ef57600080fd5b506101766106bc565b34801561020457600080fd5b506000546001600160a01b03165b6040516001600160a01b039091168152602001610126565b34801561023657600080fd5b506005546001600160a01b0316610212565b34801561025457600080fd5b50610176610263366004610e24565b610766565b34801561027457600080fd5b50600254610212906001600160a01b031681565b34801561029457600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061011c565b3480156102c757600080fd5b506102126102d6366004610e54565b610858565b3480156102e757600080fd5b506101766102f6366004610e24565b610888565b6002546001600160a01b031633146103405760025460405163073e64fd60e21b81523360048201526001600160a01b0390911660248201526044015b60405180910390fd5b61034b83838361089c565b505050565b7f000000000000000000000000000000000000000000000000000000000000000034101561039157604051633e48252960e01b815260040160405180910390fd5b6001600554600160a01b900460ff1660018111156103b1576103b1610bc5565b036103cf57604051636eac21ed60e01b815260040160405180910390fd5b6003805460018101825560009182527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180546001600160a01b0319163390811790915560405190917f634f3211e3a4e43fee5a21ad9f87ca153b300fc78b1c557a2057dbe9c63bcb4791a2565b60006104576040518060200160405280600081525061061c565b509050806104ad57600354600554479190600160a01b900460ff16600181111561048357610483610bc5565b60405163e059521b60e01b8152600481019390935260248301919091526044820152606401610337565b6005805460ff60a01b1916600160a01b1790556040805160c0810182527f000000000000000000000000000000000000000000000000000000000000000081527f000000000000000000000000000000000000000000000000000000000000000060208083019190915260018284018190527f000000000000000000000000000000000000000000000000000000000000000063ffffffff1660608401526080830152825190810190925260008083529160a082019061056c906109dc565b9052600254604051634d8e1c2f60e11b81529192506000916001600160a01b0390911690639b1c385e906105a4908590600401610e6d565b6020604051808303816000875af11580156105c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e79190610eca565b60405190915081907fcd6e45c8998311cab7e9d4385596cac867e20a0587194b954fa3a731c93ce78b90600090a25050505050565b6000606060007f0000000000000000000000000000000000000000000000000000000000000000600454426106519190610ee3565b10159050600080600554600160a01b900460ff16600181111561067657610676610bc5565b6003549114915047151590151583801561068d5750825b80156106965750815b801561069f5750805b604080516020810190915260008152909890975095505050505050565b6001546001600160a01b0316331461070f5760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b6044820152606401610337565b60008054336001600160a01b0319808316821784556001805490911690556040516001600160a01b0390921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6000546001600160a01b0316331480159061078c57506002546001600160a01b03163314155b156107dd57336107a46000546001600160a01b031690565b60025460405163061db9c160e01b81526001600160a01b0393841660048201529183166024830152919091166044820152606401610337565b6001600160a01b0381166108045760405163d92e233d60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd1a6a14209a385a964d036e404cb5cfb71f4000cdb03c9366292430787261be69060200160405180910390a150565b60006003828154811061086d5761086d610f0a565b6000918252602090912001546001600160a01b031692915050565b610890610a4d565b61089981610aa2565b50565b600354600090838383816108b2576108b2610f0a565b905060200201356108c39190610f20565b90506000600382815481106108da576108da610f0a565b600091825260208083209190910154600580546001600160a81b0319166001600160a01b039092169182179055604080519384529183019182905291519192506109279160039190610b4b565b50426004556040516001600160a01b038216907f5b690ec4a06fe979403046eaeea5b3ce38524683c3001f662c8b5a829632f7df90600090a26000816001600160a01b03164760405160006040518083038185875af1925050503d80600081146109ad576040519150601f19603f3d011682016040523d82523d6000602084013e6109b2565b606091505b50509050806109d45760405163ba31c4f360e01b815260040160405180910390fd5b505050505050565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa82604051602401610a1591511515815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915292915050565b6000546001600160a01b03163314610aa05760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b6044820152606401610337565b565b336001600160a01b03821603610afa5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610337565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b828054828255906000526020600020908101928215610ba0579160200282015b82811115610ba057825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190610b6b565b50610bac929150610bb0565b5090565b5b80821115610bac5760008155600101610bb1565b634e487b7160e01b600052602160045260246000fd5b6020810160028310610bfd57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600060408486031215610c1857600080fd5b83359250602084013567ffffffffffffffff80821115610c3757600080fd5b818601915086601f830112610c4b57600080fd5b813581811115610c5a57600080fd5b8760208260051b8501011115610c6f57600080fd5b6020830194508093505050509250925092565b60008060208385031215610c9557600080fd5b823567ffffffffffffffff80821115610cad57600080fd5b818501915085601f830112610cc157600080fd5b813581811115610cd057600080fd5b866020828501011115610ce257600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215610d1c57600080fd5b813567ffffffffffffffff80821115610d3457600080fd5b818401915084601f830112610d4857600080fd5b813581811115610d5a57610d5a610cf4565b604051601f8201601f19908116603f01168101908382118183101715610d8257610d82610cf4565b81604052828152876020848701011115610d9b57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000815180845260005b81811015610de157602081850181015186830182015201610dc5565b506000602082860101526020601f19601f83011685010191505092915050565b8215158152604060208201526000610e1c6040830184610dbb565b949350505050565b600060208284031215610e3657600080fd5b81356001600160a01b0381168114610e4d57600080fd5b9392505050565b600060208284031215610e6657600080fd5b5035919050565b60208152815160208201526020820151604082015261ffff60408301511660608201526000606083015163ffffffff80821660808501528060808601511660a0850152505060a083015160c080840152610e1c60e0840182610dbb565b600060208284031215610edc57600080fd5b5051919050565b81810381811115610f0457634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052603260045260246000fd5b600082610f3d57634e487b7160e01b600052601260045260246000fd5b50069056fea2646970667358221220a4afe871f76ddca81a8cbf9a0bd8e377a384331bec71475cc7e8acb9dc30d22264736f6c63430008130033000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000009ddfaca8183c41ad55329bdeed9f6a8d53168b1b787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677aecd7470feb71f72fb1da8ec5b8fd20338cfe001cdb2ae5c2d31b664df95dd551b000000000000000000000000000000000000000000000000000000000007a120", + "nonce": "0x14", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0x11da80e150b2e1be4fd45d0d360bf670f5db08c66adf01a82aab0291a33bf105", + "transactionType": "CALL", + "contractName": null, + "contractAddress": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "function": "addConsumer(uint256,address)", + "arguments": [ + "92929868081786283001051859072688436333659780913164620031290002461021448262939", + "0xD28eBaEbEF523db361C6Fe8266B3c6001454B4c3" + ], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "gas": "0x20182", + "value": "0x0", + "input": "0xbec4c08ccd7470feb71f72fb1da8ec5b8fd20338cfe001cdb2ae5c2d31b664df95dd551b000000000000000000000000d28ebaebef523db361c6fe8266b3c6001454b4c3", + "nonce": "0x15", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [ + { + "status": "0x1", + "cumulativeGasUsed": "0x113425e", + "logs": [], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "transactionHash": "0xd65a9daecfe5a146af295011d0c0967e419fd8a1726923c883678e84df392e6b", + "transactionIndex": "0xa6", + "blockHash": "0x1f125f6e61b0ae31adf8fdc2f64541422a2d0e1e84a4f2ede301bd19db14018d", + "blockNumber": "0x6e08e4", + "gasUsed": "0xf0efe", + "effectiveGasPrice": "0x7b7dc369", + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": null, + "contractAddress": "0xd28ebaebef523db361c6fe8266b3c6001454b4c3" + }, + { + "status": "0x1", + "cumulativeGasUsed": "0x114b624", + "logs": [ + { + "address": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "topics": [ + "0x1e980d04aa7648e205713e5e8ea3808672ac163d10936d36f91b2c88ac1575e1", + "0xcd7470feb71f72fb1da8ec5b8fd20338cfe001cdb2ae5c2d31b664df95dd551b" + ], + "data": "0x000000000000000000000000d28ebaebef523db361c6fe8266b3c6001454b4c3", + "blockHash": "0x1f125f6e61b0ae31adf8fdc2f64541422a2d0e1e84a4f2ede301bd19db14018d", + "blockNumber": "0x6e08e4", + "transactionHash": "0x11da80e150b2e1be4fd45d0d360bf670f5db08c66adf01a82aab0291a33bf105", + "transactionIndex": "0xa7", + "logIndex": "0xb0", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000080000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000008000000000000000000000000000000000000000000000000002000000000000000000000000000000000010000000000000000000000000000000004000000080000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "transactionHash": "0x11da80e150b2e1be4fd45d0d360bf670f5db08c66adf01a82aab0291a33bf105", + "transactionIndex": "0xa7", + "blockHash": "0x1f125f6e61b0ae31adf8fdc2f64541422a2d0e1e84a4f2ede301bd19db14018d", + "blockNumber": "0x6e08e4", + "gasUsed": "0x173c6", + "effectiveGasPrice": "0x7b7dc369", + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "contractAddress": null + } + ], + "libraries": [], + "pending": [], + "returns": {}, + "timestamp": 1733336585, + "chain": 11155111, + "commit": "9ed1329" +} \ No newline at end of file diff --git a/broadcast/DeployRaffle.s.sol/11155111/run-latest.json b/broadcast/DeployRaffle.s.sol/11155111/run-latest.json new file mode 100644 index 0000000..2b90da0 --- /dev/null +++ b/broadcast/DeployRaffle.s.sol/11155111/run-latest.json @@ -0,0 +1,106 @@ +{ + "transactions": [ + { + "hash": "0xd65a9daecfe5a146af295011d0c0967e419fd8a1726923c883678e84df392e6b", + "transactionType": "CREATE", + "contractName": "Raffle", + "contractAddress": "0xd28ebaebef523db361c6fe8266b3c6001454b4c3", + "function": null, + "arguments": [ + "10000000000000000", + "30", + "0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B", + "0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae", + "92929868081786283001051859072688436333659780913164620031290002461021448262939", + "500000" + ], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "gas": "0x13937d", + "value": "0x0", + "input": "0x61012060405234801561001157600080fd5b5060405161121c38038061121c833981016040819052610030916101dd565b8333806000816100875760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600080546001600160a01b0319166001600160a01b03848116919091179091558116156100b7576100b781610134565b5050506001600160a01b0381166100e15760405163d92e233d60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b039290921691909117905560809590955260a0939093524260045560c0525060e05263ffffffff16610100526005805460ff60a01b19169055610253565b336001600160a01b0382160361018c5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640161007e565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b60008060008060008060c087890312156101f657600080fd5b86516020880151604089015191975095506001600160a01b038116811461021c57600080fd5b80945050606087015192506080870151915060a087015163ffffffff8116811461024557600080fd5b809150509295509295509295565b60805160a05160c05160e05161010051610f786102a4600039600061052101526000818161029701526104ef015260006104cc0152600061062401526000818160fc01526103520152610f786000f3fe6080604052600436106100e85760003560e01c806379ba50971161008a5780639eccacf6116100595780639eccacf614610268578063de3d9fb714610288578063e55ae4e8146102bb578063f2fde38b146102db57600080fd5b806379ba5097146101e35780638da5cb5b146101f85780638e7ea5b21461022a5780638ea981171461024857600080fd5b80632cfcc539116100c65780632cfcc5391461017857806337899770146101805780634585e33b146101955780636e04ff0d146101b557600080fd5b806309bc33a7146100ed578063115cbaf51461012f5780631fe543e314610156575b600080fd5b3480156100f957600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b6040519081526020015b60405180910390f35b34801561013b57600080fd5b50600554600160a01b900460ff166040516101269190610bdb565b34801561016257600080fd5b50610176610171366004610c03565b6102fb565b005b610176610350565b34801561018c57600080fd5b5060045461011c565b3480156101a157600080fd5b506101766101b0366004610c82565b61043d565b3480156101c157600080fd5b506101d56101d0366004610d0a565b61061c565b604051610126929190610e01565b3480156101ef57600080fd5b506101766106bc565b34801561020457600080fd5b506000546001600160a01b03165b6040516001600160a01b039091168152602001610126565b34801561023657600080fd5b506005546001600160a01b0316610212565b34801561025457600080fd5b50610176610263366004610e24565b610766565b34801561027457600080fd5b50600254610212906001600160a01b031681565b34801561029457600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061011c565b3480156102c757600080fd5b506102126102d6366004610e54565b610858565b3480156102e757600080fd5b506101766102f6366004610e24565b610888565b6002546001600160a01b031633146103405760025460405163073e64fd60e21b81523360048201526001600160a01b0390911660248201526044015b60405180910390fd5b61034b83838361089c565b505050565b7f000000000000000000000000000000000000000000000000000000000000000034101561039157604051633e48252960e01b815260040160405180910390fd5b6001600554600160a01b900460ff1660018111156103b1576103b1610bc5565b036103cf57604051636eac21ed60e01b815260040160405180910390fd5b6003805460018101825560009182527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180546001600160a01b0319163390811790915560405190917f634f3211e3a4e43fee5a21ad9f87ca153b300fc78b1c557a2057dbe9c63bcb4791a2565b60006104576040518060200160405280600081525061061c565b509050806104ad57600354600554479190600160a01b900460ff16600181111561048357610483610bc5565b60405163e059521b60e01b8152600481019390935260248301919091526044820152606401610337565b6005805460ff60a01b1916600160a01b1790556040805160c0810182527f000000000000000000000000000000000000000000000000000000000000000081527f000000000000000000000000000000000000000000000000000000000000000060208083019190915260018284018190527f000000000000000000000000000000000000000000000000000000000000000063ffffffff1660608401526080830152825190810190925260008083529160a082019061056c906109dc565b9052600254604051634d8e1c2f60e11b81529192506000916001600160a01b0390911690639b1c385e906105a4908590600401610e6d565b6020604051808303816000875af11580156105c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e79190610eca565b60405190915081907fcd6e45c8998311cab7e9d4385596cac867e20a0587194b954fa3a731c93ce78b90600090a25050505050565b6000606060007f0000000000000000000000000000000000000000000000000000000000000000600454426106519190610ee3565b10159050600080600554600160a01b900460ff16600181111561067657610676610bc5565b6003549114915047151590151583801561068d5750825b80156106965750815b801561069f5750805b604080516020810190915260008152909890975095505050505050565b6001546001600160a01b0316331461070f5760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b6044820152606401610337565b60008054336001600160a01b0319808316821784556001805490911690556040516001600160a01b0390921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6000546001600160a01b0316331480159061078c57506002546001600160a01b03163314155b156107dd57336107a46000546001600160a01b031690565b60025460405163061db9c160e01b81526001600160a01b0393841660048201529183166024830152919091166044820152606401610337565b6001600160a01b0381166108045760405163d92e233d60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd1a6a14209a385a964d036e404cb5cfb71f4000cdb03c9366292430787261be69060200160405180910390a150565b60006003828154811061086d5761086d610f0a565b6000918252602090912001546001600160a01b031692915050565b610890610a4d565b61089981610aa2565b50565b600354600090838383816108b2576108b2610f0a565b905060200201356108c39190610f20565b90506000600382815481106108da576108da610f0a565b600091825260208083209190910154600580546001600160a81b0319166001600160a01b039092169182179055604080519384529183019182905291519192506109279160039190610b4b565b50426004556040516001600160a01b038216907f5b690ec4a06fe979403046eaeea5b3ce38524683c3001f662c8b5a829632f7df90600090a26000816001600160a01b03164760405160006040518083038185875af1925050503d80600081146109ad576040519150601f19603f3d011682016040523d82523d6000602084013e6109b2565b606091505b50509050806109d45760405163ba31c4f360e01b815260040160405180910390fd5b505050505050565b60607f92fd13387c7fe7befbc38d303d6468778fb9731bc4583f17d92989c6fcfdeaaa82604051602401610a1591511515815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915292915050565b6000546001600160a01b03163314610aa05760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b6044820152606401610337565b565b336001600160a01b03821603610afa5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610337565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b828054828255906000526020600020908101928215610ba0579160200282015b82811115610ba057825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190610b6b565b50610bac929150610bb0565b5090565b5b80821115610bac5760008155600101610bb1565b634e487b7160e01b600052602160045260246000fd5b6020810160028310610bfd57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600060408486031215610c1857600080fd5b83359250602084013567ffffffffffffffff80821115610c3757600080fd5b818601915086601f830112610c4b57600080fd5b813581811115610c5a57600080fd5b8760208260051b8501011115610c6f57600080fd5b6020830194508093505050509250925092565b60008060208385031215610c9557600080fd5b823567ffffffffffffffff80821115610cad57600080fd5b818501915085601f830112610cc157600080fd5b813581811115610cd057600080fd5b866020828501011115610ce257600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215610d1c57600080fd5b813567ffffffffffffffff80821115610d3457600080fd5b818401915084601f830112610d4857600080fd5b813581811115610d5a57610d5a610cf4565b604051601f8201601f19908116603f01168101908382118183101715610d8257610d82610cf4565b81604052828152876020848701011115610d9b57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000815180845260005b81811015610de157602081850181015186830182015201610dc5565b506000602082860101526020601f19601f83011685010191505092915050565b8215158152604060208201526000610e1c6040830184610dbb565b949350505050565b600060208284031215610e3657600080fd5b81356001600160a01b0381168114610e4d57600080fd5b9392505050565b600060208284031215610e6657600080fd5b5035919050565b60208152815160208201526020820151604082015261ffff60408301511660608201526000606083015163ffffffff80821660808501528060808601511660a0850152505060a083015160c080840152610e1c60e0840182610dbb565b600060208284031215610edc57600080fd5b5051919050565b81810381811115610f0457634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052603260045260246000fd5b600082610f3d57634e487b7160e01b600052601260045260246000fd5b50069056fea2646970667358221220a4afe871f76ddca81a8cbf9a0bd8e377a384331bec71475cc7e8acb9dc30d22264736f6c63430008130033000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000009ddfaca8183c41ad55329bdeed9f6a8d53168b1b787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677aecd7470feb71f72fb1da8ec5b8fd20338cfe001cdb2ae5c2d31b664df95dd551b000000000000000000000000000000000000000000000000000000000007a120", + "nonce": "0x14", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0x11da80e150b2e1be4fd45d0d360bf670f5db08c66adf01a82aab0291a33bf105", + "transactionType": "CALL", + "contractName": null, + "contractAddress": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "function": "addConsumer(uint256,address)", + "arguments": [ + "92929868081786283001051859072688436333659780913164620031290002461021448262939", + "0xD28eBaEbEF523db361C6Fe8266B3c6001454B4c3" + ], + "transaction": { + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "gas": "0x20182", + "value": "0x0", + "input": "0xbec4c08ccd7470feb71f72fb1da8ec5b8fd20338cfe001cdb2ae5c2d31b664df95dd551b000000000000000000000000d28ebaebef523db361c6fe8266b3c6001454b4c3", + "nonce": "0x15", + "chainId": "0xaa36a7" + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [ + { + "status": "0x1", + "cumulativeGasUsed": "0x113425e", + "logs": [], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "transactionHash": "0xd65a9daecfe5a146af295011d0c0967e419fd8a1726923c883678e84df392e6b", + "transactionIndex": "0xa6", + "blockHash": "0x1f125f6e61b0ae31adf8fdc2f64541422a2d0e1e84a4f2ede301bd19db14018d", + "blockNumber": "0x6e08e4", + "gasUsed": "0xf0efe", + "effectiveGasPrice": "0x7b7dc369", + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": null, + "contractAddress": "0xd28ebaebef523db361c6fe8266b3c6001454b4c3" + }, + { + "status": "0x1", + "cumulativeGasUsed": "0x114b624", + "logs": [ + { + "address": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "topics": [ + "0x1e980d04aa7648e205713e5e8ea3808672ac163d10936d36f91b2c88ac1575e1", + "0xcd7470feb71f72fb1da8ec5b8fd20338cfe001cdb2ae5c2d31b664df95dd551b" + ], + "data": "0x000000000000000000000000d28ebaebef523db361c6fe8266b3c6001454b4c3", + "blockHash": "0x1f125f6e61b0ae31adf8fdc2f64541422a2d0e1e84a4f2ede301bd19db14018d", + "blockNumber": "0x6e08e4", + "transactionHash": "0x11da80e150b2e1be4fd45d0d360bf670f5db08c66adf01a82aab0291a33bf105", + "transactionIndex": "0xa7", + "logIndex": "0xb0", + "removed": false + } + ], + "logsBloom": "0x00000000000000000000000000000080000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000008000000000000000000000000000000000000000000000000002000000000000000000000000000000000010000000000000000000000000000000004000000080000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "transactionHash": "0x11da80e150b2e1be4fd45d0d360bf670f5db08c66adf01a82aab0291a33bf105", + "transactionIndex": "0xa7", + "blockHash": "0x1f125f6e61b0ae31adf8fdc2f64541422a2d0e1e84a4f2ede301bd19db14018d", + "blockNumber": "0x6e08e4", + "gasUsed": "0x173c6", + "effectiveGasPrice": "0x7b7dc369", + "from": "0x95fd8bdd071f25a1bae9086b6f95eeda9c3ebb78", + "to": "0x9ddfaca8183c41ad55329bdeed9f6a8d53168b1b", + "contractAddress": null + } + ], + "libraries": [], + "pending": [], + "returns": {}, + "timestamp": 1733336585, + "chain": 11155111, + "commit": "9ed1329" +} \ No newline at end of file diff --git a/foundry.toml b/foundry.toml new file mode 100644 index 0000000..2080306 --- /dev/null +++ b/foundry.toml @@ -0,0 +1,15 @@ +[profile.default] +src = "src" +out = "out" +libs = ["lib"] +remappings = [ + '@chainlink/contracts/=lib/chainlink-brownie-contracts/contracts/', + '@solmate=lib/solmate/src', +] +fs_permissions = [ + { access = "read", path = "./broadcast" }, + { access = "read", path = "./reports" }, +] +[fuzz] +runs = 256 +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/lib/chainlink-brownie-contracts b/lib/chainlink-brownie-contracts new file mode 160000 index 0000000..12393bd --- /dev/null +++ b/lib/chainlink-brownie-contracts @@ -0,0 +1 @@ +Subproject commit 12393bd475bd60c222ff12e75c0f68effe1bbaaf diff --git a/lib/forge-std b/lib/forge-std new file mode 160000 index 0000000..1eea5ba --- /dev/null +++ b/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 1eea5bae12ae557d589f9f0f0edae2faa47cb262 diff --git a/lib/foundry-devops b/lib/foundry-devops new file mode 160000 index 0000000..47393d0 --- /dev/null +++ b/lib/foundry-devops @@ -0,0 +1 @@ +Subproject commit 47393d0a85ad9f6aa127ba2aed2bf9a7a7488bcf diff --git a/lib/solmate b/lib/solmate new file mode 160000 index 0000000..a9e3ea2 --- /dev/null +++ b/lib/solmate @@ -0,0 +1 @@ +Subproject commit a9e3ea26a2dc73bfa87f0cb189687d029028e0c5 diff --git a/script/DeployRaffle.s.sol b/script/DeployRaffle.s.sol new file mode 100644 index 0000000..432dfac --- /dev/null +++ b/script/DeployRaffle.s.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.19; + +import {Script} from "forge-std/Script.sol"; +import {Raffle} from "src/Raffle.sol"; +import {HelperConfig} from "script/HelperConfig.s.sol"; +import {CreateSubscription, FundSubscription, AddConsumer} from "script/Interactions.s.sol"; + +contract DeployRaffle is Script { + function run() public { + deployRaffle(); + } + + function deployRaffle() public returns (Raffle, HelperConfig) { + HelperConfig helperConfig = new HelperConfig(); + HelperConfig.NetworkConfig memory config = helperConfig.getConfig(); + if (config.subscriptionId == 0) { + CreateSubscription createSubscription = new CreateSubscription(); + (config.subscriptionId, config.vrfCoordinator) = createSubscription //110146416707791746939207738026704245955047294542294573815139559467961003768950 , 0x34A1D3fff3958843C43aD80F30b94c5106 + .createSubscription(config.vrfCoordinator, config.account); + FundSubscription fundSubscription = new FundSubscription(); + fundSubscription.fundSubscription( + config.vrfCoordinator, + config.subscriptionId, + config.link, + config.account + ); + } + vm.startBroadcast(config.account); + Raffle raffle = new Raffle( + config.entranceFee, + config.interval, + config.vrfCoordinator, + config.gasLane, + config.subscriptionId, + config.callbackGasLimit + ); + vm.stopBroadcast(); + AddConsumer addConsumer = new AddConsumer(); + addConsumer.addConsumer( + address(raffle), + config.vrfCoordinator, + config.subscriptionId, + config.account + ); + helperConfig.setLocalNetworkConfig(config); + return (raffle, helperConfig); + } +} diff --git a/script/HelperConfig.s.sol b/script/HelperConfig.s.sol new file mode 100644 index 0000000..ad724ff --- /dev/null +++ b/script/HelperConfig.s.sol @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.19; + +import {Script, console2} from "forge-std/Script.sol"; +import {VRFCoordinatorV2_5Mock} from "@chainlink/contracts/src/v0.8/vrf/mocks/VRFCoordinatorV2_5Mock.sol"; +import {LinkToken} from "test/unit/mocks/LinkToken.sol"; + +abstract contract CodeConstants { + /*VRF Mock Values*/ + uint96 public MOCK_BASE_FEE = 0.25 ether; + uint96 public MOCK_GAS_PRICE = 1e9; + //Link/ETH price + int256 public MOCK_WEI_PER_UNIT_LINK = 4e15; + + uint256 public constant ETH_SEPOLIA_CHAIN_ID = 11155111; + uint256 public constant LOCAL_CHAIN_ID = 31337; +} + +contract HelperConfig is CodeConstants, Script { + error HelperConfig_InvalidChainId(); + struct NetworkConfig { + uint256 entranceFee; + uint256 interval; + address vrfCoordinator; + bytes32 gasLane; + uint32 callbackGasLimit; + uint256 subscriptionId; + address link; + address account; + } + + NetworkConfig public localNetworkConfig; + mapping(uint256 chainId => NetworkConfig) public networkConfigs; + + constructor() { + networkConfigs[ETH_SEPOLIA_CHAIN_ID] = getSepoliaEthConfig(); + } + + function getConfigByChainId( + uint256 chainId + ) public returns (NetworkConfig memory) { + if (networkConfigs[chainId].vrfCoordinator != address(0)) { + return networkConfigs[chainId]; + } else if (chainId == LOCAL_CHAIN_ID) { + return getOrCreateAnvilConfig(); + } else { + revert HelperConfig_InvalidChainId(); + } + } + + function getSepoliaEthConfig() public pure returns (NetworkConfig memory) { + return + NetworkConfig({ + entranceFee: 0.01 ether, + interval: 30, //30 seconds + vrfCoordinator: 0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B, + gasLane: 0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae, + callbackGasLimit: 500000, + subscriptionId: 92929868081786283001051859072688436333659780913164620031290002461021448262939, + link: 0x779877A7B0D9E8603169DdbD7836e478b4624789, + account: 0x95fd8bdd071f25a1baE9086b6f95Eeda9c3EBB78 + }); + } + + function getConfig() public returns (NetworkConfig memory) { + return getConfigByChainId(block.chainid); + } + + function getOrCreateAnvilConfig() public returns (NetworkConfig memory) { + if (localNetworkConfig.vrfCoordinator != address(0)) { + return localNetworkConfig; + } + //Deploy mocks + vm.startBroadcast(); + VRFCoordinatorV2_5Mock vrfCoordinator = new VRFCoordinatorV2_5Mock( + MOCK_BASE_FEE, + MOCK_GAS_PRICE, + MOCK_WEI_PER_UNIT_LINK + ); + LinkToken link = new LinkToken(); + vm.stopBroadcast(); + localNetworkConfig = NetworkConfig({ + entranceFee: 0.01 ether, + interval: 30, //30 seconds + vrfCoordinator: address(vrfCoordinator), + gasLane: 0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae, + callbackGasLimit: 500000, + subscriptionId: 0, + link: address(link), + account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + }); + return localNetworkConfig; + } + + function setLocalNetworkConfig(NetworkConfig memory config) public { + localNetworkConfig = config; + } +} diff --git a/script/Interactions.s.sol b/script/Interactions.s.sol new file mode 100644 index 0000000..62857ec --- /dev/null +++ b/script/Interactions.s.sol @@ -0,0 +1,125 @@ +//SPDX License Identifier: MIT +pragma solidity ^0.8.19; +import {Script, console2} from "forge-std/Script.sol"; +import {HelperConfig, CodeConstants} from "script/HelperConfig.s.sol"; +import {VRFCoordinatorV2_5Mock} from "@chainlink/contracts/src/v0.8/vrf/mocks/VRFCoordinatorV2_5Mock.sol"; +import {LinkToken} from "test/unit/mocks/LinkToken.sol"; +import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol"; + +contract CreateSubscription is Script { + function createSubscriptionUsingConfig() public returns (uint256, address) { + // Create a new subscription + HelperConfig helperConfig = new HelperConfig(); + address vrfCoordinator = helperConfig.getConfig().vrfCoordinator; + address account = helperConfig.getConfig().account; + (uint256 subId, ) = createSubscription(vrfCoordinator, account); + return (subId, vrfCoordinator); + } + + function createSubscription( + address vrfCoordinator, + address account + ) public returns (uint256, address) { + console2.log("Creating subscription on chain Id: ", block.chainid); + vm.startBroadcast(account); + uint256 subId = VRFCoordinatorV2_5Mock(vrfCoordinator) + .createSubscription(); + vm.stopBroadcast(); + console2.log("Your subscription Id is: ", subId); + console2.log( + "Please update your subscription Id in the HelperConfig contract" + ); + return (subId, vrfCoordinator); + } + + function run() public returns (uint256, address) { + return createSubscriptionUsingConfig(); + } +} + +contract FundSubscription is Script, CodeConstants { + uint256 public constant FUND_AMOUNT = 3 ether; + + function fundSubscriptionUsingConfig() public { + HelperConfig helperConfig = new HelperConfig(); + address vrfCoordinator = helperConfig.getConfig().vrfCoordinator; + uint256 subscriptionId = helperConfig.getConfig().subscriptionId; + address linkToken = helperConfig.getConfig().link; + address account = helperConfig.getConfig().account; + fundSubscription(vrfCoordinator, subscriptionId, linkToken, account); + } + + function fundSubscription( + address vrfCoordinator, + uint256 subscriptionId, + address linkToken, + address account + ) public { + console2.log("Funding subscription", subscriptionId); + console2.log("Using vrfCoordinator: ", vrfCoordinator); + console2.log("On chainID: ", block.chainid); + if (block.chainid == LOCAL_CHAIN_ID) { + vm.startBroadcast(); + VRFCoordinatorV2_5Mock(vrfCoordinator).fundSubscription( + subscriptionId, + FUND_AMOUNT * 100 + ); + vm.stopBroadcast(); + } else { + vm.startBroadcast(account); + require( + LinkToken(linkToken).balanceOf(account) >= FUND_AMOUNT, + "Insufficient LINK balance" + ); + LinkToken(linkToken).transferAndCall( + vrfCoordinator, + FUND_AMOUNT, + abi.encode(subscriptionId) + ); + vm.stopBroadcast(); + } + } + + function run() public { + fundSubscriptionUsingConfig(); + } + + function getFundAmount() public pure returns (uint256) { + return FUND_AMOUNT * 100; + } +} + +contract AddConsumer is Script { + function addConsumerUsingConfig(address mostRecentlyDeployed) public { + HelperConfig helperConfig = new HelperConfig(); + uint256 subId = helperConfig.getConfig().subscriptionId; + address vrfCoordinator = helperConfig.getConfig().vrfCoordinator; + address account = helperConfig.getConfig().account; + addConsumer(mostRecentlyDeployed, vrfCoordinator, subId, account); + } + + function addConsumer( + address contractToAddtoVrf, + address vrfCoordinator, + uint256 subId, + address account + ) public { + console2.log("Adding consumer to VRF Coordinator: ", vrfCoordinator); + console2.log("Using subscription Id: ", subId); + console2.log("On chainID: ", block.chainid); + vm.startBroadcast(account); + VRFCoordinatorV2_5Mock(vrfCoordinator).addConsumer( + subId, + contractToAddtoVrf + ); + vm.stopBroadcast(); + } + + function run() external { + address mostRecentlyDeployed = DevOpsTools.get_most_recent_deployment( + "Raffle", + block.chainid + ); + addConsumerUsingConfig(mostRecentlyDeployed); + } +} diff --git a/src/Raffle.sol b/src/Raffle.sol new file mode 100644 index 0000000..2a12b71 --- /dev/null +++ b/src/Raffle.sol @@ -0,0 +1,173 @@ +//SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import {VRFConsumerBaseV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol"; +import {VRFV2PlusClient} from "@chainlink/contracts/src/v0.8/vrf/dev/libraries/VRFV2PlusClient.sol"; +import {console} from "forge-std/console.sol"; + +/** + * @title Raffle contract + * @author Chitoiu Andrei-Victor + * @notice This contract is used to create a raffle + * @dev Implements Chainlink VRFv2.5 + */ + +contract Raffle is VRFConsumerBaseV2Plus { + //** Errors */ + error Raffle_SendMoreToEnterRaffle(); + error Raffle_TransferFailed(); + error Raffle_RaffleNotOpen(); + error Raffle_UpkeepNotNeeded( + uint256 balance, + uint256 playersLength, + uint256 state + ); + //*Type declarations */ + enum RaffleState { + OPEN, //0 + CALCULATING_WINNER //1 + } + //** State variables */ + + uint256 private immutable i_entranceFee; + address payable[] private s_players; + //@dev the duration of each lottery in seconds + uint256 immutable i_interval; + uint256 private s_lastTimestamp; + bytes32 private immutable i_keyHash; + uint256 private immutable i_subscriptionId; + uint16 private constant REQUEST_CONFIRMATONS = 1; + uint32 private immutable i_callbackGasLimit; + uint32 private constant NUM_WORDS = 1; + address private s_recentWinner; + RaffleState private s_raffleState; + //*Events */ + + event RaffleEntered(address indexed player); + event WinnerPicked(address indexed winner); + event RequestedRaffleWinner(uint256 indexed requestId); + + constructor( + uint256 entranceFee, + uint256 interval, + address vrfCoordinator, + bytes32 gasLane, + uint256 subscriptionId, + uint32 callbackGasLimit + ) VRFConsumerBaseV2Plus(vrfCoordinator) { + i_entranceFee = entranceFee; + i_interval = interval; + s_lastTimestamp = block.timestamp; + i_keyHash = gasLane; + i_subscriptionId = subscriptionId; + i_callbackGasLimit = callbackGasLimit; + s_raffleState = RaffleState.OPEN; + } + + function enterRaffle() external payable { + //require(msg.value >= i_entranceFee, "Not enoungh ETH sent !"); -not gas efficient + if (msg.value < i_entranceFee) { + revert Raffle_SendMoreToEnterRaffle(); + } + if (s_raffleState == RaffleState.CALCULATING_WINNER) { + revert Raffle_RaffleNotOpen(); + } + s_players.push(payable(msg.sender)); + emit RaffleEntered(msg.sender); + } + + /** + * @dev This is the funtion that the Chainlink nodes will call to see + * if the lottery is ready to have a winner picked. + * The following should be true in order for upkeepNeeded to be true: + * 1. The time interval has passed between raffle runs. + * 2. The lottery is open. + * 3. The contract hash ETH. + * 4. Implicitly, your subscription is funded. + * @param - ignored + * @return upkeepNeeded - a boolean value that indicates if the contract needs upkeep + * @return - ignored + */ + function checkUpkeep( + bytes memory /*checkData*/ + ) public view returns (bool upkeepNeeded, bytes memory /*performData*/) { + bool timeHasPassed = block.timestamp - s_lastTimestamp >= i_interval; + bool isOpen = s_raffleState == RaffleState.OPEN; + bool hasBalance = address(this).balance > 0; + bool hasPlayers = s_players.length > 0; + upkeepNeeded = timeHasPassed && isOpen && hasBalance && hasPlayers; + return (upkeepNeeded, ""); + } + + function performUpkeep(bytes calldata /* performData */) external { + (bool upkeepNeeded, ) = checkUpkeep(""); + if (!upkeepNeeded) { + revert Raffle_UpkeepNotNeeded( + address(this).balance, + s_players.length, + uint256(s_raffleState) + ); + } + s_raffleState = RaffleState.CALCULATING_WINNER; + VRFV2PlusClient.RandomWordsRequest memory request = VRFV2PlusClient + .RandomWordsRequest({ + keyHash: i_keyHash, + subId: i_subscriptionId, + requestConfirmations: REQUEST_CONFIRMATONS, + callbackGasLimit: i_callbackGasLimit, + numWords: NUM_WORDS, + extraArgs: VRFV2PlusClient._argsToBytes( + VRFV2PlusClient.ExtraArgsV1({nativePayment: false}) + ) + }); + uint256 requestId = s_vrfCoordinator.requestRandomWords(request); + emit RequestedRaffleWinner(requestId); + } + + function fulfillRandomWords( + uint256 /*requestId*/, + uint256[] calldata randomWords + ) internal override { + //Checks + + //Effects + uint256 indexOfWinner = randomWords[0] % s_players.length; + address payable recentWinner = s_players[indexOfWinner]; + s_recentWinner = recentWinner; + s_raffleState = RaffleState.OPEN; + s_players = new address payable[](0); + s_lastTimestamp = block.timestamp; + emit WinnerPicked(recentWinner); + //Interactions + (bool succes, ) = recentWinner.call{value: address(this).balance}(""); + if (!succes) { + revert Raffle_TransferFailed(); + } + } + + //** Getter functions */ + function getEntranceFee() external view returns (uint256) { + return i_entranceFee; + } + + function getRaffleState() external view returns (RaffleState) { + return s_raffleState; + } + + function getPlayer(uint256 indexOfPlayer) external view returns (address) { + return s_players[indexOfPlayer]; + } + + function getLastTimestamp() external view returns (uint256) { + return s_lastTimestamp; + } + + function getWinner() external view returns (address) { + return s_recentWinner; + } + + function getSubscriptionId() external view returns (uint256) { + return i_subscriptionId; + } +} diff --git a/test/unit/RaffleTest.t.sol b/test/unit/RaffleTest.t.sol new file mode 100644 index 0000000..cd417bb --- /dev/null +++ b/test/unit/RaffleTest.t.sol @@ -0,0 +1,207 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; +import {Test} from "forge-std/Test.sol"; +import {DeployRaffle} from "script/DeployRaffle.s.sol"; +import {Raffle} from "src/Raffle.sol"; +import {HelperConfig} from "script/HelperConfig.s.sol"; +import {Vm} from "forge-std/Vm.sol"; +import {VRFCoordinatorV2_5Mock} from "@chainlink/contracts/src/v0.8/vrf/mocks/VRFCoordinatorV2_5Mock.sol"; +import {CodeConstants} from "script/HelperConfig.s.sol"; + +contract RaffleTest is Test, CodeConstants { + event RaffleEntered(address indexed player); + event WinnerPicked(address indexed winner); + Raffle public raffle; + HelperConfig public helperConfig; + uint256 entranceFee; + uint256 interval; + address vrfCoordinator; + bytes32 gasLane; + uint256 subscriptionId; + uint32 callbackGasLimit; + address public PLAYER = makeAddr("player"); + uint256 public constant STARTING_PLAYER_BALANCE = 10 ether; + + function setUp() external { + DeployRaffle deployer = new DeployRaffle(); + (raffle, helperConfig) = deployer.deployRaffle(); + HelperConfig.NetworkConfig memory config = helperConfig.getConfig(); + entranceFee = config.entranceFee; + interval = config.interval; + vrfCoordinator = config.vrfCoordinator; + gasLane = config.gasLane; + subscriptionId = config.subscriptionId; + callbackGasLimit = config.callbackGasLimit; + vm.deal(PLAYER, STARTING_PLAYER_BALANCE); + } + + function testRaffleInititializesInOpenState() public view { + assert(raffle.getRaffleState() == Raffle.RaffleState.OPEN); + } + + function testRaffleRevertsIfNotEnoughFunds() public { + vm.prank(PLAYER); + vm.expectRevert(Raffle.Raffle_SendMoreToEnterRaffle.selector); + raffle.enterRaffle(); + } + + function testRaffleRecordsPlayersWhenTheyEnter() public { + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + address playerRecorded = raffle.getPlayer(0); + assert(playerRecorded == PLAYER); + } + + function testEnteringRaffleEmitsEvent() public { + vm.prank(PLAYER); + + vm.expectEmit(true, false, false, false, address(raffle)); + emit RaffleEntered(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + } + + function testDontAllowPlayersToEnterWhileRaffleIsCalculating() public { + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + vm.warp(block.timestamp + interval + 1); + vm.roll(block.number + 1); + raffle.performUpkeep(""); + vm.expectRevert(Raffle.Raffle_RaffleNotOpen.selector); + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + } + + function testCheckUpkeepReturnsFalseIfItHasNoBalance() public { + vm.warp(block.timestamp + interval + 1); + vm.roll(block.number + 1); + + (bool upkeepNeeded, ) = raffle.checkUpkeep(""); + + assert(upkeepNeeded == false); + } + + function testCheckUpkeepReturnsFalseIfRaffleIsntOpen() public { + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + vm.warp(block.timestamp + interval + 1); + vm.roll(block.number + 1); + raffle.performUpkeep(""); + Raffle.RaffleState raffleState = raffle.getRaffleState(); + (bool upkeepNeeded, ) = raffle.checkUpkeep(""); + assert(uint256(raffleState) == 1); + assert(upkeepNeeded == false); + } + + function testCheckUpkeepReturnsFalseIfEnoughTimeHasntPassed() public { + vm.warp(block.timestamp + interval - 1); + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + (bool upkeepNeeded, ) = raffle.checkUpkeep(""); + assert(upkeepNeeded == false); + } + + function testCheckUpkeepReturnsTrueWhenParametrsAreGood() public { + vm.warp(block.timestamp + interval + 1); + vm.roll(block.number + 1); + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + (bool upkeepNeeded, ) = raffle.checkUpkeep(""); + assert(upkeepNeeded == true); + } + + function testPerformUpkeepCanOnlyRunIfCheckUpkeepIsTrue() public { + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + vm.warp(block.timestamp + interval + 1); + vm.roll(block.number + 1); + raffle.performUpkeep(""); + } + + function testCheckPerformUpkeepRevertsIfUpkeepIsFalse() public { + vm.expectRevert( + abi.encodeWithSelector( + Raffle.Raffle_UpkeepNotNeeded.selector, + 0, + 0, + 0 + ) + ); + raffle.performUpkeep(""); + } + + modifier raffleEntered() { + vm.prank(PLAYER); + raffle.enterRaffle{value: entranceFee}(); + vm.warp(block.timestamp + interval + 1); + vm.roll(block.number + 1); + _; + } + + function testPerformUpkeepUpdatesRaffleStateAndEmitsRequestId() + public + raffleEntered + { + vm.recordLogs(); + raffle.performUpkeep(""); + Vm.Log[] memory entries = vm.getRecordedLogs(); + bytes32 requestId = entries[1].topics[1]; + Raffle.RaffleState raffleState = raffle.getRaffleState(); + assert(uint256(requestId) > 0); + assert(uint256(raffleState) == 1); + } + + modifier skipFork() { + if (block.chainid != LOCAL_CHAIN_ID) { + return; + } + _; + } + + function testFulfillRandomWordsCanOnlyBeCalledAfterPerformUpkeep( + uint256 randomRequestId + ) public raffleEntered skipFork { + vm.expectRevert(VRFCoordinatorV2_5Mock.InvalidRequest.selector); + VRFCoordinatorV2_5Mock(vrfCoordinator).fulfillRandomWords( + randomRequestId, + address(raffle) + ); + } + + function testFulfillRandomWordsPicksAWinnerResetsAndSendsMoney() + public + raffleEntered + skipFork + { + uint256 additionalEntrants = 3; //4 people total enter + uint256 startingIndex = 1; + address expectedWinner = address(1); + for ( + uint256 i = startingIndex; + i < startingIndex + additionalEntrants; + i++ + ) { + address newPlayer = address(uint160(i)); + hoax(newPlayer, 1 ether); + raffle.enterRaffle{value: entranceFee}(); + } + uint256 startingTimestamp = raffle.getLastTimestamp(); + uint256 winnerStartingBalance = expectedWinner.balance; + vm.recordLogs(); + raffle.performUpkeep(""); + Vm.Log[] memory entries = vm.getRecordedLogs(); + bytes32 requestId = entries[1].topics[1]; + VRFCoordinatorV2_5Mock(vrfCoordinator).fulfillRandomWords( + uint256(requestId), + address(raffle) + ); + address recentWinner = raffle.getWinner(); + Raffle.RaffleState raffleState = raffle.getRaffleState(); + uint256 winnerBalance = recentWinner.balance; + uint256 endingTimestamp = raffle.getLastTimestamp(); + uint256 prize = entranceFee * (additionalEntrants + 1); + assert(recentWinner == expectedWinner); + assert(uint256(raffleState) == 0); + assert(winnerBalance == winnerStartingBalance + prize); + assert(endingTimestamp > startingTimestamp); + } +} diff --git a/test/unit/integration/Interactions.t.sol b/test/unit/integration/Interactions.t.sol new file mode 100644 index 0000000..5153096 --- /dev/null +++ b/test/unit/integration/Interactions.t.sol @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.19; +import {Test} from "forge-std/Test.sol"; +import {Raffle} from "src/Raffle.sol"; +import {DeployRaffle} from "script/DeployRaffle.s.sol"; +import {CreateSubscription, FundSubscription, AddConsumer} from "script/Interactions.s.sol"; +import {HelperConfig, CodeConstants} from "script/HelperConfig.s.sol"; +import {VRFCoordinatorV2_5Mock} from "@chainlink/contracts/src/v0.8/vrf/mocks/VRFCoordinatorV2_5Mock.sol"; +import {console2} from "forge-std/Script.sol"; + +contract Interactions is Test { + Raffle raffle; + address USER = makeAddr("USER"); + uint256 constant STARTING_BALANCE = 10 ether; + HelperConfig helperConfig; + uint256 subId; + address vrfCoordinator; + uint96 initialBalance; + + function setUp() external { + DeployRaffle deployRaffle = new DeployRaffle(); + (raffle, helperConfig) = deployRaffle.deployRaffle(); + vrfCoordinator = helperConfig.getConfig().vrfCoordinator; + subId = helperConfig.getConfig().subscriptionId; + initialBalance = VRFCoordinatorV2_5Mock(vrfCoordinator).s_totalBalance(); + vm.deal(USER, STARTING_BALANCE); + } + + function testUserCanFundSubscriptionInteractions() external { + FundSubscription fundSubscription = new FundSubscription(); + fundSubscription.fundSubscription( + vrfCoordinator, + subId, + helperConfig.getConfig().link, + helperConfig.getConfig().account + ); + uint96 finalBalance = VRFCoordinatorV2_5Mock(vrfCoordinator) + .s_totalBalance(); + assertEq( + finalBalance, + initialBalance + fundSubscription.getFundAmount() + ); + } +} diff --git a/test/unit/mocks/LinkToken.sol b/test/unit/mocks/LinkToken.sol new file mode 100644 index 0000000..fd04e98 --- /dev/null +++ b/test/unit/mocks/LinkToken.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: MIT +// @dev This contract has been adapted to fit with foundry +pragma solidity ^0.8.0; + +import {ERC20} from "@solmate/tokens/ERC20.sol"; + +interface ERC677Receiver { + function onTokenTransfer( + address _sender, + uint256 _value, + bytes memory _data + ) external; +} + +contract LinkToken is ERC20 { + uint256 constant INITIAL_SUPPLY = 1000000000000000000000000; + uint8 constant DECIMALS = 18; + + constructor() ERC20("LinkToken", "LINK", DECIMALS) { + _mint(msg.sender, INITIAL_SUPPLY); + } + + function mint(address to, uint256 value) public { + _mint(to, value); + } + + event Transfer( + address indexed from, + address indexed to, + uint256 value, + bytes data + ); + + /** + * @dev transfer token to a contract address with additional data if the recipient is a contact. + * @param _to The address to transfer to. + * @param _value The amount to be transferred. + * @param _data The extra data to be passed to the receiving contract. + */ + function transferAndCall( + address _to, + uint256 _value, + bytes memory _data + ) public virtual returns (bool success) { + super.transfer(_to, _value); + // emit Transfer(msg.sender, _to, _value, _data); + emit Transfer(msg.sender, _to, _value, _data); + if (isContract(_to)) { + contractFallback(_to, _value, _data); + } + return true; + } + + // PRIVATE + + function contractFallback( + address _to, + uint256 _value, + bytes memory _data + ) private { + ERC677Receiver receiver = ERC677Receiver(_to); + receiver.onTokenTransfer(msg.sender, _value, _data); + } + + function isContract(address _addr) private view returns (bool hasCode) { + uint256 length; + assembly { + length := extcodesize(_addr) + } + return length > 0; + } +}