Crates.io | sn-trie-proofs |
lib.rs | sn-trie-proofs |
version | 0.1.1 |
source | src |
created_at | 2024-10-28 09:50:31.911131 |
updated_at | 2024-10-28 09:58:43.49605 |
description | Starknet Transaction Trie Proofs |
homepage | |
repository | https://github.com/HerodotusDev/trie-proofs.git |
max_upload_size | |
id | 1425417 |
size | 64,848 |
A comprehensive transaction/receipt inclusion proofs handler for Starknet trie. Tested with various versions including v0.12.3 ~ v 0.13.2. This library exposes various proof building functionalities, verification, trie construction etc.
Add dependency sn-trie-proofs
to your project:
sn-trie-proofs = { git = "https://github.com/HerodotusDev/trie-proofs.git" }
#[tokio::test]
async fn test_build_tx_tree_from_block_3() {
let mut handler = TxsMptHandler::new(PATHFINDER_URL).unwrap();
// # 0.13.1.1
let block_number = 70015;
handler
.build_tx_tree_from_block(block_number)
.await
.unwrap();
let proof = handler.get_proof(0).unwrap();
let membership: Membership = handler.verify_proof(0, proof).unwrap();
assert!(membership.is_member());
}
Currently we only supporting receipt trie after 0.13.2 version.
#[tokio::test]
async fn test_build_tx_tree_from_block_4() {
let mut handler = TxReceiptsMptHandler::new(PATHFINDER_URL).unwrap();
// # 0.13.2
let block_number = 99708;
handler
.build_tx_receipts_tree_from_block(block_number)
.await
.unwrap();
let proof = handler.get_proof(0).unwrap();
let membership: Membership = handler.verify_proof(0, proof).unwrap();
assert!(membership.is_member());
}
For trie implementation, this project depends on the sn-merkle-trie, code is mostly from pathfinder's merkle tree implementation.
For transaction and transaction receipt types, using types-rs.
sn-trie-proofs
is licensed under the GNU General Public License v3.0.
Herodotus Dev Ltd - 2024