Solana - SPL Initialized Account
SPL Initialized Account Foundational Store
Overview
Consuming Account Owner Data
use substreams::store::FoundationalStore;
use std::collections::HashSet;
#[substreams::handlers::map]
fn map_spl_instructions(
params: String,
transactions: SolanaTransactions,
foundational_store: FoundationalStore,
) -> Result<SplInstructions, Error> {
// ... extract transfer instructions from transactions
// Collect account addresses that need owner lookup
let mut accounts_to_lookup = HashSet::<String>::new();
accounts_to_lookup.insert(transfer.from.clone());
accounts_to_lookup.insert(transfer.to.clone());
// Convert addresses to bytes and query store
let account_bytes: Vec<Vec<u8>> = accounts_to_lookup
.iter()
.filter_map(|addr| bs58::decode(addr).into_vec().ok())
.collect();
let resp = foundational_store.get(&account_bytes);
// Process responses and decode owner data
for queried_entry in resp.entries {
if queried_entry.code != ResponseCode::Found as i32 {
continue;
}
let Some(entry) = &queried_entry.entry else { continue; };
let Some(value) = &entry.value else { continue; };
let Ok(account_owner) = AccountOwner::decode(value.value.as_slice()) else {
continue;
};
// Use owner data to enrich transfers
let owner_b58 = bs58::encode(&account_owner.owner).into_string();
transfer.from_owner = owner_b58;
}
Ok(SplInstructions { instructions })
}Data Model
Key Structure
Value Schema
Implementation details
Implementation
Creating Foundational Store Entries
Substreams Manifest Configuration
Related Resources
Last updated
Was this helpful?

