Skip to content

Commit dc07154

Browse files
committed
Created a BridgeToken Script and bridged tokens from Sepolia to ZksyncSepolia
1 parent ce59dec commit dc07154

File tree

89 files changed

+905
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+905
-3
lines changed

bridgeToZksync.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
3+
# Define constants
4+
AMOUNT=100000
5+
6+
DEFAULT_ZKSYNC_LOCAL_KEY="0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110"
7+
DEFAULT_ZKSYNC_ADDRESS="0x36615Cf349d7F6344891B1e7CA7C72883F5dc049"
8+
9+
ZKSYNC_REGISTRY_MODULE_OWNER_CUSTOM="0x3139687Ee9938422F57933C3CDB3E21EE43c4d0F"
10+
ZKSYNC_TOKEN_ADMIN_REGISTRY="0xc7777f12258014866c677Bdb679D0b007405b7DF"
11+
ZKSYNC_ROUTER="0xA1fdA8aa9A8C4b945C45aD30647b01f07D7A0B16"
12+
ZKSYNC_RNM_PROXY_ADDRESS="0x3DA20FD3D8a8f8c1f1A5fD03648147143608C467"
13+
ZKSYNC_SEPOLIA_CHAIN_SELECTOR="6898391096552792247"
14+
ZKSYNC_LINK_ADDRESS="0x23A1aFD896c8c8876AF46aDc38521f4432658d1e"
15+
16+
SEPOLIA_REGISTRY_MODULE_OWNER_CUSTOM="0x62e731218d0D47305aba2BE3751E7EE9E5520790"
17+
SEPOLIA_TOKEN_ADMIN_REGISTRY="0x95F29FEE11c5C55d26cCcf1DB6772DE953B37B82"
18+
SEPOLIA_ROUTER="0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59"
19+
SEPOLIA_RNM_PROXY_ADDRESS="0xba3f6251de62dED61Ff98590cB2fDf6871FbB991"
20+
SEPOLIA_CHAIN_SELECTOR="16015286601757825753"
21+
SEPOLIA_LINK_ADDRESS="0x779877A7B0D9E8603169DdbD7836e478b4624789"
22+
23+
# Compile and deploy the Rebase Token contract
24+
foundryup-zksync
25+
source .env
26+
forge build --zksync
27+
echo "Compiling and deploying the Rebase Token contract on ZKsync..."
28+
ZKSYNC_REBASE_TOKEN_ADDRESS=$(forge create src/RebaseToken.sol:RebaseToken --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase --legacy --zksync | awk '/Deployed to:/ {print $3}')
29+
echo "ZKsync rebase token address: $ZKSYNC_REBASE_TOKEN_ADDRESS"
30+
31+
# Compile and deploy the pool contract
32+
echo "Compiling and deploying the pool contract on ZKsync..."
33+
ZKSYNC_POOL_ADDRESS=$(forge create src/RebaseTokenPool.sol:RebaseTokenPool --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase --legacy --zksync --constructor-args ${ZKSYNC_REBASE_TOKEN_ADDRESS} [] ${ZKSYNC_RNM_PROXY_ADDRESS} ${ZKSYNC_ROUTER} | awk '/Deployed to:/ {print $3}')
34+
echo "Pool address: $ZKSYNC_POOL_ADDRESS"
35+
36+
# Set the permissions for the pool contract
37+
echo "Setting the permissions for the pool contract on ZKsync..."
38+
cast send ${ZKSYNC_REBASE_TOKEN_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase "grantMintAndBurnRole(address)" ${ZKSYNC_POOL_ADDRESS}
39+
echo "Pool permissions set"
40+
41+
# Set the CCIP roles and permissions
42+
echo "Setting the CCIP roles and permissions on ZKsync..."
43+
cast send ${ZKSYNC_REGISTRY_MODULE_OWNER_CUSTOM} "registerAdminViaOwner(address)" ${ZKSYNC_REBASE_TOKEN_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase
44+
cast send ${ZKSYNC_TOKEN_ADMIN_REGISTRY} "acceptAdminRole(address)" ${ZKSYNC_REBASE_TOKEN_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase
45+
cast send ${ZKSYNC_TOKEN_ADMIN_REGISTRY} "setPool(address,address)" ${ZKSYNC_REBASE_TOKEN_ADDRESS} ${ZKSYNC_POOL_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase
46+
echo "CCIP roles and permissions set"
47+
48+
# 2. On Sepolia!
49+
50+
echo "Running the script to deploy the contracts on Sepolia..."
51+
output=$(forge script ./script/Deployer.s.sol:TokenAndPoolDeployer --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast)
52+
echo "Contracts deployed and permission set on Sepolia"
53+
54+
# Extract the addresses from the output
55+
SEPOLIA_REBASE_TOKEN_ADDRESS=$(echo "$output" | grep 'token: contract RebaseToken' | awk '{print $4}')
56+
SEPOLIA_POOL_ADDRESS=$(echo "$output" | grep 'pool: contract RebaseTokenPool' | awk '{print $4}')
57+
58+
echo "Sepolia rebase token address: $SEPOLIA_REBASE_TOKEN_ADDRESS"
59+
echo "Sepolia pool address: $SEPOLIA_POOL_ADDRESS"
60+
61+
# Deploy the vault
62+
echo "Deploying the vault on Sepolia..."
63+
VAULT_ADDRESS=$(forge script ./script/Deployer.s.sol:VaultDeployer --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast --sig "run(address)" ${SEPOLIA_REBASE_TOKEN_ADDRESS} | grep 'vault: contract Vault' | awk '{print $NF}')
64+
echo "Vault address: $VAULT_ADDRESS"
65+
66+
# Configure the pool on Sepolia
67+
echo "Configuring the pool on Sepolia..."
68+
# uint64 remoteChainSelector,
69+
# address remotePoolAddress, /
70+
# address remoteTokenAddress, /
71+
# bool outboundRateLimiterIsEnabled, false
72+
# uint128 outboundRateLimiterCapacity, 0
73+
# uint128 outboundRateLimiterRate, 0
74+
# bool inboundRateLimiterIsEnabled, false
75+
# uint128 inboundRateLimiterCapacity, 0
76+
# uint128 inboundRateLimiterRate 0
77+
forge script ./script/Configure.s.sol:ConfigurePool --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast --sig "run(address,uint64,address,address,bool,uint128,uint128,bool,uint128,uint128)" ${SEPOLIA_POOL_ADDRESS} ${ZKSYNC_SEPOLIA_CHAIN_SELECTOR} ${ZKSYNC_POOL_ADDRESS} ${ZKSYNC_REBASE_TOKEN_ADDRESS} false 0 0 false 0 0
78+
79+
# Deposit funds to the vault
80+
echo "Depositing funds to the vault on Sepolia..."
81+
cast send ${VAULT_ADDRESS} --value ${AMOUNT} --rpc-url ${SEPOLIA_RPC_URL} --account Rebase "deposit()"
82+
83+
# Wait a beat for some interest to accrue
84+
85+
# Configure the pool on ZKsync
86+
echo "Configuring the pool on ZKsync..."
87+
cast send ${ZKSYNC_POOL_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase "applyChainUpdates(uint64[],(uint64,bytes[],bytes,(bool,uint128,uint128),(bool,uint128,uint128))[])" "[${SEPOLIA_CHAIN_SELECTOR}]" "[(${SEPOLIA_CHAIN_SELECTOR},[$(cast abi-encode "f(address)" ${SEPOLIA_POOL_ADDRESS})],$(cast abi-encode "f(address)" ${SEPOLIA_REBASE_TOKEN_ADDRESS}),(false,0,0),(false,0,0))]"
88+
89+
# Bridge the funds using the script to zksync
90+
echo "Bridging the funds using the script to ZKsync..."
91+
SEPOLIA_BALANCE_BEFORE=$(cast balance $(cast wallet address --account Rebase) --erc20 ${SEPOLIA_REBASE_TOKEN_ADDRESS} --rpc-url ${SEPOLIA_RPC_URL})
92+
echo "Sepolia balance before bridging: $SEPOLIA_BALANCE_BEFORE"
93+
forge script ./script/BridgeToken.s.sol:BridgeToken --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast --sig "sendMessage(address,uint64,address,uint256,address,address)" $(cast wallet address --account Rebase) ${ZKSYNC_SEPOLIA_CHAIN_SELECTOR} ${SEPOLIA_REBASE_TOKEN_ADDRESS} ${AMOUNT} ${SEPOLIA_LINK_ADDRESS} ${SEPOLIA_ROUTER}
94+
echo "Funds bridged to ZKsync"
95+
SEPOLIA_BALANCE_AFTER=$(cast balance $(cast wallet address --account Rebase) --erc20 ${SEPOLIA_REBASE_TOKEN_ADDRESS} --rpc-url ${SEPOLIA_RPC_URL})
96+
echo "Sepolia balance after bridging: $SEPOLIA_BALANCE_AFTER"
97+
98+
99+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"transactions": [
3+
{
4+
"hash": "0x7125c650bf32a52435e414dad7dd794237a50e8fcd363e5cf3fc2964be45de7b",
5+
"transactionType": "CALL",
6+
"contractName": null,
7+
"contractAddress": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
8+
"function": "applyChainUpdates((uint64,bool,bytes,bytes,(bool,uint128,uint128),(bool,uint128,uint128))[])",
9+
"arguments": [
10+
"[(6898391096552792247, true, 0x0000000000000000000000002410415d498ee4aa857956af9572e5e1d3fc7a1f, 0x0000000000000000000000007f2df611e7031edace5e59be545ee4d0a3e8abf3, (false, 0, 0), (false, 0, 0))]"
11+
],
12+
"transaction": {
13+
"from": "0x6abffc2e29842932754e125327099899fb08ae01",
14+
"to": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
15+
"gas": "0x5580a",
16+
"value": "0x0",
17+
"input": "0xdb6327dc0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000005fbc02272fbf20b700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000002410415d498ee4aa857956af9572e5e1d3fc7a1f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000007f2df611e7031edace5e59be545ee4d0a3e8abf3",
18+
"nonce": "0x8c",
19+
"chainId": "0xaa36a7"
20+
},
21+
"additionalContracts": [],
22+
"isFixedGasLimit": false
23+
}
24+
],
25+
"receipts": [
26+
{
27+
"status": "0x1",
28+
"cumulativeGasUsed": "0x12aee23",
29+
"logs": [
30+
{
31+
"address": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
32+
"topics": [
33+
"0x8d340f17e19058004c20453540862a9c62778504476f6756755cb33bcd6c38c2"
34+
],
35+
"data": "0x0000000000000000000000000000000000000000000000005fbc02272fbf20b7000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007f2df611e7031edace5e59be545ee4d0a3e8abf3",
36+
"blockHash": "0xdbcdece01a2bd2fe774287dc936875d4bf7ab3086aa60e2247730c349adf38c0",
37+
"blockNumber": "0x7e6f42",
38+
"blockTimestamp": "0x681d51d4",
39+
"transactionHash": "0x7125c650bf32a52435e414dad7dd794237a50e8fcd363e5cf3fc2964be45de7b",
40+
"transactionIndex": "0xb3",
41+
"logIndex": "0x13e",
42+
"removed": false
43+
}
44+
],
45+
"logsBloom": "0x00000000000000400000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000100000000000000",
46+
"type": "0x2",
47+
"transactionHash": "0x7125c650bf32a52435e414dad7dd794237a50e8fcd363e5cf3fc2964be45de7b",
48+
"transactionIndex": "0xb3",
49+
"blockHash": "0xdbcdece01a2bd2fe774287dc936875d4bf7ab3086aa60e2247730c349adf38c0",
50+
"blockNumber": "0x7e6f42",
51+
"gasUsed": "0x3a76a",
52+
"effectiveGasPrice": "0x29945e",
53+
"from": "0x6abffc2e29842932754e125327099899fb08ae01",
54+
"to": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
55+
"contractAddress": null
56+
}
57+
],
58+
"libraries": [],
59+
"pending": [],
60+
"returns": {},
61+
"timestamp": 1746751957,
62+
"chain": 11155111,
63+
"commit": "ce59dec"
64+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"transactions": [
3+
{
4+
"hash": "0x7125c650bf32a52435e414dad7dd794237a50e8fcd363e5cf3fc2964be45de7b",
5+
"transactionType": "CALL",
6+
"contractName": null,
7+
"contractAddress": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
8+
"function": "applyChainUpdates((uint64,bool,bytes,bytes,(bool,uint128,uint128),(bool,uint128,uint128))[])",
9+
"arguments": [
10+
"[(6898391096552792247, true, 0x0000000000000000000000002410415d498ee4aa857956af9572e5e1d3fc7a1f, 0x0000000000000000000000007f2df611e7031edace5e59be545ee4d0a3e8abf3, (false, 0, 0), (false, 0, 0))]"
11+
],
12+
"transaction": {
13+
"from": "0x6abffc2e29842932754e125327099899fb08ae01",
14+
"to": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
15+
"gas": "0x5580a",
16+
"value": "0x0",
17+
"input": "0xdb6327dc0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000005fbc02272fbf20b700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000002410415d498ee4aa857956af9572e5e1d3fc7a1f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000007f2df611e7031edace5e59be545ee4d0a3e8abf3",
18+
"nonce": "0x8c",
19+
"chainId": "0xaa36a7"
20+
},
21+
"additionalContracts": [],
22+
"isFixedGasLimit": false
23+
}
24+
],
25+
"receipts": [
26+
{
27+
"status": "0x1",
28+
"cumulativeGasUsed": "0x12aee23",
29+
"logs": [
30+
{
31+
"address": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
32+
"topics": [
33+
"0x8d340f17e19058004c20453540862a9c62778504476f6756755cb33bcd6c38c2"
34+
],
35+
"data": "0x0000000000000000000000000000000000000000000000005fbc02272fbf20b7000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007f2df611e7031edace5e59be545ee4d0a3e8abf3",
36+
"blockHash": "0xdbcdece01a2bd2fe774287dc936875d4bf7ab3086aa60e2247730c349adf38c0",
37+
"blockNumber": "0x7e6f42",
38+
"blockTimestamp": "0x681d51d4",
39+
"transactionHash": "0x7125c650bf32a52435e414dad7dd794237a50e8fcd363e5cf3fc2964be45de7b",
40+
"transactionIndex": "0xb3",
41+
"logIndex": "0x13e",
42+
"removed": false
43+
}
44+
],
45+
"logsBloom": "0x00000000000000400000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000100000000000000",
46+
"type": "0x2",
47+
"transactionHash": "0x7125c650bf32a52435e414dad7dd794237a50e8fcd363e5cf3fc2964be45de7b",
48+
"transactionIndex": "0xb3",
49+
"blockHash": "0xdbcdece01a2bd2fe774287dc936875d4bf7ab3086aa60e2247730c349adf38c0",
50+
"blockNumber": "0x7e6f42",
51+
"gasUsed": "0x3a76a",
52+
"effectiveGasPrice": "0x29945e",
53+
"from": "0x6abffc2e29842932754e125327099899fb08ae01",
54+
"to": "0x9616408bc1d81649acd980cc2991fbc9a04f6a0e",
55+
"contractAddress": null
56+
}
57+
],
58+
"libraries": [],
59+
"pending": [],
60+
"returns": {},
61+
"timestamp": 1746751957,
62+
"chain": 11155111,
63+
"commit": "ce59dec"
64+
}

0 commit comments

Comments
 (0)