Skip to main content

polyoxide_relay/
lib.rs

1//! # polyoxide-relay
2//!
3//! Gasless transaction relay client for Polymarket's Safe and Proxy wallet infrastructure.
4//!
5//! This crate enables submitting on-chain transactions through Polymarket's relayer service,
6//! which pays gas fees on behalf of users. It supports two wallet types:
7//!
8//! - **Safe wallets** — Gnosis Safe multisig contracts (must be deployed before first use)
9//! - **Proxy wallets** — lightweight proxy contracts that auto-deploy on first transaction
10//!
11//! ## Authentication
12//!
13//! Relay operations require a private key for EIP-712 transaction signing and one of
14//! two authentication schemes for relay submission:
15//!
16//! - **Builder API credentials** — HMAC-SHA256 signed headers (`BUILDER_API_KEY`,
17//!   `BUILDER_SECRET`, `BUILDER_PASS_PHRASE`)
18//! - **Relayer API keys** — static headers (`RELAYER_API_KEY`, `RELAYER_API_KEY_ADDRESS`),
19//!   a simpler alternative
20//!
21//! ## Example
22//!
23//! ```no_run
24//! use polyoxide_relay::{RelayClient, BuilderAccount, BuilderConfig};
25//!
26//! # async fn example() -> Result<(), polyoxide_relay::RelayError> {
27//! let config = BuilderConfig::new("key".into(), "secret".into(), None);
28//! let account = BuilderAccount::new("0xprivatekey...", Some(config))?;
29//! let client = RelayClient::from_account(account)?;
30//!
31//! let latency = client.ping().await?;
32//! println!("Relay API latency: {}ms", latency.as_millis());
33//! # Ok(())
34//! # }
35//! ```
36
37#[cfg(doctest)]
38#[doc = include_str!("../README.md")]
39struct ReadmeDoctests;
40
41mod client;
42mod config;
43mod error;
44mod types;
45
46pub use client::RelayClient;
47pub use config::{AuthConfig, BuilderConfig, ContractConfig, RelayerApiKeyConfig};
48pub use error::RelayError;
49pub use types::{
50    RelayerApiKey, RelayerTransaction, SafeTransaction, SafeTx, SubmitResponse, TransactionRequest,
51    WalletType,
52};
53
54mod account;
55
56pub use account::BuilderAccount;
57
58#[cfg(feature = "keychain")]
59pub use account::{
60    save_builder_config_to_keychain, save_private_key_to_keychain, KEYCHAIN_SERVICE,
61};