Passa al contenuto principale

Avvio Rapido

Avvia un nodo Savitri locale e invia la tua prima transazione in meno di 5 minuti.

1. Genera le Chiavi

# Generate a node keypair
cargo run -p savitri-sdk --bin key_generator

Questo produce una coppia di chiavi ed25519:

  • Chiave privata: 64 caratteri esadecimali (32 byte) -- tienila segreta
  • Chiave pubblica: 64 caratteri esadecimali (32 byte) -- questo è il tuo indirizzo

2. Avvia un Lightnode

cargo run -p savitri-lightnode --bin lightnode -- \
--listen-port 4001 \
--tx-interval-secs 2 \
--block-interval-secs 10 \
--max-block-txs 32

Il lightnode inizia ad ascoltare sulla porta 4001 (P2P) e 8545 (RPC).

3. Verifica lo Stato del Nodo

curl -X POST http://localhost:8545/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "savitri_health",
"params": [],
"id": 1
}'

Risposta:

{
"jsonrpc": "2.0",
"result": {
"status": "ok",
"service": "savitri-rpc",
"mode": "lightnode"
},
"id": 1
}

4. Ottieni l'Altezza del Blocco

curl -X POST http://localhost:8545/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "savitri_blockNumber",
"params": [],
"id": 2
}'

5. Verifica il Saldo dell'Account

curl -X POST http://localhost:8545/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "savitri_getAccount",
"params": ["YOUR_ADDRESS_HEX_64_CHARS"],
"id": 3
}'

6. Richiedi Token Testnet (Faucet)

Sul testnet, richiedi token SAVT gratuiti:

curl -X POST http://localhost:8545/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "savitri_faucetClaim",
"params": ["YOUR_ADDRESS_HEX_64_CHARS"],
"id": 4
}'

Risposta:

{
"jsonrpc": "2.0",
"result": {
"result": {
"tx_hash": "0x...",
"amount": "5000000000000000000"
}
},
"id": 4
}

Il faucet eroga 5 SAVT per richiesta con un tempo di attesa di 24 ore.

7. Utilizzo dell'SDK (Rust)

Aggiungi al tuo Cargo.toml:

[dependencies]
savitri-sdk = { path = "../savitri-sdk" }
tokio = { version = "1", features = ["full"] }
use savitri_sdk::{RpcClient, Wallet, TransactionBuilder};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = RpcClient::from_url("http://localhost:8545")?;

// Health check
let health = client.health().await?;
println!("Node mode: {}", health.mode);

// Block height
let height = client.get_block_number().await?;
println!("Block height: {}", height);

// Create wallet and check balance
let wallet = Wallet::new();
let account = client.get_account(wallet.address()).await?;
println!("Address: {}", wallet.address());
println!("Balance: {}", account.balance);

Ok(())
}

Passi Successivi