TokenScript
TokenScript copied to clipboard
Volatility hint for Tokenscript engine optimisation
Compare:
<ts:ethereum function="balanceOf" contract="dai" as="uint">
vs
<ts:ethereum function="getStreet" contract="EntryToken" as="utf8">
The balanceOf is expected to be more volatile than the getStreet value. Adding a volatile attribute will help to give a hint for wallet run speed optimisation.
This would be a good start:
<ts:ethereum function="balanceOf" contract="dai" as="uint" volatile="true">
or
<ts:ethereum function="balanceOf" contract="dai" as="uint" volatility="high">
<ts:ethereum function="getStreet" contract="EntryToken" as="utf8" volatility="low">
Ok we have refined this down to two values to begin with:
<ts:ethereum function="balanceOf" contract="dai" as="uint" volatility="immediate">
and
<ts:ethereum function="getStreet" contract="EntryToken" as="utf8" volatility="default">
The second default volatility is handled by the client as appropriate, it is the default behaviour so there is no need to declare it. The immediate flag indicates that the value should be fetched before usage.