Submit The Proof Request
Code
import { ZKP } from "@bel2labs/sdk";
import { ethers } from "ethers";
const verification = await ZKP.EthersV6.TransactionVerification.create(
txId,
20
);
if (!verification.isSubmitted()) {
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
verification.status$.subscribe((status) => {
console.log("New status:", status);
});
const response = await verification.submitVerific
Breakdown
Imports:
ZKP
from@bel2labs/sdk
for Zero-Knowledge Proof functionalities.ethers
fromether.js
for EVM interactions.
Create Verification Request:
ZKP.EthersV6.TransactionVerification.create(txId, 20)
creates a verification request for a BTC transaction with ID txId
over EVM whose chain ID is 20
(Elastos ESC mainnet).
Check Submission Status:
verification.isSubmitted()
checks if the verification request has been previously submitted.
Provider and Signer Setup:
new ethers.BrowserProvider(window.ethereum)
creates a provider using the user's MetaMask wallet.provider.getSigner()
retrieves the signer's account.
Status Subscription:
verification.status$.subscribe(...)
subscribes to status updates of the verification request and logs the new status to the console.
Submit Verification Request:
verification.submitVerificationRequest(signer)
submits the verification request using the signer's account.