Writing and Emitting Retroshades
As promised, this section is very short, because there's little to know about Retroshades: it's all Soroban code!
The only concept that you need to keep in mind is that the retroshade logic within your contract is not metered on chain, and you are not paying any extra fees by adding Retroshade logic to your code. In fact, you can write retroshades for contracts that are already deployed and you don't need to perform any kind of action on-chain.
The contracts compiled with the mercury feature can be directly deployed to Mercury's retroshade network and work out of the box.
Defining Retroshades
Defining retroshades means defining rust structures. Keep in mind that:
The fields will be translated to database columns. So if you have data that you want to be able to efficiently query, include them as top-level field, rather than in a nested structure.
The types are transformed to their corresponding native database type.
Emitting Retroshades
Emitting a retroshade is as simple as declaring the retroshade structure and emit it in your target code block:
Keep in mind that you can add additional soroban code under the mercury flag to retrieve the data you need!
This code won't have any impact when the binary is compiled with the mercury
flag.
Tip: beware that .clone() are just compiler stubs in Soroban. So if you end up having to clone Val
don't worry, because it won't change the resulting binary.
Last updated