pub struct RelayClient { /* private fields */ }Expand description
Client for submitting gasless transactions through Polymarket’s relayer service.
Supports both Safe and Proxy wallet types. Handles EIP-712 transaction signing, nonce management, and multi-send batching automatically.
Implementations§
Source§impl RelayClient
impl RelayClient
Sourcepub fn new(
private_key: impl Into<String>,
config: Option<BuilderConfig>,
) -> Result<Self, RelayError>
pub fn new( private_key: impl Into<String>, config: Option<BuilderConfig>, ) -> Result<Self, RelayError>
Create a new Relay client with authentication
Sourcepub fn builder() -> Result<RelayClientBuilder, RelayError>
pub fn builder() -> Result<RelayClientBuilder, RelayError>
Create a new Relay client builder
Sourcepub fn default_builder() -> Result<RelayClientBuilder, RelayError>
pub fn default_builder() -> Result<RelayClientBuilder, RelayError>
Create a new Relay client builder pulling settings from environment
Sourcepub fn from_account(account: BuilderAccount) -> Result<Self, RelayError>
pub fn from_account(account: BuilderAccount) -> Result<Self, RelayError>
Create a new Relay client from a BuilderAccount
Sourcepub fn address(&self) -> Option<Address>
pub fn address(&self) -> Option<Address>
Returns the signer’s Ethereum address, or None if no account is configured.
Sourcepub async fn ping(&self) -> Result<Duration, RelayError>
pub async fn ping(&self) -> Result<Duration, RelayError>
Measure the round-trip time (RTT) to the Relay API.
Makes a GET request to the API base URL and returns the latency.
§Example
use polyoxide_relay::RelayClient;
let client = RelayClient::builder()?.build()?;
let latency = client.ping().await?;
println!("API latency: {}ms", latency.as_millis());Sourcepub async fn get_nonce(&self, address: Address) -> Result<u64, RelayError>
pub async fn get_nonce(&self, address: Address) -> Result<u64, RelayError>
Fetch the current transaction nonce for an address from the relayer.
Sourcepub async fn get_transaction(
&self,
transaction_id: &str,
) -> Result<TransactionStatusResponse, RelayError>
pub async fn get_transaction( &self, transaction_id: &str, ) -> Result<TransactionStatusResponse, RelayError>
Query the status of a previously submitted relay transaction.
Sourcepub async fn get_deployed(
&self,
safe_address: Address,
) -> Result<bool, RelayError>
pub async fn get_deployed( &self, safe_address: Address, ) -> Result<bool, RelayError>
Check whether a Safe wallet has been deployed on-chain.
Sourcepub fn get_expected_safe(&self) -> Result<Address, RelayError>
pub fn get_expected_safe(&self) -> Result<Address, RelayError>
Derive the expected Safe wallet address for the configured account via CREATE2.
Sourcepub fn get_expected_proxy_wallet(&self) -> Result<Address, RelayError>
pub fn get_expected_proxy_wallet(&self) -> Result<Address, RelayError>
Derive the expected Proxy wallet address for the configured account via CREATE2.
Sourcepub async fn get_relay_payload(
&self,
address: Address,
) -> Result<(Address, u64), RelayError>
pub async fn get_relay_payload( &self, address: Address, ) -> Result<(Address, u64), RelayError>
Get relay payload for PROXY wallets (returns relay address and nonce)
Sourcepub async fn execute(
&self,
transactions: Vec<SafeTransaction>,
metadata: Option<String>,
) -> Result<RelayerTransactionResponse, RelayError>
pub async fn execute( &self, transactions: Vec<SafeTransaction>, metadata: Option<String>, ) -> Result<RelayerTransactionResponse, RelayError>
Sign and submit transactions through the relayer with default gas settings.
Sourcepub async fn execute_with_gas(
&self,
transactions: Vec<SafeTransaction>,
metadata: Option<String>,
gas_limit: Option<u64>,
) -> Result<RelayerTransactionResponse, RelayError>
pub async fn execute_with_gas( &self, transactions: Vec<SafeTransaction>, metadata: Option<String>, gas_limit: Option<u64>, ) -> Result<RelayerTransactionResponse, RelayError>
Sign and submit transactions through the relayer with an optional gas limit override.
For Safe wallets, transactions are batched via MultiSend. For Proxy wallets, they are encoded into the proxy’s calldata format.
Sourcepub async fn estimate_redemption_gas(
&self,
condition_id: [u8; 32],
index_sets: Vec<U256>,
) -> Result<u64, RelayError>
pub async fn estimate_redemption_gas( &self, condition_id: [u8; 32], index_sets: Vec<U256>, ) -> Result<u64, RelayError>
Estimate gas required for a redemption transaction.
Returns the estimated gas limit with relayer overhead and safety buffer included. Uses the default RPC URL configured for the current chain.
§Arguments
condition_id- The condition ID to redeemindex_sets- The index sets to redeem
§Example
use polyoxide_relay::{RelayClient, BuilderAccount, BuilderConfig, WalletType};
use alloy::primitives::{U256, hex};
let builder_config = BuilderConfig::new(
"key".to_string(),
"secret".to_string(),
None,
);
let account = BuilderAccount::new("0x...", Some(builder_config))?;
let client = RelayClient::builder()?
.with_account(account)
.wallet_type(WalletType::Proxy)
.build()?;
let condition_id = [0u8; 32];
let index_sets = vec![U256::from(1)];
let estimated_gas = client
.estimate_redemption_gas(condition_id, index_sets)
.await?;
println!("Estimated gas: {}", estimated_gas);Sourcepub async fn submit_gasless_redemption(
&self,
condition_id: [u8; 32],
index_sets: Vec<U256>,
) -> Result<RelayerTransactionResponse, RelayError>
pub async fn submit_gasless_redemption( &self, condition_id: [u8; 32], index_sets: Vec<U256>, ) -> Result<RelayerTransactionResponse, RelayError>
Submit a gasless CTF position redemption without gas estimation.
Sourcepub async fn submit_gasless_redemption_with_gas_estimation(
&self,
condition_id: [u8; 32],
index_sets: Vec<U256>,
estimate_gas: bool,
) -> Result<RelayerTransactionResponse, RelayError>
pub async fn submit_gasless_redemption_with_gas_estimation( &self, condition_id: [u8; 32], index_sets: Vec<U256>, estimate_gas: bool, ) -> Result<RelayerTransactionResponse, RelayError>
Submit a gasless CTF position redemption, optionally estimating gas first.
When estimate_gas is true, simulates the redemption against the configured
RPC endpoint to determine a safe gas limit before submission.
Trait Implementations§
Source§impl Clone for RelayClient
impl Clone for RelayClient
Source§fn clone(&self) -> RelayClient
fn clone(&self) -> RelayClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RelayClient
impl !RefUnwindSafe for RelayClient
impl Send for RelayClient
impl Sync for RelayClient
impl Unpin for RelayClient
impl UnsafeUnpin for RelayClient
impl !UnwindSafe for RelayClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more