Skip to main content

r402_hedera/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![cfg_attr(
3    test,
4    allow(
5        unknown_lints,
6        clippy::unused_async_trait_impl,
7        reason = "in-crate mock impls of AFIT traits have no .await"
8    )
9)]
10
11//! Hedera chain support for the x402 payment protocol.
12//!
13//! This crate implements the x402 `"exact"` scheme for Hedera: the buyer
14//! signs a `TransferTransaction` that credits `payTo`, and a facilitator
15//! fee payer submits it after Mirror Node preflight.
16//!
17//! # Features
18//!
19//! - **CAIP-2 Addressing**: `hedera:mainnet` and `hedera:testnet`
20//! - **HBAR and HTS**: native tinybars (`0.0.0`) and USDC token ids
21//! - **Fee-payer sponsorship**: `extra.feePayer` is copied from `/supported`
22//! - **In-process facilitator**: verify and settle via Hiero SDK
23//!
24//! # Feature Flags
25//!
26//! - `server` — server-side price tag generation
27//! - `client` — client-side transfer signing
28//! - `facilitator` — facilitator-side payment verification and settlement
29//! - `telemetry` — `tracing` instrumentation
30
31#[cfg(not(any(feature = "client", feature = "facilitator")))]
32use base64 as _;
33#[cfg(feature = "telemetry")]
34use tracing_core as _;
35
36#[cfg(test)]
37mod unused_dev_deps {
38    #[cfg(not(feature = "facilitator"))]
39    use reqwest as _;
40    #[cfg(not(any(feature = "client", feature = "facilitator")))]
41    use tokio as _;
42    #[cfg(not(feature = "facilitator"))]
43    use wiremock as _;
44}
45
46pub mod chain;
47pub mod exact;
48
49mod networks;
50#[cfg(any(feature = "client", feature = "facilitator"))]
51pub use chain::inspect_hedera_transaction;
52#[cfg(feature = "facilitator")]
53pub use chain::{HederaChainProvider, HederaFeePayer, HederaMirrorClient};
54pub use exact::HederaExact;
55#[cfg(feature = "client")]
56pub use exact::client::{HederaExactClient, HederaSigner};
57#[cfg(feature = "facilitator")]
58pub use exact::facilitator::{AliasPolicy, HederaExactFacilitator, HederaExactFacilitatorConfig};
59pub use networks::*;