Skip to content

Commit

Permalink
feat: add deploy and register fn example (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani authored Feb 26, 2024
1 parent 5a48e5a commit 5150323
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions contracts/script/gateway-examples/DeployAndRegisterFunction.s.sol
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);
}
}

0 comments on commit 5150323

Please sign in to comment.