-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deploy and register fn example (#372)
- Loading branch information
1 parent
5a48e5a
commit 5150323
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
contracts/script/gateway-examples/DeployAndRegisterFunction.s.sol
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.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); | ||
} | ||
} |