메인 콘텐츠로 건너뛰기

Light Client

LightClient는 기본적인 체인 조회와 트랜잭션 전송만 필요한 경량 소비자를 위한 간소화된 API를 제공합니다.

설정

use savitri_sdk::LightClient;

let client = LightClient::new("http://localhost:8545")?;

API

// Connection check
let connected: bool = client.is_connected().await;

// Health
let health = client.health().await?;
println!("{} - {}", health.mode, health.status);

// Block height
let height: u64 = client.get_block_number().await?;

// Block by height
let block = client.get_block(42).await?;

// Account info
let account = client.get_account("address_hex").await?;
println!("Balance: {}, Nonce: {}", account.balance, account.nonce);

// Balance only
let balance: String = client.get_balance("address_hex").await?;

// Submit transaction
let result = client.send_raw_transaction("signed_tx_hex").await?;
println!("TX hash: {}", result.tx_hash);

// PoU status
let pou = client.pou_local().await?;

LightClient와 RpcClient 비교

기능LightClientRpcClient
상태/핑
블록 조회높이 + 높이별 조회모든 블록 메서드
계정 조회잔액 + 계정잔액, 논스, 토큰
트랜잭션raw 전송raw 전송 + 조회 + 영수증
PoU로컬만로컬, 피어, 그룹, masternode
멤풀아니요크기, 상태, 대기 중
토큰아니요정보, 잔액, 전송
배치 요청아니요
raw JSON-RPC아니요예 (call_raw)

단순한 통합에는 LightClient를 사용하세요. 전체 API 표면이 필요할 때는 RpcClient를 직접 사용하세요. 고급 작업을 위해 client.rpc()를 통해 내부 RpcClient에 접근할 수 있습니다.