Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ ARBITRUM_SEPOLIA_ETHERSCAN_API_URL=https://api-sepolia.arbiscan.io/api
ARBITRUM_SEPOLIA_ETHERSCAN_BROWSER_URL=https://sepolia.arbiscan.io/
ARBITRUM_SEPOLIA_INBOX=0xaAe29B0366299461418F5324a79Afc425BE5ae21

# WORLD CHAIN

WORLD_CHAIN_PRIVATE_KEY=

# sepolia
WORLD_CHAIN_SEPOLIA_RPC=
WORLD_CHAIN_SEPOLIA_CHAINID=4801
WORLD_CHAIN_SEPOLIA_L2_OUTPUT_ORACLE=0xc8886f8BAb6Eaeb215aDB5f1c686BF699248300e

# STARKNET

STARKNET_SEPOLIA_CORE_ADDRESS=0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057
Expand Down
15 changes: 15 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const config: HardhatUserConfig = {
zkSyncSepolia: process.env.ZKSYNC_ETHERSCAN_API_KEY as string,
optimismSepolia: process.env.OPTIMISM_ETHERSCAN_API_KEY as string,
arbitrumSepolia: process.env.ARBITRUM_ETHERSCAN_API_KEY as string,
// worldChainSepolia: process.env.WORLD_CHAIN_ETHERSCAN_API_KEY as string,
},
customChains: [
{
Expand All @@ -55,6 +56,16 @@ const config: HardhatUserConfig = {
.ARBITRUM_SEPOLIA_ETHERSCAN_BROWSER_URL as string,
},
},
//? Verifying Probably does not work on World Chain yet
// {
// network: "worldChainSepolia",
// chainId: parseInt(process.env.WORLD_CHAIN_SEPOLIA_CHAINID as string),
// urls: {
// apiURL: process.env.WORLD_CHAIN_SEPOLIA_ETHERSCAN_API_URL as string,
// browserURL: process.env
// .WORLD_CHAIN_SEPOLIA_ETHERSCAN_BROWSER_URL as string,
// },
// },
],
},
defaultNetwork: "zkSyncSepolia",
Expand All @@ -78,6 +89,10 @@ const config: HardhatUserConfig = {
url: process.env.ARBITRUM_SEPOLIA_RPC,
accounts: [process.env.ARBITRUM_PRIVATE_KEY as string],
},
worldChainSepolia: {
url: process.env.WORLD_CHAIN_SEPOLIA_RPC,
accounts: [process.env.WORLD_CHAIN_PRIVATE_KEY as string],
},
},
};
export default config;
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@
"license": "GPL-3.0",
"scripts": {
"preinstall": "npx only-allow pnpm",
"compile": "npx hardhat compile",
"deploy:11155111_to_300": "bash script/Deploy_11155111_to_300.sh",
"deploy:11155111_to_11155111": "npx hardhat run script/Deploy_11155111_to_11155111.ts --network sepolia",
"deploy:11155111_to_11155420": "bash script/Deploy_11155111_to_11155420.sh",
"deploy:11155111_to_421614": "bash script/Deploy_11155111_to_421614.sh",
"deploy:11155111_to_4801": "bash script/Deploy_11155111_to_4801.sh",
"deploy:4801_to_4801": "npx hardhat run script/Deploy_4801_to_4801.ts --network worldChainSepolia",
"deploy:4801_to_11155111": "npx hardhat run script/Deploy_4801_to_11155111.ts --network sepolia",
"deploy:84532_to_4801": "bash script/Deploy_84532_to_4801.sh",
"verify:11155111_to_300": "bash script/Verify_11155111_to_300.sh",
"verify:11155111_to_11155111": "bash script/Verify_11155111_to_11155111.sh",
"verify:11155111_to_11155420": "bash script/Verify_11155111_to_11155420.sh",
"verify:11155111_to_421614": "bash script/Verify_11155111_to_421614.sh"
"verify:11155111_to_421614": "bash script/Verify_11155111_to_421614.sh",
"verify:11155111_to_4801": "bash script/Verify_11155111_to_4801.sh",
"verify:4801_to_4801": "bash script/Verify_4801_to_4801.sh",
"verify:4801_to_11155111": "bash script/Verify_4801_to_11155111.sh"
},
"dependencies": {
"@accumulators/hashers": "^4.2.3",
Expand Down Expand Up @@ -41,4 +49,4 @@
"typescript": "^5.5.4",
"zksync-ethers": "^6.11.2"
}
}
}
30 changes: 30 additions & 0 deletions script/Deploy_11155111_to_4801.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

