-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(contract): Add deploy scripts; update README
- Loading branch information
Showing
9 changed files
with
275 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Galxe.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Galxe Raffle 🎲 | ||
|
||
A raffle system powered by SP1 zero-knowledge proofs and Galxe Raffle smart contracts. | ||
|
||
## 🏗️ Project Structure | ||
|
||
- `zk/`: Contains the SP1 RISC-V program and proof generation scripts. | ||
- `contracts/`: Contains the Galxe Raffle smart contracts. | ||
|
||
## 🔑 ZK | ||
|
||
For more information, see the [zk/README.md](zk/README.md). | ||
|
||
## 📄 Contracts | ||
|
||
For more information, see the [contracts/README.md](contracts/README.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Salt used to deploy the contracts. Recommended to use the same salt across different chains. | ||
CREATE2_SALT=0x0000000000000000000000000000000000000000000000000000000000000000 | ||
|
||
### The owner of the Raffle contract. | ||
OWNER= | ||
|
||
### The signer of the Raffle contract. | ||
SIGNER= | ||
|
||
### The SP1 verifier address. | ||
VERIFIER= | ||
|
||
### The verification key for the SP1 RISC-V program. | ||
VKEY= | ||
|
||
### The DrandOracle contract address. | ||
DRAND_ORACLE= | ||
|
||
### The chain to deploy to, specified by chain name (e.g. CHAIN=gravity_sepolia) | ||
CHAIN=gravity_sepolia | ||
|
||
### RPCs for each chain ID | ||
RPC_GRAVITY=https://rpc.gravity.xyz | ||
RPC_GRAVITY_SEPOLIA=https://rpc-sepolia.gravity.xyz | ||
|
||
# Etherscan API URLs for each chain | ||
ETHERSCAN_API_URL_GRAVITY=https://explorer.gravity.xyz/api | ||
ETHERSCAN_API_URL_GRAVITY_SEPOLIA=https://explorer-sepolia.gravity.xyz/api | ||
|
||
## Contract Deployer Private Key | ||
PRIVATE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 🎲 Galxe Raffle Smart Contracts | ||
|
||
## 📋 Requirements | ||
|
||
- [Foundry](https://book.getfoundry.sh/getting-started/installation) for smart contract development | ||
|
||
## 📄 Example Deployment | ||
|
||
- Gravity Alpha Testnet Sepolia: [0xc0e9eb9299bd2349ca0bb711b4ba4a1d43b1524f](https://explorer-sepolia.gravity.xyz/address/0xc0e9eb9299bd2349ca0bb711b4ba4a1d43b1524f) |
70 changes: 70 additions & 0 deletions
70
contracts/broadcast/Raffle.s.sol/13505/run-1730752044.json
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "forge-std/Script.sol"; | ||
import {BaseScript} from "../utils/Base.s.sol"; | ||
import {Raffle} from "../../src/Raffle.sol"; | ||
|
||
contract RaffleScript is BaseScript { | ||
function run() external chain broadcaster { | ||
bytes32 CREATE2_SALT = vm.envBytes32("CREATE2_SALT"); | ||
address owner = vm.envAddress("OWNER"); | ||
address signer = vm.envAddress("SIGNER"); | ||
address verifier = vm.envAddress("VERIFIER"); | ||
bytes32 vkey = vm.envBytes32("VKEY"); | ||
address drandOracle = vm.envAddress("DRAND_ORACLE"); | ||
|
||
console.log("Owner:", owner); | ||
console.log("Signer:", signer); | ||
console.log("Verifier:", verifier); | ||
console.log("VKey:"); | ||
console.logBytes32(vkey); | ||
console.log("DrandOracle:", drandOracle); | ||
|
||
Raffle raffle = new Raffle{salt: CREATE2_SALT}(owner, signer, verifier, vkey, drandOracle); | ||
console.log("Raffle deployed at:", address(raffle)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "forge-std/Vm.sol"; | ||
import "forge-std/console.sol"; | ||
import {stdJson} from "forge-std/StdJson.sol"; | ||
import {Script} from "forge-std/Script.sol"; | ||
|
||
/// @notice Script to inherit from to get access to helper functions for deployments. | ||
abstract contract BaseScript is Script { | ||
using stdJson for string; | ||
|
||
/// @notice Run the command with the `--broadcast` flag to send the transaction to the chain, | ||
/// otherwise just simulate the transaction execution. | ||
modifier broadcaster() { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
console.log("Deployer: %s", vm.addr(deployerPrivateKey)); | ||
vm.startBroadcast(deployerPrivateKey); | ||
_; | ||
vm.stopBroadcast(); | ||
} | ||
|
||
/// @notice Runs the script on the chain specified in the `CHAIN` env variable. | ||
/// Must have a `RPC_${CHAIN}` env variable set for the chain (e.g. RPC_MAINNET). | ||
modifier chain() { | ||
string memory c = vm.envString("CHAIN"); | ||
|
||
// Switch to the chain using the RPC | ||
vm.createSelectFork(c); | ||
|
||
console.log("Running script on %s", c); | ||
|
||
_; | ||
} | ||
} |