You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
15
16
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.
### 2. Prepare and Submit Request on Source Chain (Coston2)
94
99
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.
96
103
97
104
The script saves the `abiEncodedRequest` and the resulting `votingRoundId` to files, which will be needed for the final step on the target chain.
### 3. Deliver Proof to Consumer on Target Chain (XRPL EVM Sidechain)
143
150
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.
145
154
146
155
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.
148
157
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.
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
-
16
12
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
-
18
13
In this guide, we will follow the steps outlined under User Workflow in the [FDC overview](/fdc/overview).
19
14
15
+
<AvailableTestnet />
16
+
20
17
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:
@@ -191,7 +188,9 @@ forge script script/crossChainPayment.s.sol:SubmitAttestationRequest --rpc-url c
191
188
192
189
### 4. Retrieve Proof
193
190
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.
195
194
196
195
The `RetrieveProof` script waits for finalization, polls the DA layer, and saves the complete proof to a file.
0 commit comments