Language
Reference
Advanced

Advanced

Dangerous or unstable features meant to be used by advanced users only.

⚠️

Proceed with caution.

readForwardFee

extends fun readForwardFee(self: Context): Int

Read and compute forward fee from the Context and return it as Int value in nanoToncoins (nano-tons).

throw

fun throw(code: Int);

Throw an exception with error code equal code.

nativeThrowWhen

fun nativeThrowWhen(code: Int, condition: Bool);

Throw an exception with error code equal to code when condition is equal to true.

nativeThrowUnless

fun nativeThrowUnless(code: Int, condition: Bool);

Throw an exception with error code equal to code when condition is equal to false.

getConfigParam

fun getConfigParam(id: Int): Cell?;

Load network configuration parameter from the blockchain.

nativeRandomize

fun nativeRandomize(x: Int);

Randomize the random number generator with the specified seed x.

nativeRandomizeLt

fun nativeRandomizeLt();

Randomize the random number generator with the current logical time.

nativePrepareRandom

fun nativePrepareRandom();

This function prepares random number generator by calling nativeRandomizeLt once and called internally by random and randomInt functions.

nativeRandom

fun nativeRandom(): Int;

You shouldn't use this function directly, use random and randomInt functions instead.
This function generates 256-bit random number just like randomInt function, but random generator is not initialized by nativePrepareRandom function.

nativeRandomInterval

fun nativeRandomInterval(max: Int): Int;

You shouldn't use this function directly, use random and randomInt functions instead.
This function generates random number in the range from 0 to max. This call doesn't prepare initialization by nativePrepareRandom function.

nativeReserve

fun nativeReserve(amount: Int, mode: Int);

Calls native raw_reserve function with specified amount and mode. The raw_reserve is a function that creates an output action to reserve a specific amount of nanoToncoins (nano-tons) from the remaining balance of the account.

It has the following signature in FunC:

raw_reserve(int amount, int mode) impure asm "RAWRESERVE";

The function takes two arguments:

  • amount: The number of nanotoncoins to reserve.
  • mode: Determines the reservation behavior.

The resulting mode value can have the following base modes:

  • 00: Reserve exactly amount nanotoncoins.
  • 11 or 33: Reserve all but amount nanotoncoins.
  • 22: Reserve at most amount nanotoncoins.

Additionally, the resulting mode can have the following optional flags added:

  • +2+2: If the specified amount cannot be reserved, reserve the remaining balance instead of failing.
  • +4+4: Increase amount by the original balance of the current account (before the compute phase), including all extra currencies.
  • +8+8: Negate the amount before performing further actions.

Function raw_reserve is roughly equivalent to creating an outbound message carrying the specified amount of nanoToncoins (or b-amount nanoToncoins, where b is the remaining balance) to oneself. This ensures that subsequent output actions cannot spend more money than the remainder.

⚠️

Currently, amount must be a non-negative integer, and mode must be in the range 0..15, inclusive.