Runtime

In this section, we discuss the runtime behavior of Scrypto code (in WASM format).

When a transaction enters the system, Radix Engine validates its format and interprets its instructions one-by-one, which generally consists of two categories:

  • To update or assert the transaction worktop

  • To call a function or method

Scrypto code runs when a function/method get invoked.

Entrypoint

Each blueprint has a separate exported WASM function which serves as the entrypoint for any function/method call. These are named {BlueprintName}_main.

Execution

Execution of WASM code follows the standard with the following modifications:

  • Floating point instructions have been removed.

External Calls

A component can make calls to other components (or blueprints) via the system call INVOKE_SNODE.

When an invocation occurs, all data and resources in call arguments moves downstream from the caller to the callee. Call data is inspected by Radix Engine. Invalid data would result in a runtime failure.

Return

Similar to external calls, all data and resources in a return object moves upstream from the callee to the caller.

When a call frame exits, dangling objects (such as buckets) are checked for and a runtime error is issued if some exist.