Wormhole Functions Documentation
Wormhole is a higher-level layer that allows executing PersistentScripts (aka Smart Contracts) or retrieving on-chain templates.
PersistentScript
Description: This function allows executing another graph as a contract in the current execution context.
- GraphID (string): The ID of the graph to execute.
- FunctionName (string): The name of the function to call in the graph.
- Args ([]interface{}) (optional): An array of parameters to pass to the function.
Returns: The result of executing the specified function.
let result = Wormhole.PersistentScript("graph-id", "FunctionName", [arg1, arg2]);
LoadTemplate
Description: This function loads a template from a specific graph and replaces it with provided variables.
- GraphID (string): The ID of the graph containing the target template.
- Props (map[string]interface{}) (optional): A properties object to replace template variables.
Returns: The evaluated template with variables replaced.
let template = Wormhole.LoadTemplate("graph-id", {variable1: "value1", variable2: "value2"});
LoadTemplateElement
Description: This function loads a specific template element from a graph.
- GraphID (string): The ID of the graph containing the target template.
- ElementID (string): The ID of the template element.
- Props (map[string]interface{}) (optional): A properties object to replace template variables.
Returns: The evaluated template element with variables replaced.
let templateElement = Wormhole.LoadTemplateElement("graph-id", "element-id", {variable1: "value1"});
SetOutputFormat
Description: This function sets the expected output format.
- OutputFormat (string): The mime type of the expected output format.
Returns: Undefined value.
Wormhole.SetOutputFormat("application/json");
GetCacheEntry
Description: This function returns the value of the cache entry for a given key.
- Key (string): The key of the cache entry.
Returns: The value of the cache entry if it exists, otherwise an undefined value.
let cacheValue = Wormhole.GetCacheEntry("cache-key");
SetCacheEntry
Description: This function sets the value of the cache entry for a given key.
- Key (string): The key of the cache entry.
- Value (interface{}): The value to set for the cache entry.
Returns: true if the value was successfully set, otherwise false.
let success = Wormhole.SetCacheEntry("cache-key", "value");
IncrementCacheEntry
Description: This function increments a string value in the cache entry for a given key.
- Key (string): The key of the cache entry.
Returns: true if the value was successfully incremented, otherwise false.
let success = Wormhole.IncrementCacheEntry("cache-key");
FilterEntriesWithPrefixInKey
Description: This function returns a list of cache entries whose keys start with a given prefix.
- Prefix (string): The prefix to filter by.
Returns: A list of cache entries with the specified prefix.
let entries = Wormhole.FilterEntriesWithPrefixInKey("cache-prefix");