Skip to content

Commit

Permalink
Add Deploy_jwtVerifier.s.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
wshino committed Oct 12, 2024
1 parent f04645d commit d31bb35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Here is the sample verified deployed addresses on Sepolia:
```
JWTRegistry: 0x983A7B6a8b5657319078D858a303830C99761108
DKIMRegistry: 0xf3B70Dc348C7820b3026564500A7eBAc6cC4cC33
JWTVerifier: 0xac82c745AAdA7489786ed689bcc1138F27833cD7
JWTVerifier implementation: 0xF462839975B5e1844dD32cb301aFE65D0Dbe66Dd
JWTVerifier proxy: 0x63E990e29317Bf54a6c4F5Fb26e33342D3DE6Fd3
```

## Errors
Expand Down
21 changes: 19 additions & 2 deletions packages/contracts/script/Deploy_jwtVerifier.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,37 @@ pragma solidity ^0.8.12;

import "forge-std/Script.sol";
import "../src/utils/JwtVerifier.sol";
import "../src/utils/JwtGroth16Verifier.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

// 1. `source .env`
// 2. `forge script script/Deploy_jwtVerifier.s.sol:DeployScript --rpc-url $RPC_URL --verify --etherscan-api-key $ETHERSCAN_API_KEY --broadcast -vvvv`
contract DeployScript is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
address initialOwner = deployer;
bytes32 salt = keccak256(abi.encodePacked(vm.envString("DEPLOY_SALT")));

vm.startBroadcast(deployerPrivateKey);

// Deploy the contract using CREATE2
JwtVerifier jwtVerifier = new JwtVerifier{salt: salt}();
JwtVerifier jwtVerifierImpl = new JwtVerifier();
console.log(
"JWTVerifier implementation deployed at: %s",
address(jwtVerifierImpl)
);
JwtGroth16Verifier groth16Verifier = new JwtGroth16Verifier();
ERC1967Proxy jwtVerifierProxy = new ERC1967Proxy{salt: salt}(
address(jwtVerifierImpl),
abi.encodeCall(
jwtVerifierImpl.initialize,
(initialOwner, address(groth16Verifier))
)
);

console.log("Contract deployed to:", address(jwtVerifier));
JwtVerifier jwtVerifier = JwtVerifier(address(jwtVerifierProxy));
console.log("JWTVerifier proxy deployed to:", address(jwtVerifier));

vm.stopBroadcast();
}
Expand Down

0 comments on commit d31bb35

Please sign in to comment.