| Crates.io | pivx_rpc_rs |
| lib.rs | pivx_rpc_rs |
| version | 0.1.1 |
| created_at | 2026-01-04 02:29:00.960031+00 |
| updated_at | 2026-01-04 02:29:00.960031+00 |
| description | A Rust library for interacting with PIVX Core via JSON-RPC |
| homepage | https://github.com/PIVX-Labs/pivx-rpc-rs |
| repository | https://github.com/PIVX-Labs/pivx-rpc-rs |
| max_upload_size | |
| id | 2021184 |
| size | 112,859 |
A Rust library for interacting with PIVX Core via JSON-RPC.
throttled_json_rpcAdd this to your Cargo.toml:
[dependencies]
pivx_rpc_rs = "0.1"
use pivx_rpc_rs::PivxRpcClient;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to PIVX Core node
let client = PivxRpcClient::new(
"http://127.0.0.1:51473".to_string(),
Some("rpcuser".to_string()),
Some("rpcpassword".to_string()),
3, // max parallel requests
10, // max retries
1000, // timeout (ms)
);
// Get blockchain info
let info = client.getblockchaininfo()?;
println!("Chain: {}", info.chain);
println!("Blocks: {}", info.blocks);
println!("Difficulty: {}", info.difficulty);
// Get best block
let best_hash = client.getbestblockhash()?;
let block = client.getblock(best_hash)?;
println!("Latest block has {} transactions", block.tx.len());
Ok(())
}
Your PIVX Core node must be running with RPC enabled. Configure it in pivx.conf:
server=1
rpcuser=your_username
rpcpassword=your_secure_password
rpcallowip=127.0.0.1
rpcport=51473
The library includes several examples demonstrating common use cases:
Run an example:
cargo run --example basic_usage
getbestblockhashgetblockgetblockchaininfogetblockcountgetblockhashgetblockheadercreaterawtransactiongetrawtransactiongettxoutsendrawtransactionsignrawtransactiondumpprivkeygetnewaddresssendtoaddressgetmasternodecountlistmasternodesrelaymasternodebroadcastgetstakingstatuslistcoldutxosdelegatoraddgetbudgetinfogetinfogetrawmempoolgetsupplyinfogenerate (regtest)All PIVX-specific data structures are fully typed:
Block, FullBlockTransaction, GetRawTransactionInfo, Vin, VoutMasternodeList, MasternodeCountPivxStatus, ColdUtxoBlockChainInfo, Softfork, UpgradesBudgetInfoMoneySupply, ShieldPoolValueSee the full documentation for details.
| PIVX Core | pivx-rpc-rs |
|---|---|
| 5.x | ✅ 0.1.x |
| 4.x | ⚠️ Partial |
This crate uses:
reqwest 0.9 (blocking mode) for HTTP requeststhrottled_json_rpc for RPC client implementationserde 1.0 for serializationNote: Due to dependency on throttled_json_rpc, this crate uses the older failure error handling crate. Future versions may migrate to anyhow or thiserror once the upstream dependency is updated.
Financial values (balances, amounts) use f64 for compatibility with PIVX Core's JSON-RPC responses. Be aware of floating-point precision limitations when handling monetary values.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This library is provided as-is. Always test thoroughly with small amounts before using in production, especially when dealing with private keys or sending transactions.
This library is provided as-is. Always test thoroughly with small amounts before using in production, especially when dealing with private keys or sending transactions.