Hello everyone,
I’m working on implementing ICRC-3 ledger in Rust and would like to get some guidance on the best way to approach this efficiently.
The ICRC-3 standard requires the ledger to:
- Certify the last block (tip) and expose it via
icrc3_get_tip_certificate
. - Provide a certificate that contains:
last_block_index
last_block_hash
I am considering using the ic-certification
crate to handle certification. Something like this:
let leaf1 = leaf(last_block_index.to_string());
let leaf2 = leaf(last_block_hash);
let hash_tree = fork(leaf1, leaf2);
ic_cdk::api::set_certified_data(&hash_tree.digest());
let certificate = ic_cdk::api::data_certificate().expect("No data certificate available");
Certificate {
tree: hash_tree,
signature: certificate,
delegation: None,
}
I also came across this implementation in the icp-icrc3-evm-adapter project:
However, I’m not sure I know a right way to do it, because the standard doesn’t define it in details. Has anyone implemented this in Rust? Would love to hear your thoughts on the best approach!
Thanks!