Skip to content

Commit adb42c5

Browse files
committed
fix: use hardhat language for PoR and line fix
1 parent ef9d0b2 commit adb42c5

File tree

4 files changed

+115
-45
lines changed

4 files changed

+115
-45
lines changed

docs/fdc/guides/foundry/cross-chain-fdc.mdx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Cross-Chain FDC
33
slug: cross-chain-fdc
44
authors: [anthonyamadia]
5-
description: Use the FDC to verify Web2 data on Flare and use the proof to trigger actions on a different chain like the XRPL EVM Sidechain.
5+
description: Use the FDC data on a non-Flare, like the XRPL EVM Sidechain.
66
tags: [fdc, foundry]
77
keywords:
88
[ethereum, flare-data-connector, evm, cross-chain, web2json, relay, xrpl]
@@ -11,9 +11,14 @@ sidebar_position: 11
1111

1212
import AvailableTestnet from "../_available_testnet.mdx";
1313

14-
This guide demonstrates a powerful cross-chain workflow using the Flare Data Connector (FDC). We will fetch data from a public Web2 API using the `Web2Json` attestation type on a Flare network (Coston2) and then use the resulting proof to trigger a state change on a different EVM-compatible blockchain, the XRPL EVM Sidechain Testnet.
14+
This guide demonstrates a powerful cross-chain workflow using the Flare Data Connector (FDC).
15+
We will fetch data from a public Web2 API using the `Web2Json` attestation type on a Flare network (Coston2) and then use the resulting proof to trigger a state change on a different EVM-compatible blockchain, the XRPL EVM Sidechain Testnet.
1516

16-
The key to this cross-chain interaction is the `Relay` contract, which securely transmits the Merkle root from the Flare network to the target chain. This allows a verifier contract on the target chain to confirm the validity of FDC proofs without trusting a centralized intermediary.
17+
The key to this cross-chain interaction is the `Relay` contract. For a non-Flare chain to verify FDC proofs, the Merkle root of each finalized voting round on Flare must be transmitted to the target chain.
18+
This is handled by the `Relay` contract, which must be deployed on the target chain.
19+
For the XRPL EVM Sidechain, Flare provides a relayer service where a backend script listens for `Relay` transactions on Flare and copies them to the `Relay` contract on the target chain which allows a verifier contract on the target chain to confirm the validity of FDC proofs without trusting a centralized intermediary.
20+
21+
Before running any code, you must make sure you deploy the `Relay` contract onto the target chain and save its address to a `.env` file.
1722

1823
<AvailableTestnet />
1924

@@ -92,7 +97,9 @@ forge script script/CrossChainFdc.s.sol:DeployInfrastructure --rpc-url $XRPLEVM_
9297

9398
### 2. Prepare and Submit Request on Source Chain (Coston2)
9499

95-
This step, executed by the `PrepareAndSubmitRequest` script, must be run on a Flare network (Coston2). It prepares the `Web2Json` request off-chain by calling the verifier API and then immediately submits the resulting `abiEncodedRequest` to the FDC on-chain.
100+
This step, executed by the `PrepareAndSubmitRequest` script, must be run on a Flare network (Coston2).
101+
102+
It prepares the `Web2Json` request off-chain by calling the verifier API and then immediately submits the resulting `abiEncodedRequest` to the FDC on-chain.
96103

97104
The script saves the `abiEncodedRequest` and the resulting `votingRoundId` to files, which will be needed for the final step on the target chain.
98105

@@ -141,10 +148,12 @@ forge script script/CrossChainFdc.s.sol:PrepareAndSubmitRequest --rpc-url $COSTO
141148

142149
### 3. Deliver Proof to Consumer on Target Chain (XRPL EVM Sidechain)
143150

144-
The final script, `DeliverProofToContract`, is executed on the target chain (XRPL EVM Sidechain). It handles deploying the consumer contract, retrieving the proof, and delivering it for verification.
151+
The final script, `DeliverProofToContract`, is executed on the target chain (XRPL EVM Sidechain).
152+
153+
It handles deploying the consumer contract, retrieving the proof, and delivering it for verification.
145154

146155
1. **Deploy Consumer Contract**: It first deploys the `StarWarsCharacterListV3` contract, passing it the address of the `FdcVerification` contract deployed in Step 1.
147-
2. **Retrieve Proof**: It reads the `abiEncodedRequest` and `votingRoundId` from the files created in Step 2. After waiting for the voting round on Flare to finalize (approx. 90-180 seconds), it polls the Data Availability layer to get the proof.
156+
2. **Retrieve Proof**: It reads the `abiEncodedRequest` and `votingRoundId` from the files created in Step 2. After waiting for the voting round on Flare to finalize (max. 180 seconds), it polls the Data Availability layer to get the proof.
148157
3. **Interact with Consumer**: It calls `addCharacter` on the deployed consumer contract, passing the `finalProof`. A `value` of 1 wei is sent to cover the fee required by the `Relay` contract to fetch the Merkle root from the source chain.
149158

150159
```solidity title="script/CrossChainFdc.s.sol"

docs/fdc/guides/foundry/cross-chain-payment.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ sidebar_position: 9
99

1010
import AvailableTestnet from "../_available_testnet.mdx";
1111

12-
The `EVMTransaction` attestation type enables the verification of transaction details from any EVM-compatible blockchain. You can learn more about it in the official [specification repo](/fdc/attestation-types/evm-transaction).
13-
14-
<AvailableTestnet />
15-
1612
We will now demonstrate how the FDC protocol can be used to verify a payment that occurred on one chain (e.g., Sepolia testnet) and trigger an action on another (e.g., Coston2). In this example, verifying a specific USDC transfer on Sepolia will result in the minting of a commemorative NFT on Coston2.
17-
1813
In this guide, we will follow the steps outlined under User Workflow in the [FDC overview](/fdc/overview).
1914

15+
<AvailableTestnet />
16+
2017
Our implementation requires handling the FDC voting round finalization process. To manage this, we will use separate scripts in `script/crossChainPayment.s.sol` that handle different stages of the validation process:
2118

2219
```solidity title="script/crossChainPayment.s.sol"
@@ -191,7 +188,9 @@ forge script script/crossChainPayment.s.sol:SubmitAttestationRequest --rpc-url c
191188

192189
### 4. Retrieve Proof
193190

194-
After waiting for the voting round to be finalized (typically 90-180 seconds), we can retrieve the proof from a Data Availability Layer provider. You can check if the request was submitted successfully on the [AttestationRequests](https://coston2-systems-explorer.flare.rocks/attestation-request) page on the Flare Systems Explorer website. To check if the round has been finalized, go to the [Finalizations](https://coston2-systems-explorer.flare.rocks/finalizations) page.
191+
After waiting for the voting round to be finalized (max. 180 seconds), we can retrieve the proof from a Data Availability Layer provider.
192+
193+
You can check if the request was submitted successfully on the [AttestationRequests](https://coston2-systems-explorer.flare.rocks/attestation-request) page on the Flare Systems Explorer website. To check if the round has been finalized, go to the [Finalizations](https://coston2-systems-explorer.flare.rocks/finalizations) page.
195194

196195
The `RetrieveProof` script waits for finalization, polls the DA layer, and saves the complete proof to a file.
197196

0 commit comments

Comments
 (0)