General functions
General functions are used to perform many different types of common tasks, such as specifying the character set for a smart contract, concatenating a list of strings, or defining a unique namespace for module code. For an introduction to creating and working with modules, see Modules and references.
| Function | Description |
|---|---|
| acquire‑module-admin | Grant module administrative privileges for a specified module. |
| at | Retrieve the value at the location specified by an index number or by a key string. |
| base64‑decode | Convert a previously-encoded string from unpadded base64 encoding to a string. |
| base64‑encode | Convert the specified string to an unpadded base64-encoded string. |
| bind | Bind variables to values over subsequent body statements. |
| chain-data | Retrieve the blockchain-specific public metadata for a transaction. |
| charset-ascii | Use the standard ASCII character set. |
| charset-latin1 | Use the standard Latin-1 character set. |
| compose | Compose functions using specified operands and a specified input value. |
| concat | Concatenate a list of strings. |
| constantly | Ignore specified arguments. |
| contains | Evaluate the contents of a list, object, or string. |
| continue | Continue a previously started defpact step. |
| define-namespace | Create a new namespace or update the guards of an existing namespace. |
| describe-namespace | Describe the specified namespace. |
| distinct | Return a list with duplicates removed. |
| do | Evaluate a sequence of expressions and return the result from the last expression. |
| drop | Remove values from a list or string. |
| enforce-guard | Execute a specified guard or keyset to enforce predicate logic. |
| enforce-one | Evaluate a series of tests in order. |
| enforce-pact-version | Enforce the runtime Pact version to be within a specified range. |
| enforce-verifier | Enforce that a verifier with the specified name is in scope. |
| enforce | Fail a transaction if an expression evaluates to false. |
| enumerate | Return a sequence of numbers as a list. |
| filter | Filter a list by applying a function to each element. |
| fold | Reduce a list iteratively by applying a function to each element. |
| format | Format a message using placeholders and variables. |
| hash-keccak256 | Compute the hash of a list of inputs. |
| hash | Compute the BLAKE2b 256-bit hash of a value. |
| identity | Return the provided value. |
| if | Test whether a condition is true to determine the operation to perform. |
| int-to-str | Represent an integer value as a string in a specified base. |
| is-charset | Check whether a string conforms to a supported character set. |
| length | Compute the length of a list, string, or object. |
| list-module | List modules available for loading. |
| make-list | Create a list by repeating a specified value a certain number of times. |
| map | Apply a function (APP) to each element in a list. |
| namespace | Set the current namespace to a specified value. |
| negate | Negate a specified integer or decimal value. |
| pact-id | Return the identifier associated with defpact execution. |
| pact-version | Get the current Pact build version. |
| poseidon-hash-hack-a-chain | Compute a hash using the Poseidon hash function used by Hack-a-Chain. |
| read-decimal | Read a key string or number value from the message data as a decimal. |
| read-integer | Read a key string or number value from the message data as an integer. |
| read-keyset | Read a key from the message data as a keyset with a list of keys and a predicate function. |
| read-msg | Read a key from the message data body. |
| read-string | Read a key string or number value from the message data as a string. |
| remove | Remove an entry associated with a specified key from an object. |
| resume | Bind a yielded object value from a defpact step to the execution of the next defpact step. |
| reverse | Reverse the order of elements in a given list. |
| round | Perform Banker's rounding to return an integer or decimal value. |
| show | Convert a specified value into a string. |
| sort | Sort a list of primitive values or objects. |
| static-redeploy | Redeploy a module without any code changes. |
| str-to-int | Compute the integer value of the specified string. |
| str-to-list | Convert a string into a list where each element is a single-character string. |
| take | Retrieve a specified number of values from a list, string, or object. |
| try | Attempt a pure action without input, output, or state-changing operations. |
| tx-hash | Get the hash of the current transaction as a string. |
| typeof | Return a description of the data type for a specified value. |
| where | Define a clause to refine the results from filter or select operations. |
| yield | Yield an object to use with the resume function in a defpact step. |
| zip | Combine two lists using a specified function to create a new list. |