Last active
December 20, 2024 11:14
-
-
Save clemsos/3ce1d700515da57f2564a9c19cec1295 to your computer and use it in GitHub Desktop.
Revisions
-
clemsos revised this gist
Dec 20, 2024 . 1 changed file with 31 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,20 @@ import { ethers } from 'ethers' const transactionHash = '0xc37329f7bfada70be0a695031b270741542d1dd477fc0a2e0f476d242b8ff508' // sepolia 11155111 const srcChainRPC = 'https://sepolia.gateway.tenderly.co' // base sepolia 84532 const destChainRPC = 'https://base-sepolia.gateway.tenderly.co' const messengerAddress = '0x7865fAfC2db2093669d92c0F33AeEF291086BEFD' async function main() { // decode message on origin chain const srcProvider = new ethers.JsonRpcProvider(srcChainRPC) const transactionReceipt = await srcProvider.getTransactionReceipt(transactionHash) const eventTopic = ethers.solidityPackedKeccak256( ['string'], ['MessageSent(bytes)'] @@ -15,7 +24,26 @@ async function main() { const messageBytes = abiCoder.decode(['bytes'], log.data)[0] const messageHash = ethers.keccak256(messageBytes) // get attestation from Circle's servers // NB: url for testnets only const url = `https://iris-api-sandbox.circle.com/attestations/${messageHash}` const resp = await fetch(url) const { attestation, status } = await resp.json() console.log({ messageBytes, attestation, status }) // receive attestation on dest server if (status === 'completed') { // get destination provider const destProvider = new ethers.JsonRpcProvider(destChainRPC) // TODO: parse signer // get contract const messenger = new ethers.Contract( messengerAddress, ['function receiveMessage(bytes,bytes)'], destProvider ) await messenger.receiveMessage(messageBytes, attestation) } } main().then(() => console.log('ok')) -
clemsos revised this gist
Dec 20, 2024 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,14 +10,12 @@ async function main() { ['string'], ['MessageSent(bytes)'] ) const log = transactionReceipt?.logs.find((l) => l.topics[0] === eventTopic) const abiCoder = ethers.AbiCoder.defaultAbiCoder() const messageBytes = abiCoder.decode(['bytes'], log.data)[0] const messageHash = ethers.keccak256(messageBytes) console.log({ messageBytes, messageHash }) } main().then(() => console.log('ok')) -
clemsos created this gist
Dec 20, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import { ethers } from 'hardhat' const transactionHash = '0xc37329f7bfada70be0a695031b270741542d1dd477fc0a2e0f476d242b8ff508' async function main() { const transactionReceipt = await ethers.provider.getTransactionReceipt(transactionHash) const eventTopic = ethers.solidityPackedKeccak256( ['string'], ['MessageSent(bytes)'] ) console.log(eventTopic) const log = transactionReceipt?.logs.find((l) => l.topics[0] === eventTopic) console.log(log) const abiCoder = ethers.AbiCoder.defaultAbiCoder() const messageBytes = abiCoder.decode(['bytes'], log.data)[0] const messageHash = ethers.keccak256(messageBytes) console.log({ messageHash }) } main().then(() => console.log('ok'))