@raicholime.near [Posted on Developer DAO Board](https://near.social/#/devgovgigs.near/widget/Post?id=455) ## Idea: NEAR Local execution of view calls with LAKE Indexer This discussion is a reference to https://near.social/#/devgovgigs.near/widget/Post?id=119 for the implementation of a TS Light Client. **NEAR Local execution of view calls with LAKE Indexer** **Phase 1:** 1. Compile near-lake-rs to WASM 1. Won’t be that straightforward, may need to alter the code. 2. Rust Lake is preferred over JS Lake for performance reasons. JS framework can be used if near-lake-rs can’t be compiled to WASM 2. Create a NEAR LAKE Indexer which will be able to: - Track account state changes, transaction outcomes, etc. - Store recent state in-memory - Prune older or irrelevant state to free up memory - Option to use browser storage as persistent storage (maybe) - Compile to WASM 3. Integrate indexer into near-api-js 1. Can be added as opt-in config parameter 2. Pre-RPC-request checks: 3. Add following checks before sending a RPC request (more can be added, these are just first line thoughts): 1. Check if state key is tracked: 1. If tracked see if it’s available for queried block height (if it’s not already available) 1. If available - return it 2. If not available - wait for indexer to pick it up (0.2-2.2 seconds delay) 2. Query RPC server only if state isn’t tracked 4. Add following criteria to add state key for tracking: 1. If it’s the user’s address 2. If key has been queried more than twice in last 1 minute (*frequency is up for discussion*) 3. More query patterns can be added here **Questions**: - Who’s to pay for the indexer operation? **Phase 2:** This will require further research and community feedback **Estimate (Phase 1)**: - 2 - 3 months ( 1FTE with experience in Rust, WASM, Typescript; 0.5 FTE TL & PM combined) Disclaimer: The purpose of the proposal above is to gather feedback on the implementation. As the scope might potentially change this version is not final, thus a specific funding request will be submitted upon finalisation of this proposal.