Skip to main content

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.

FunctionDescription
acquire‑module-adminGrant module administrative privileges for a specified module.
atRetrieve the value at the location specified by an index number or by a key string.
base64‑decodeConvert a previously-encoded string from unpadded base64 encoding to a string.
base64‑encodeConvert the specified string to an unpadded base64-encoded string.
bindBind variables to values over subsequent body statements.
chain-dataRetrieve the blockchain-specific public metadata for a transaction.
charset-asciiUse the standard ASCII character set.
charset-latin1Use the standard Latin-1 character set.
composeCompose functions using specified operands and a specified input value.
concatConcatenate a list of strings.
constantlyIgnore specified arguments.
containsEvaluate the contents of a list, object, or string.
continueContinue a previously started defpact step.
define-namespaceCreate a new namespace or update the guards of an existing namespace.
describe-namespaceDescribe the specified namespace.
distinctReturn a list with duplicates removed.
doEvaluate a sequence of expressions and return the result from the last expression.
dropRemove values from a list or string.
enforce-guardExecute a specified guard or keyset to enforce predicate logic.
enforce-oneEvaluate a series of tests in order.
enforce-pact-versionEnforce the runtime Pact version to be within a specified range.
enforce-verifierEnforce that a verifier with the specified name is in scope.
enforceFail a transaction if an expression evaluates to false.
enumerateReturn a sequence of numbers as a list.
filterFilter a list by applying a function to each element.
foldReduce a list iteratively by applying a function to each element.
formatFormat a message using placeholders and variables.
hash-keccak256Compute the hash of a list of inputs.
hashCompute the BLAKE2b 256-bit hash of a value.
identityReturn the provided value.
ifTest whether a condition is true to determine the operation to perform.
int-to-strRepresent an integer value as a string in a specified base.
is-charsetCheck whether a string conforms to a supported character set.
lengthCompute the length of a list, string, or object.
list-moduleList modules available for loading.
make-listCreate a list by repeating a specified value a certain number of times.
mapApply a function (APP) to each element in a list.
namespaceSet the current namespace to a specified value.
negateNegate a specified integer or decimal value.
pact-idReturn the identifier associated with defpact execution.
pact-versionGet the current Pact build version.
poseidon-hash-hack-a-chainCompute a hash using the Poseidon hash function used by Hack-a-Chain.
read-decimalRead a key string or number value from the message data as a decimal.
read-integerRead a key string or number value from the message data as an integer.
read-keysetRead a key from the message data as a keyset with a list of keys and a predicate function.
read-msgRead a key from the message data body.
read-stringRead a key string or number value from the message data as a string.
removeRemove an entry associated with a specified key from an object.
resumeBind a yielded object value from a defpact step to the execution of the next defpact step.
reverseReverse the order of elements in a given list.
roundPerform Banker's rounding to return an integer or decimal value.
showConvert a specified value into a string.
sortSort a list of primitive values or objects.
static-redeployRedeploy a module without any code changes.
str-to-intCompute the integer value of the specified string.
str-to-listConvert a string into a list where each element is a single-character string.
takeRetrieve a specified number of values from a list, string, or object.
tryAttempt a pure action without input, output, or state-changing operations.
tx-hashGet the hash of the current transaction as a string.
typeofReturn a description of the data type for a specified value.
whereDefine a clause to refine the results from filter or select operations.
yieldYield an object to use with the resume function in a defpact step.
zipCombine two lists using a specified function to create a new list.