From 51503238e6f1fd33b96e52a095a7444a193732f7 Mon Sep 17 00:00:00 2001 From: Ratan Kaliani Date: Mon, 26 Feb 2024 12:46:47 -0800 Subject: [PATCH] feat: add deploy and register fn example (#372) --- .../DeployAndRegisterFunction.s.sol | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 contracts/script/gateway-examples/DeployAndRegisterFunction.s.sol diff --git a/contracts/script/gateway-examples/DeployAndRegisterFunction.s.sol b/contracts/script/gateway-examples/DeployAndRegisterFunction.s.sol new file mode 100644 index 00000000..3440dce3 --- /dev/null +++ b/contracts/script/gateway-examples/DeployAndRegisterFunction.s.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "forge-std/Vm.sol"; +import "forge-std/console.sol"; +import {SuccinctGateway} from "../../src/SuccinctGateway.sol"; + +// NOTE: Update FunctionVerifier to the verifier you want to deploy and register from the +// Succinct platform. +contract FunctionVerifier { +} + +contract DeployAndRegisterFunction is Script { + function run() external returns (bytes32, address) { + vm.startBroadcast(); + + // Get the bytecode of the FunctionVerifier contract. + bytes memory bytecode = type(FunctionVerifier).creationCode; + + // SuccinctGateway address + address GATEWAY = vm.envAddress("SUCCINCT_GATEWAY"); + console.logAddress(GATEWAY); + + // Create2 salt + bytes32 SALT = vm.envBytes32("CREATE2_SALT"); + + address OWNER = msg.sender; + + (bytes32 functionId, address verifier) = + SuccinctGateway(GATEWAY).deployAndRegisterFunction(OWNER, bytecode, SALT); + + return (functionId, verifier); + } +}