Reading From Indexes/External Tables
Learn how Zephyr programs can access publicly indexed data.
Last updated
Learn how Zephyr programs can access publicly indexed data.
Last updated
Zephyr tables are by default shareable across programs.
Note that when pricing kicks off creators of certain tables will be able to manage how their tables are accessed with custom rules.
This functionality allows any program or Custom Dashboards to access already indexed + live-updated data on Mercury. As seen in Zephyr.toml Extentions, creators can share their tables with the community and significantly simplify the work for othr users. All the needed data to access an already existing public table can be found in the Community Indexes section of the app.
By selecting the desired index, it's possible to copy the table struct to paste in the program that needs to access it.
Let's make things practical and jump straight to an example. This code returns all indexed Blend Mainnet borrowed operations for a given pool:
The key here is the attribute
Which tells the compiler (and then the ZephyrVM) that you're reading from the borrowed
table created by id 35 (in this case, blend's Mainnet deployment).
This function can be easily called through:
The result will be a list of all the borrows for a certain pool, each borrow displaying the specified fields.
As you can see here, we are accessing some data that we have not indexed ourselves quite easily, and this can be done from every point of your Zephyr program.