Skip to content

Commit 66d0908

Browse files
committed
add FAQs
1 parent e322b4b commit 66d0908

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,16 @@ A special devnet has been created for previewing smart escrows with ZK verificat
5050
- RPC - wss://groth5.devnet.rippletest.net:51233
5151
- Faucet - http://groth5-faucet.devnet.rippletest.net
5252

53-
The easiest way to deploy to this devnet is to use the [provided web UI](https://boundless-xyz.github.io/xrpl-risc0-starter/) but you can also build your own web integrations using xrpl.js. If using XRPL.js you MUST use the version [4.5.0-smartescrow.4](https://www.npmjs.com/package/xrpl/v/4.5.0-smartescrow.4)
53+
The easiest way to deploy to this devnet is to use the [provided web UI](https://boundless-xyz.github.io/xrpl-risc0-starter/)!
54+
55+
1. Connect to the groth5 devnet and generate/fund a new account
56+
2. Using the web UI upload your escrow binary (./target/wasm32v1-none/release/escrow.wasm) using the upload file tab
57+
3. Deploy an escrow using the Deploy WASM tab
58+
4. Generate a valid proof to finish the escrow (e.g. `just prove 13 11`) and copy the memo JSON
59+
5. Use the Advanced Options under Finish Escrow to submit a finish transaction with the memo
60+
5. If the proof is valid your escrow should finish and the recipient receive their funds
61+
62+
You can also build your own web integrations using [xrpl.js](https://js.xrpl.org/). If using xrpl.js you MUST use the version [4.5.0-smartescrow.4](https://www.npmjs.com/package/xrpl/v/4.5.0-smartescrow.4)
5463

5564
> [!IMPORTANT]
5665
> Do not try and deploy ZK smart escrows to the regular devnet it won't work.
@@ -79,3 +88,25 @@ This requires you build the docker image first with `just build-docker`.
7988

8089
> [!NOTE]
8190
> The tests will automatically teardown the devnet container upon completion. If the tests are interrupted this doesn't happen. You may need to manually kill the container if you see an error like: `Bind for 0.0.0.0:5005 failed: port is already allocated`
91+
92+
## FAQs
93+
94+
#### Can XRPL escrows store data/state?
95+
96+
Sort of. You can set the data field of an escrow at deployment time and read this from within the escrow code. You cannot change this data after deployment.
97+
98+
#### Can XRPL escrows read state from other LedgerObjects?
99+
100+
Yes. Using [xrpl-wasm-stdlib](https://crates.io/crates/xrpl-wasm-stdlib) you can call `cache_ledger_obj` to load an object from the XRPL state into the Wasm cache and then `get_ledger_obj_field` to read its fields. This uses low-level operations and is experimental at this time.
101+
102+
#### Is it possible to a smart escrow to change the amount/recipient or do partial withdrawals
103+
104+
No. An escrow needs its amount and recipient set at deployment time. It is then a boolean operation, an escrow either finishes and delivers all of its held funds to its recipient, or does not finish.
105+
106+
#### Can smart escrow functionality be used in tandem with regular escrow functionality?
107+
108+
Partially yes. In particular you can use the fields `"CancelAfter"` and `"FinishAfter"` on the deploy transaction (use the custom fields in the UI) to set XRPL timestamps for when an escrow can be cancelled or finished without requiring its finish function to execute.
109+
110+
#### What can you prove in a zkVM?
111+
112+
You would be amazed what is possible. Check out some examples https://github.com/risc0/risc0/tree/main/examples

escrow/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use risc0_verifier_xrpl_wasm::{Proof, risc0};
77
use xrpl_wasm_stdlib::host::{Error, Result, Result::Err, Result::Ok};
88
use xrpl_wasm_stdlib::{core::locator::Locator, host::get_tx_nested_field, sfield};
99

10+
/// An escrow that can only be unlocked if the prover can demonstrate knowledge of the prime factors of 143 (11 and 13) without revealing them.
1011
#[unsafe(no_mangle)]
1112
pub extern "C" fn finish() -> i32 {
1213
// The size of the journal will change depending on how many bytes are written using `env::commit` in the guest.
@@ -15,6 +16,9 @@ pub extern "C" fn finish() -> i32 {
1516
// The seal will always be 256 bytes
1617
let seal: [u8; 256] = get_memo(1).unwrap();
1718

19+
let factored_number = u32::from_be_bytes(journal);
20+
assert_eq!(factored_number, 143); // 11 * 13 = 143
21+
1822
let proof = Proof::from_seal_bytes(&seal).unwrap();
1923
let journal_digest = risc0::hash_journal(&journal);
2024
risc0::verify(&proof, &bytemuck::cast(EXAMPLE_PROOF_ID), &journal_digest).unwrap();

0 commit comments

Comments
 (0)