Getter functions retrieve data from the blockchain or protocols. They do not perform transactions and do not use the sign function.
-
Function and File Naming
- The function name must match the file name.
- One function per file in the
functions/directory.
-
Input Validation
- Validate input arguments at the beginning.
- Return informative error messages using
toResult.
-
Data Limits
- Do not return more than 500 tokens of data.
- Split functions into smaller ones if retrieving large amounts of data.
-
Returning Results
- Always use
toResultto return data. - Ensure data is formatted and parsed appropriately.
- Always use
-
Comments and Documentation
- Include JSDoc comments.
- Explain any complex logic.
[See the code in the Getter Function Example.