# [Ride v5] Standard Library Version 5
⚠️ We recommend to use Standard library version 6 for application development.
Standard library version 5 is enabled by feature #16 “Ride V5, dApp-to-dApp invocations”.
# dApp-to-dApp Invocation
A dApp callable function can invoke a callable function of another dApp, or another callable function of the same dApp, or even itself. The invoked function returns a value that the invoking function can use. The subsequent operations of invoking function are executed, taking into account script actions of invoked function (as if the actions are applied to the blockchain state). All callable functions are executed within a single Invoke Script transaction. The total complexity is limited. More about dApp-to-dApp invocation
Changes in Ride:
- Added the functions for dApp-to-dApp invocation:
- Added strict variables that are evaluated before the next expression to ensure executing callable functions and applying their actions in the right order.
- Modified the Invocation structure: in case of dApp-to-dApp invocation, the structure contains the address and public key of both the sender of the Invoke Script transaction and the dApp account that invokes the callable function.
- Modified the callable function result by adding a return value.
# Lease and LeaseCancel Script Actions
Added script actions that the callable function can perform:
Using these actions, you can change the amount of the lease, in particular, withdraw a part of the leased funds. If you cancel a lease for a larger amount and create a new lease for a smaller amount with the same recipient in the same script invocation, the recipient's generating balance decreases by the difference. Otherwise, if you send two separate transactions: a Lease Cancel transaction and a Lease transaction, they can be added to a different blocks and therefore generating balance decreases by the amount of the canceled lease immediately and increases by the amount of the new lease after 1000 blocks.
Added the function calculateLeaseId that calculates ID of the lease formed by the
# Big Integers
Added the BigInt data type of 64 bytes (512 bits) and functions supporting it:
- fraction(BigInt, BigInt, BigInt): BigInt
- fraction(BigInt, BigInt, BigInt, Union): BigInt
- log(BigInt, Int, BigInt, Int, Int, Union): BigInt
- max(List[BigInt]): BigInt
- median(List[BigInt]): BigInt
- min(List[BigInt]): BigInt
- pow(BigInt, Int, BigInt, Int, Int, Union): BigInt
- parseBigInt(String): BigInt|Unit
- parseBigIntValue(String): BigInt
- toBigInt(ByteVector): BigInt
- toBigInt(ByteVector, Int, Int): BigInt
- toBigInt(Int): BigInt
- toBytes(BigInt): ByteVector
- toInt(BigInt): Int
- toString(BigInt): String
When executing a dApp script, the payments attached to the invocation are considered to be already credited to the dApp balance (unlike versions 4 and 3, where payments do not affect the dApp balance until the end of script execution).
Added the following built-in functions:
- isDataStorageUntouched that checks if the data storage of a given account never contained any entries.
- scriptHash that returns BLAKE2b-256 hash of the script assigned to a given account.
- fraction(Int, Int, Int, Union): Int that multiplies and divides integers to avoid overflow, applying the specified rounding method.
Added the following account data storage functions that allow the dApp script to read entries of its own data storage:
getBinary(key: String): ByteVector|Unit
getBinaryValue(key: String): ByteVector
getBoolean(key: String): Boolean|Unit
getBooleanValue(key: String): Boolean
getInteger(key: String): Int|Unit
getIntegerValue(key: String): Int
getString(key: String): String|Unit
getStringValue(key: String): String
The maximum complexity of a callable function of a dApp script is changed to 10,000.