Expand description
§Nad.fun SDK
A simple and efficient Rust SDK for Nad.fun trading and event monitoring.
§Core Features
- Trading: Buy/sell tokens with automatic routing (bonding curve ↔ DEX)
- Event Streaming: Real-time streaming and historical indexing
- API Client: Authenticated API access with session management
- Simple API: Two main modules -
Corefor trading,streamfor events
§Quick Start
ⓘ
use nadfun_sdk::{Core, Network};
use alloy::primitives::{Address, U256};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Initialize Core - set network once, used everywhere
let core = Core::new(
"https://your-rpc-url".to_string(),
"your-private-key".to_string(),
Network::Mainnet
).await?;
// Get quote and execute trade
let (router, amount_out) = core.get_amount_out(token, mon_amount, true).await?;
// Execute buy - returns tx_hash immediately (fast!)
let tx_hash = core.buy(buy_params, router).await?;
println!("Transaction submitted: {}", tx_hash);
// Optionally check receipt later
let receipt = core.get_receipt(tx_hash).await?;
println!("Confirmed: {}", receipt.status);
Ok(())
}Re-exports§
pub use api::ApiClient;pub use api::ALLOWED_IMAGE_TYPES;pub use constants::get_creator_manager;pub use constants::get_creator_treasury;pub use constants::get_current_network;pub use constants::set_network;pub use constants::Network;pub use core::estimate_gas;pub use core::Core;pub use core::GasEstimationParams;pub use core::Router;pub use core::SlippageUtils;pub use stream::BondingCurveEvent;pub use stream::CurveIndexer;pub use stream::CurveStream;pub use stream::DexIndexer;pub use stream::DexStream;pub use stream::EventType;pub use stream::PoolMetadata;pub use stream::SwapEvent;pub use token::TokenHelper;pub use types::*;
Modules§
- api
- Authenticated API client with session management
- constants
- Constants and contract addresses for the Nad.fun ecosystem
- core
- Core trading functionality including buy/sell operations and slippage calculations
- create
Deprecated - Token creation functionality (DEPRECATED)
- prelude
- Convenient prelude module for importing commonly used types and functions
- stream
- Real-time event streaming and historical data indexing
- token
- Token interaction utilities for ERC-20 operations
- types
- Type definitions for events, trading parameters, and API responses
Structs§
- Creator
Client - CreatorTreasury client for claiming creator rewards
- Pool
Discovery - Pool discovery helper for finding DEX pools
Functions§
- get_
pool_ addresses_ for_ tokens - Convenience function to get pool addresses for tokens paired with WMON