Asking a node for a balance is trusting the node. Two calls trade that trust for a Merkle proof that closes against a verified header — without downloading the state.
This applies to any consumer that does not run its own node: wallet, point-of-sale terminal, dashboard.
The difference between the three stances below is the whole difference between trusting and verifying.
Order matters: the root has to come from outside the answer you want to verify.
The method fetches the block, recomputes the hash and checks integrity before returning the stateRoot. A node cannot forge a block whose hash and signatures close.
// 1) a raiz vem do HEADER, e o header é verificado antes de ser usado:
// hash recalculada + assinatura do produtor conferida localmente
let raiz = cliente.raiz_confiavel_do_header("latest")?;The proof is checked locally. If the root the node asserts in /proof differs from the one you brought, the call fails with ProvaInvalida instead of returning a number.
// 2) o saldo chega com a prova de Merkle e é conferido CONTRA essa raiz
let saldo = cliente.saldo_provado("E7A4B2…9F21", Some(&raiz))?;
println!("saldo PROVADO: {saldo} e7");encodedAccount carries big integers as prefixed text; path is the route to the root. The SDK handles decoding — recovering the wrong tag would reject every valid proof.
curl -s https://eavscan.com/proof/E7A4B2…9F21 -H 'Accept: application/json'
{
"stateRoot": "e7c41f…",
"encodedAccount": { "balance": "B12500000", "nonce": 41, … },
"path": [ { "hash": "a91c…", "right": true }, … ]
}// SEM a raiz do header, a prova fecha contra a raiz que o PRÓPRIO nó afirmou:
// pega inconsistência interna, não um nó que minta raiz e saldo de forma coerente.
let saldo = cliente.saldo_provado("E7A4B2…9F21", None)?;An account proof proves an account, at a height. It is not a substitute for syncing the chain.
1 200 000Below this height blocks carry no stateRoot and the method refuses rather than inventing a root.| Error | When it happens |
|---|---|
ErroCliente::ProvaInvalida | The path does not lead to the root, or the node's root differs from the one you required. Treat it as a hostile answer. |
ErroCliente::Resposta | The proof arrived without stateRoot, encodedAccount or path — a malformed response. |
ErroCliente::Api | The node answered with an HTTP error; 404 means the account does not exist. |
Status, account and proved balance in a single run.
cargo run -p eav7-sdk --example consulta -- \ https://eavscan.com E7A4B2…9F21