-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathAccessKey.sol
More file actions
42 lines (35 loc) · 1.24 KB
/
Copy pathAccessKey.sol
File metadata and controls
42 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import { IBridgehub, L2TransactionRequestDirect } from "@zksync-contracts/l1-contracts/bridgehub/IBridgehub.sol";
contract AccessKey {
address public owner;
constructor() {
owner = msg.sender;
}
function unlockVaultOnL2(
uint256 chainId,
address bridgeHubAddress,
address vaultAddress,
bytes memory data,
uint256 gasLimit,
uint256 gasPerPubdataByteLimit,
uint256 cost
) external payable {
require(msg.sender == owner, "Only owner can unlock");
IBridgehub bridgeHub = IBridgehub(bridgeHubAddress);
// Construct the L2 transaction request struct
L2TransactionRequestDirect memory request = L2TransactionRequestDirect({
chainId: chainId,
mintValue: msg.value,
l2Contract: vaultAddress,
l2Value: 0,
l2Calldata: data,
l2GasLimit: gasLimit,
l2GasPerPubdataByteLimit: gasPerPubdataByteLimit,
factoryDeps: new bytes[](0),
refundRecipient: msg.sender
});
// Make the cross-chain transaction call
bridgeHub.requestL2TransactionDirect{ value: msg.value }(request);
}
}