Created
August 26, 2022 21:16
-
-
Save saucepoint/fd987db6d08c482d366a6762367b2f9f to your computer and use it in GitHub Desktop.
SnowV1
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
// SPDX-License-Identifier: MIT | |
// author: @saucepoint | |
// Forge script | |
// Off the top my head (might be missing a flag): | |
// forge script script/SnowV1Program.s.sol --rpc-url https://mainnet-polygon.brave.com/ --chain-id 137 --private-key YOUR_PRIVATE_KEY --broadcast | |
pragma solidity ^0.8.13; | |
import "forge-std/Script.sol"; | |
import "../src/SnowV1Program.sol"; | |
contract SnowV1ProgramScript is Script { | |
function setUp() public {} | |
// Attaches your program to the SnowV1 contract | |
function run() public { | |
// https://polygonscan.com/address/0xf53d926c13af77c53afae6b33480ddd94b167610#writeProxyContract | |
SnowV1 c = ISnowV1(address(0xF53D926c13Af77C53AFAe6B33480DDd94B167610)); | |
// Assumes you've been whitelisted already! | |
vm.startBroadcast("0xYOUR_ADDRESS_HERE"); | |
SnowV1Program program = new SnowV1Program(); | |
c.becomeOperator(address(program)); | |
vm.stopBroadcast(); | |
} | |
} |
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
// SPDX-License-Identifier: MIT | |
// author: @saucepoint | |
pragma solidity ^0.8.13; | |
interface ISnowV1Program { | |
function name() external view returns (string memory); | |
function run(uint256[64] memory canvas, uint8 lastUpdatedIndex) | |
external | |
returns (uint8 index, uint256 value); | |
} | |
interface ISnowV1 { | |
function becomeOperator(address program) external; | |
} | |
// Implement your program, which looks like it writes to some sort of canvas | |
// See https://polygonscan.com/address/0x7b07afdd4b384b36dfadf4654b19932dc9164bd6#code#F1#L63 | |
// for how SnowV1 will be calling your SnowV1Program | |
contract SnowV1Program is ISnowV1Program { | |
function name() public pure returns (string memory _name) { | |
_name = "saucepoint"; | |
} | |
function run(uint256[64] memory canvas, uint8 lastUpdatedIndex) public returns (uint8 index, uint256 value) { | |
index = 69; | |
value = 420; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment