aiken/builtin

This modules contains all the Plutus builtins recognized by Aiken.

It’s important to note that many of those functions are partial and will halt the execution of the Plutus virtual machine on failure. They also all rely on call-by-value, which means that function arguments are eagerly evaluated.

Functions

add_integer(left: Int, right: Int) -> Int

Minimum Plutus Version1

Adds two integers (+).

append_bytearray(left: ByteArray, right: ByteArray) -> ByteArray

Minimum Plutus Version1

Concatenate two bytearrays together.

append_string(left: String, right: String) -> String

Minimum Plutus Version1

Concatenate two strings.

b_data(bytes: ByteArray) -> Data

Minimum Plutus Version1

Construct a Data from a ByteArray

blake2b_256(preimage: ByteArray) -> ByteArray

Minimum Plutus Version1

Calculate the blake2b-256 hash digest value of a given bytearray. Output is always 32-byte long.

bls12_381_final_verify(a: MillerLoopResult, b: MillerLoopResult) -> Bool

Minimum Plutus Version3

bls12_381_g1_add(a: G1Element, b: G1Element) -> G1Element

Minimum Plutus Version3

bls12_381_g1_compress(self: G1Element) -> ByteArray

Minimum Plutus Version3

bls12_381_g1_equal(self: G1Element, other: G1Element) -> Bool

Minimum Plutus Version3

bls12_381_g1_hash_to_group(
  group: ByteArray,
  domain_separation_tag: ByteArray,
) -> G1Element

Minimum Plutus Version3

bls12_381_g1_neg(self: G1Element) -> G1Element

Minimum Plutus Version3

bls12_381_g1_scalar_mul(scalar: Int, self: G1Element) -> G1Element

Minimum Plutus Version3

bls12_381_g1_uncompress(self: ByteArray) -> G1Element

Minimum Plutus Version3

bls12_381_g2_add(a: G2Element, b: G2Element) -> G2Element

Minimum Plutus Version3

bls12_381_g2_compress(self: G2Element) -> ByteArray

Minimum Plutus Version3

bls12_381_g2_equal(self: G2Element, other: G2Element) -> Bool

Minimum Plutus Version3

bls12_381_g2_hash_to_group(
  group: ByteArray,
  domain_separation_tag: ByteArray,
) -> G2Element

Minimum Plutus Version3

bls12_381_g2_neg(self: G2Element) -> G2Element

Minimum Plutus Version3

bls12_381_g2_scalar_mul(scalar: Int, self: G2Element) -> G2Element

Minimum Plutus Version3

bls12_381_g2_uncompress(self: ByteArray) -> G2Element

Minimum Plutus Version3

bls12_381_miller_loop(g1: G1Element, g2: G2Element) -> MillerLoopResult

Minimum Plutus Version3

bls12_381_mul_miller_loop_result(
  a: MillerLoopResult,
  b: MillerLoopResult,
) -> MillerLoopResult

Minimum Plutus Version3

bytearray_to_integer(endianness: Bool, bytes: ByteArray) -> Int

Minimum Plutus Version3

Convert a ByteArray to an integer value. The first argument specifies the endianness:

boolean valueendianness
TrueBig endian
FalseLittle endian

choose_data(
  data: Data,
  when_constr: a,
  when_map: a,
  when_list: a,
  when_int: a,
  when_bytearray: a,
) -> a

Minimum Plutus Version1

Select a branch to continue with based on what the Data actually is.

choose_list(list: List<a>, when_empty: b, when_non_empty: b) -> b

Minimum Plutus Version1

Select a branch to continue with depending on whether the list is empty or not.

choose_void(void: Void, when_void: a) -> a

Minimum Plutus Version1

Continue with the continuation when the given term is Void.

cons_bytearray(byte: Int, bytes: ByteArray) -> ByteArray

Minimum Plutus Version1

Push a byte in front of a bytearray.

cons_list(elem: a, list: List<a>) -> List<a>

Minimum Plutus Version1

Push an element in front of a list.

constr_data(index: Int, fields: List<Data>) -> Data

Minimum Plutus Version1

Construct a Data from a constructor index and a list of fields.

debug(message: String, continuation: a) -> a

Minimum Plutus Version1

Trace the provided message, and continue with the continuation.

decode_utf8(bytes: ByteArray) -> String

Minimum Plutus Version1

Interpret a UTF-8 encoded array of bytes as a String. Fails if the bytes aren’t UTF-8 encoded.

divide_integer(numerator: Int, denominator: Int) -> Int

Minimum Plutus Version1

Integer division truncated towards negative infinity (/).

encode_utf8(str: String) -> ByteArray

Minimum Plutus Version1

Convert a string into a UTF-8 encoded array of bytes.

equals_bytearray(left: ByteArray, right: ByteArray) -> Bool

Minimum Plutus Version1

Bytearray equality.

equals_data(left: Data, right: Data) -> ByteArray

Minimum Plutus Version1

Equality on Data.

equals_integer(left: Int, right: Int) -> Bool

Minimum Plutus Version1

Integer equality.

equals_string(left: String, right: String) -> Bool

Minimum Plutus Version1

String equality.

fst_pair(pair: (a, b)) -> a

Minimum Plutus Version1

Get the first element of a pair.

head_list(list: List<a>) -> a

Minimum Plutus Version1

The head of a list. Fails if empty.

