walletconnect_sdk/
lib.rs

1//! # walletconnect-sdk
2//!
3//! A Rust implementation of [WalletConnect specs](https://specs.walletconnect.com/2.0/).
4//!
5//! ## Features
6//! - Pairing using session settle
7//! - Types
8//!
9//! ## Example
10//! API for interacting with WalletConnect relay
11//!
12//! ```rust
13//! // Get project_id from https://cloud.reown.com
14//! let project_id = "xxxx";
15//!
16//! // Generate random once, store it in client and reuse it for all connections
17//! let client_seed = [123u8; 32];
18//!
19//! let conn = Connection::new(
20//!     "https://relay.walletconnect.org/rpc",
21//!     "https://relay.walletconnect.org",
22//!     project_id,
23//!     client_seed,  Metadata {
24//!         name: "My Wallet Name".to_string(),
25//!         description: "My wallet interacts with dapp".to_string(),
26//!         url: "https://my-wallet-site.com".to_string(),
27//!         icons: vec![],
28//!     },
29//! );
30//!
31//! let uri_from_dapp = "wc:e4b9eb7a1372bf88abc46c37acac3687301afdfd0d2a4c2355945d66a1164464@2?relay-protocol=irn&symKey=d7430284e1b70853829a010518a088cde0e163bcad5f24425e3b17578b2b402d&expiryTimestamp=1749783095&methods=wc_sessionAuthenticate";
32//!
33//! let (mut pairing, _) = conn
34//!     .init_pairing(uri_from_dapp)
35//!     .await
36//!     .expect("pairing failed");
37//!
38//! pairing
39//!     .approve_with_session_settle(
40//!         // Address of the wallet that is connecting to dApp
41//!         "0x0000000000000000000000000000000000000123"
42//!             .parse()
43//!             .unwrap(),
44//!     )
45//!     .await
46//!     .expect("approve failed");
47//!
48//! loop {
49//!     let result =
50//!         pairing.watch_messages(Topic::Derived, None).await.unwrap();
51//!
52//!     println!("result: {result:?}");
53//! }
54//! ```
55//!
56//! ## License
57//! MIT OR Apache-2.0
58
59pub mod cacao;
60pub mod connection;
61pub mod constants;
62pub mod error;
63pub mod message;
64pub mod pairing;
65pub mod relay_auth;
66pub mod types;
67pub mod utils;
68pub mod wc_message;
69
70/// Exposed for easy access
71pub use connection::Connection;
72pub use error::Error;
73pub(crate) use error::Result;
74pub use pairing::Pairing;