source .env
while IFS= read -r line; do
echo "$line"

if [[ "$line" =~ ^Deployed\ OpMessagesInbox\ at:\ (0x[0-9A-Fa-f]+)$ ]]; then
DEPLOYED_L2_INBOX="${BASH_REMATCH[1]}"
fi
done < <(npx hardhat run script/Deploy_11155111_to_4801_part1.ts --network worldChainSepolia)

if [ -z "$DEPLOYED_L2_INBOX" ]; then
echo "Didn't find deployment address of OpMessagesInbox"
exit 1
fi

while IFS= read -r line; do
echo "$line"

if [[ "$line" =~ ^Deployed\ L1ToOptimismMessagesSender\ at:\ (0x[0-9A-Fa-f]+)$ ]]; then
DEPLOYED_L1_OUTBOX="${BASH_REMATCH[1]}"
fi
done < <(DEPLOYED_L2_INBOX=$DEPLOYED_L2_INBOX npx hardhat run script/Deploy_11155111_to_4801_part2.ts --network sepolia)

if [ -z "$DEPLOYED_L1_OUTBOX" ]; then
echo "Didn't find deployment address of L1ToOptimismMessagesSender"
exit 1
fi

DEPLOYED_L2_INBOX=$DEPLOYED_L2_INBOX DEPLOYED_L1_OUTBOX=$DEPLOYED_L1_OUTBOX npx hardhat run script/Deploy_11155111_to_4801_part3.ts --network worldChainSepolia
76 changes: 76 additions & 0 deletions script/Deploy_11155111_to_4801_part1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import dotenv from "dotenv";
import hre from "hardhat";

dotenv.config();

const PRIVATE_KEY = process.env.WORLD_CHAIN_PRIVATE_KEY || "";
const CHAINID = process.env.L1_SEPOLIA_CHAINID || "";

if (!PRIVATE_KEY) {
throw new Error("WORLD_CHAIN_PRIVATE_KEY is not set in .env");
}
if (!CHAINID) {
throw new Error("L1_SEPOLIA_CHAINID is not set in .env");
}

