pub struct AptosConfig { /* private fields */ }Expand description
Configuration for the Aptos client.
Use the builder methods to customize the configuration, or use one of the
preset configurations like AptosConfig::mainnet(), AptosConfig::testnet(),
or AptosConfig::devnet().
§Example
use aptos_sdk::AptosConfig;
use aptos_sdk::retry::RetryConfig;
use aptos_sdk::config::PoolConfig;
// Use testnet with default settings
let config = AptosConfig::testnet();
// Custom configuration with retry and connection pooling
let config = AptosConfig::testnet()
.with_timeout(std::time::Duration::from_secs(30))
.with_retry(RetryConfig::aggressive())
.with_pool(PoolConfig::high_throughput());Implementations§
Source§impl AptosConfig
impl AptosConfig
Sourcepub fn mainnet() -> Self
pub fn mainnet() -> Self
Creates a configuration for Aptos mainnet.
§Example
use aptos_sdk::AptosConfig;
let config = AptosConfig::mainnet();Sourcepub fn testnet() -> Self
pub fn testnet() -> Self
Creates a configuration for Aptos testnet.
§Example
use aptos_sdk::AptosConfig;
let config = AptosConfig::testnet();Sourcepub fn devnet() -> Self
pub fn devnet() -> Self
Creates a configuration for Aptos devnet.
§Example
use aptos_sdk::AptosConfig;
let config = AptosConfig::devnet();Sourcepub fn local() -> Self
pub fn local() -> Self
Creates a configuration for a local development network.
This assumes the local network is running on the default ports (REST API on 8080, faucet on 8081).
§Example
use aptos_sdk::AptosConfig;
let config = AptosConfig::local();Sourcepub fn custom(fullnode_url: &str) -> AptosResult<Self>
pub fn custom(fullnode_url: &str) -> AptosResult<Self>
Creates a custom configuration with the specified fullnode URL.
§Security
Only http:// and https:// URL schemes are allowed. Using https:// is
strongly recommended for production. HTTP is acceptable only for localhost
development environments.
§Errors
Returns an error if the fullnode_url cannot be parsed as a valid URL
or uses an unsupported scheme (e.g., file://, ftp://).
§Example
use aptos_sdk::AptosConfig;
let config = AptosConfig::custom("https://my-node.example.com/v1").unwrap();Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets the request timeout.
Sourcepub fn with_retry(self, retry_config: RetryConfig) -> Self
pub fn with_retry(self, retry_config: RetryConfig) -> Self
Sets the retry configuration for transient failures.
§Example
use aptos_sdk::AptosConfig;
use aptos_sdk::retry::RetryConfig;
let config = AptosConfig::testnet()
.with_retry(RetryConfig::aggressive());Sourcepub fn without_retry(self) -> Self
pub fn without_retry(self) -> Self
Disables automatic retry for API calls.
This is equivalent to with_retry(RetryConfig::no_retry()).
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Sets the maximum number of retries for transient failures.
This is a convenience method that modifies the retry config.
Sourcepub fn with_pool(self, pool_config: PoolConfig) -> Self
pub fn with_pool(self, pool_config: PoolConfig) -> Self
Sets the connection pool configuration.
§Example
use aptos_sdk::AptosConfig;
use aptos_sdk::config::PoolConfig;
let config = AptosConfig::testnet()
.with_pool(PoolConfig::high_throughput());Sourcepub fn with_api_key(self, api_key: impl Into<String>) -> Self
pub fn with_api_key(self, api_key: impl Into<String>) -> Self
Sets an API key for authenticated access.
This is useful when using Aptos Build or other services that provide higher rate limits with API keys.
Sourcepub fn with_indexer_url(self, url: &str) -> AptosResult<Self>
pub fn with_indexer_url(self, url: &str) -> AptosResult<Self>
Sourcepub fn with_faucet_url(self, url: &str) -> AptosResult<Self>
pub fn with_faucet_url(self, url: &str) -> AptosResult<Self>
Sourcepub fn fullnode_url(&self) -> &Url
pub fn fullnode_url(&self) -> &Url
Returns the fullnode URL.
Sourcepub fn indexer_url(&self) -> Option<&Url>
pub fn indexer_url(&self) -> Option<&Url>
Returns the indexer URL, if configured.
Sourcepub fn faucet_url(&self) -> Option<&Url>
pub fn faucet_url(&self) -> Option<&Url>
Returns the faucet URL, if configured.
Sourcepub fn retry_config(&self) -> &RetryConfig
pub fn retry_config(&self) -> &RetryConfig
Returns the retry configuration.
Sourcepub fn pool_config(&self) -> &PoolConfig
pub fn pool_config(&self) -> &PoolConfig
Returns the connection pool configuration.
Trait Implementations§
Source§impl Clone for AptosConfig
impl Clone for AptosConfig
Source§fn clone(&self) -> AptosConfig
fn clone(&self) -> AptosConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more