Skip to content

Commit 6fa911f

Browse files
committed
Add usage examples to main README
1 parent 34d1ac6 commit 6fa911f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,37 @@ Finally, a convenient CLI is provided to demonstrate example usage:
2222

2323
- [xrpl_cli](xrpl_cli/)
2424

25+
## Usage
26+
27+
### JSONRPC Client example
28+
29+
```rust
30+
let client = Client::new();
31+
32+
let account = env::var("XRPL_ACCOUNT_ADDRESS").expect("account not defined");
33+
34+
let req = AccountTxRequest::new(&account).limit(5);
35+
let resp = client.call(req).await;
36+
37+
dbg!(&resp);
38+
```
39+
40+
### WebSocket Client example
41+
42+
```rust
43+
let mut client = Client::connect(DEFAULT_WS_URL)
44+
.await
45+
.expect("cannot connect");
46+
47+
let req = AccountInfoRequest::new("r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59").strict(true);
48+
49+
client.call(req).await.expect("cannot send request");
50+
51+
if let Some(msg) = client.messages.next().await {
52+
dbg!(&msg);
53+
}
54+
```
55+
2556

2657
## Links
2758

0 commit comments

Comments
 (0)