i_data(i: Int) -> Data

Minimum Plutus Version1

Construct a Data from an integer.

if_then_else(condition: Bool, when_true: a, when_false: a) -> a

Minimum Plutus Version1

Return first computation when the condition is true, and the second otherwise.

index_bytearray(bytes: ByteArray, index: Int) -> Int

Minimum Plutus Version1

Access the byte at the given index in the bytearray.

integer_to_bytearray(endianness: Bool, size: Int, value: Int) -> ByteArray

Minimum Plutus Version3

Convert an integer value into a ByteArray.

  • The first arguments / specifies the endianness:

    boolean valueendianness
    TrueBig endian
    FalseLittle endian
  • The second argument indicates the target size (in bytes) of the final ByteArray. This allows to allocate a specific number of bytes in advance. The function fails if the given value cannot fit in the requested size or if the value is negative. However, a size of 0 will yield a ByteArray that is precisely as large as necessary to fit the value.

length_of_bytearray(bytes: ByteArray) -> Int

Minimum Plutus Version1

Number of bytes in a bytearray.

less_than_bytearray(left: ByteArray, right: ByteArray) -> Bool

Minimum Plutus Version1

Bytearray strict inequality.

less_than_equals_bytearray(left: ByteArray, right: ByteArray) -> Bool

Minimum Plutus Version1

Bytearray inequality.

less_than_equals_integer(left: Int, right: Int) -> Int

Minimum Plutus Version1

Integer inequality.

less_than_integer(left: Int, right: Int) -> Int

Minimum Plutus Version1

Integer strict inequality.

list_data(items: List<Data>) -> Data

Minimum Plutus Version1

Construct a Data from a list of elements.

map_data(items: List<(Data, Data)>) -> Data

Minimum Plutus Version1

Construct a Data from a list of pairs.

mk_nil_data() -> List<Data>

Minimum Plutus Version1

Construct an empty list of Data.

mk_nil_pair_data() -> List<(Data, Data)>

Minimum Plutus Version1

Construct an empty list of pairs of data.

mk_pair_data(left: Data, right: Data) -> (Data, Data)

Minimum Plutus Version1

Construct a Data from a pair of elements.

mod_integer(numerator: Int, denominator: Int) -> Int

Minimum Plutus Version1

Integer modulus (%), satisfying

divide_integer(x, y) * y + mod_integer(x, y) == x

multiply_integer(left: Int, right: Int) -> Int

Minimum Plutus Version1

Multiple two integers (*).

null_list(list: List<a>) -> Bool

Minimum Plutus Version1

True when a list is empty.

quotient_integer(numerator: Int, denominator: Int) -> Int

Minimum Plutus Version1

Integer division truncated towards zero.

remainder_integer(numerator: Int, denominator: Int) -> Int

Minimum Plutus Version1

Integer remainder, satisfying

quotient_integer(x, y) * y + remainder_integer(x, y) == x

serialise_data(data: Data) -> ByteArray

Minimum Plutus Version2

Serialise a Data to bytes, using CBOR.

sha2_256(preimage: ByteArray) -> ByteArray

Minimum Plutus Version1

Calculate the SHA2-256 hash digest value of a given bytearray. Output is always 32-byte long.

sha3_256(preimage: ByteArray) -> ByteArray

Minimum Plutus Version1

Calculate the SHA3-256 hash digest value of a given bytearray. Output is always 32-byte long.

slice_bytearray(start: Int, len: Int, bytes: ByteArray) -> ByteArray

Minimum Plutus Version1

Extract a sub-array from a bytearray given starting and length of the sub-array.

snd_pair(pair: (a, b)) -> b

Minimum Plutus Version1

Get the second element of a pair.

subtract_integer(left: Int, right: Int) -> Int

Minimum Plutus Version1

Subtract two integers (-).

tail_list(list: List<a>) -> List<a>

Minimum Plutus Version1

The tail of a list. Fails if empty.

un_b_data(data: Data) -> ByteArray

Minimum Plutus Version1

Interpret a Data as a bytearray. Fails if it’s not a bytearray.

un_constr_data(data: Data) -> (Int, List<Data>)

Minimum Plutus Version1

Interpret a Data as a constructor. Fails if it’s not a constructor.

un_i_data(data: Data) -> Int

Minimum Plutus Version1

Interpret a Data as a integer. Fails if it’s not an integer.

un_list_data(data: Data) -> List<Data>

Minimum Plutus Version1

Interpret a Data as a list. Fails if it’s not a list.

un_map_data(data: Data) -> List<(Data, Data)>

Minimum Plutus Version1

Interpret a Data as a map. Fails if it’s not a map.

verify_ecdsa_secp256k1_signature(
  verification_key: ByteArray,
  message: ByteArray,
  signature: ByteArray,
) -> ByteArray

Minimum Plutus Version2

Verify an ECDSA-SECP256k1 signature from a associated verification key.

verify_ed25519_signature(
  verification_key: ByteArray,
  message: ByteArray,
  signature: ByteArray,
) -> ByteArray

Minimum Plutus Version1

Verify an Ed25519 signature from a associated verification key.

verify_schnorr_secp256k1_signature(
  verification_key: ByteArray,
  message: ByteArray,
  signature: ByteArray,
) -> ByteArray

Minimum Plutus Version2

Verify a SCHNORR-SECP256k1 signature from a associated verification key.

Search Document