export async function main() {
// deploy OpMessagesInbox
const OpMessagesInbox =
await hre.ethers.getContractFactory("OpMessagesInbox");
const opMessagesInbox = await OpMessagesInbox.deploy();
const opMessagesInboxAddr = await opMessagesInbox.getAddress();
await opMessagesInbox.waitForDeployment();
console.log("Deployed OpMessagesInbox at:", opMessagesInboxAddr);

// deploy HeaderStore
const HeadersStore = await hre.ethers.getContractFactory("HeadersStore");
const headersStore = await HeadersStore.deploy(opMessagesInboxAddr);
const headersStoreAddr = await headersStore.getAddress();
await headersStore.waitForDeployment();
console.log("Deployed HeadersStore at:", headersStoreAddr);

// deploy FactsRegistry
const FactsRegistry = await hre.ethers.getContractFactory("FactsRegistry");
const factsRegistry = await FactsRegistry.deploy(headersStoreAddr);
const factsRegistryAddr = await factsRegistry.getAddress();
await factsRegistry.waitForDeployment();
console.log("Deployed FactsRegistry at:", factsRegistryAddr);

// set OpMessagesInbox variables
await opMessagesInbox.setHeadersStore(headersStoreAddr);
await opMessagesInbox.setMessagesOriginChainId(CHAINID);
// setCrossDomainMsgSender will be called at step 3

// verify OpMessagesInbox
await hre.run("verify:verify", {
address: opMessagesInboxAddr,
constructorArguments: [],
force: true,
});

// verify HeadersStore
await hre.run("verify:verify", {
address: headersStoreAddr,
constructorArguments: [opMessagesInboxAddr],
force: true,
});

// verify FactsRegistry
await hre.run("verify:verify", {
address: factsRegistryAddr,
constructorArguments: [headersStoreAddr],
force: true,
});

console.log(
"===============================================================",
);
console.log("HeadersStore:", headersStoreAddr);
console.log("FactsRegistry:", factsRegistryAddr);
console.log("OpMessagesInbox:", opMessagesInboxAddr);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
87 changes: 87 additions & 0 deletions script/Deploy_11155111_to_4801_part2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import dotenv from "dotenv";
import hre from "hardhat";

dotenv.config();

const aggregatorsFactory = process.env.L1_SEPOLIA_AGGREGATORS_FACTORY || "";
const l2Target = process.env.DEPLOYED_L2_INBOX || "";
const crossDomainMsgSender =
process.env.WORLD_CHAIN_SEPOLIA_CROSS_DOMAIN_MESSENGER || "";

if (!aggregatorsFactory) {
throw new Error("L1_SEPOLIA_AGGREGATORS_FACTORY is not set in .env");
}
if (!l2Target) {
throw new Error("DEPLOYED_L2_INBOX is not set in .env");
}
if (!crossDomainMsgSender) {
throw new Error(
"WORLD_CHAIN_SEPOLIA_CROSS_DOMAIN_MESSENGER is not set in .env",
);
}

export async function main() {
// deploy NativeParentHashesFetcher
const NativeParentHashesFetcher = await hre.ethers.getContractFactory(
"NativeParentHashesFetcher",
);
const nativeParentHashesFetcher = await NativeParentHashesFetcher.deploy();
const nativeParentHashesFetcherAddress =
await nativeParentHashesFetcher.getAddress();
await nativeParentHashesFetcher.waitForDeployment();
console.log(
"Deployed NativeParentHashesFetcher at:",
nativeParentHashesFetcherAddress,
);

// deploy L1ToOptimismMessagesSender
const L1ToOptimismMessagesSender = await hre.ethers.getContractFactory(
"L1ToOptimismMessagesSender",
);
const l1ToOptimismMessagesSender = await L1ToOptimismMessagesSender.deploy(
aggregatorsFactory,
nativeParentHashesFetcherAddress,
l2Target,
crossDomainMsgSender,
);
const l1ToOptimismMessagesSenderAddress =
await l1ToOptimismMessagesSender.getAddress();
await l1ToOptimismMessagesSender.waitForDeployment();
console.log(
"Deployed L1ToOptimismMessagesSender at:",
l1ToOptimismMessagesSenderAddress,
);

// verify NativeParentHashesFetcher
await hre.run("verify:verify", {
address: nativeParentHashesFetcherAddress,
constructorArguments: [],
force: true,
});

// verify L1ToOptimismMessagesSender
await hre.run("verify:verify", {
address: l1ToOptimismMessagesSenderAddress,
constructorArguments: [
aggregatorsFactory,
nativeParentHashesFetcherAddress,
l2Target,
crossDomainMsgSender,
],
force: true,
});

console.log(
"===============================================================",
);
console.log("NativeParentHashesFetcher:", nativeParentHashesFetcherAddress);
console.log(
"L1ToOptimismMessagesSenderAddress:",
l1ToOptimismMessagesSenderAddress,
);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
39 changes: 39 additions & 0 deletions script/Deploy_11155111_to_4801_part3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import dotenv from "dotenv";
import hre from "hardhat";

dotenv.config();

const PRIVATE_KEY = process.env.WORLD_CHAIN_PRIVATE_KEY || "";
const opMessagesInboxAddress = process.env.DEPLOYED_L2_INBOX || "";
const crossDomainMsgSenderAddress = process.env.DEPLOYED_L1_OUTBOX || "";

if (!PRIVATE_KEY) {
throw new Error("WORLD_CHAIN_PRIVATE_KEY is not set in .env");
}
if (!opMessagesInboxAddress) {
throw new Error("DEPLOYED_L2_INBOX is not set in .env");
}
if (!crossDomainMsgSenderAddress) {
throw new Error("DEPLOYED_L1_OUTBOX is not set in .env");
}

export async function main() {
// Call setCrossDomainMsgSender on OpMessagesInbox
const opMessagesInbox = await hre.ethers.getContractAt(
"OpMessagesInbox",
opMessagesInboxAddress,
);
const tx = await opMessagesInbox.setCrossDomainMsgSender(
crossDomainMsgSenderAddress,
);
await tx.wait();

console.log(
`crossDomainMsgSender of OpMessagesInbox(${opMessagesInboxAddress}) has been set to ${crossDomainMsgSenderAddress}`,
);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Loading