Skip to content

Commit 131a71a

Browse files
committed
Update README of client
1 parent fd2d98d commit 131a71a

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

mithril-client/README.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,63 @@
1-
# Mithril Client
1+
# Mithril-client ![crates.io](https://img.shields.io/crates/v/mithril-client.svg) [![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](LICENSE-APACHE) [![Discord](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square)](https://discord.gg/5kaErDKDRq)
22

3-
## Documentation
4-
:rocket: The documentation is available at [`Mithril client library`](https://mithril.network/doc/next/manual/developer-docs/nodes/mithril-client-library) with Mithril
3+
**This is a work in progress** 🛠
54

6-
:bulb: A guide on how to [`Bootstrap a Cardano Node`](https://mithril.network/doc/manual/getting-started/bootstrap-cardano-node) with Mithril
5+
* `mithril-client` defines all the tooling necessary to manipulate Mithril certified types available from a Mithril aggregator.
6+
7+
* The different types of available data certified by Mithril are:
8+
* Snapshot: list, get and download tarball.
9+
* Mithril stake distribution: list and get.
10+
* Certificate: list, get, and chain validation.
11+
12+
## Example
13+
14+
Below is a basic example of how to use most of the functions exposed by the Mithril client library:
15+
16+
```rust
17+
use mithril_client::{ClientBuilder, MessageBuilder};
18+
use std::path::Path;
19+
20+
#[tokio::main]
21+
async fn main() -> mithril_client::MithrilResult<()> {
22+
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
23+
24+
let snapshots = client.snapshot().list().await?;
25+
26+
let last_digest = snapshots.first().unwrap().digest.as_ref();
27+
let snapshot = client.snapshot().get(last_digest).await?.unwrap();
28+
29+
let certificate = client
30+
.certificate()
31+
.verify_chain(&snapshot.certificate_hash)
32+
.await?;
33+
34+
// Note: the directory must already exist, and the user running this code must have read/write access to it.
35+
let target_directory = Path::new("YOUR_TARGET_DIRECTORY");
36+
client
37+
.snapshot()
38+
.download_unpack(&snapshot, target_directory)
39+
.await?;
40+
41+
let message = MessageBuilder::new()
42+
.compute_snapshot_message(&certificate, target_directory)
43+
.await?;
44+
assert!(certificate.match_message(&message));
45+
46+
Ok(())
47+
}
48+
```
49+
50+
## Getting Help
51+
First, check our [Developer documentation](https://mithril.network/doc/manual/developer-docs/nodes/mithril-client-library).
52+
53+
If you need more information, feel free to join IOG's Technical Community [discord server](https://discord.gg/5kaErDKDRq).
54+
55+
## Contributing
56+
57+
Thanks for considering contributing and help us on creating the Mithril protocol!
58+
59+
The best way to contribute right now is to try things out and provide feedback,
60+
but we also accept contributions to the documentation and obviously to the
61+
code itself.
62+
63+
When contributing to this project and interacting with others, please follow our [Code of Conduct](https://github.com/input-output-hk/mithril/blob/main/CODE-OF-CONDUCT.md) and our [Contributing Guidelines](https://github.com/input-output-hk/mithril/blob/main/CONTRIBUTING.md).

0 commit comments

Comments
 (0)