# [Ride v5] Invocation
⚠️ This is the documentation for the Standard library version 5. We recommend to use version 6. Go to version 6
Structure that contains the fields of the script invocation that the callable function can use.
# Constructor
Invocation(caller: Address, callerPublicKey: ByteVector, originCaller: Address, originCallerPublicKey: ByteVector, payments: List[AttachedPayment], transactionId: ByteVector, fee: Int, feeAssetId: ByteVector|Unit)
# Fields
The field values depend on how the callable function is invoked.
If the callable function is invoked by an Invoke Script transaction:
# | Name | Data type | Description |
---|---|---|---|
1 | caller | Address | Address of the account that sent the Invoke Script transaction |
2 | callerPublicKey | ByteVector | Public key of the account that sent the Invoke Script transaction |
3 | originCaller | Address | Duplicates the caller field |
4 | originCallerPublicKey | ByteVector | Duplicates the callerPublicKey field |
5 | payments | List[AttachedPayment] | Payments indicated in the Invoke Script transaction |
6 | transactionId | ByteVector | ID of the Invoke Script transaction |
7 | fee | Int | Transaction fee |
8 | feeAssetId | ByteVector|Unit | ID of a token to pay the fee. unit means WAVES |
If the callable function is invoked by the invoke
or reentrantInvoke
function (see the dApp-to-dApp invocation article):
# | Name | Data type | Description |
---|---|---|---|
1 | caller | Address | Address of the dApp that invokes the callable function |
2 | callerPublicKey | ByteVector | Public key of the dApp that invokes the callable function |
3 | originCaller | Address | Address of the account that sent the Invoke Script transaction |
4 | originCallerPublicKey | ByteVector | Public key of the account that sent the Invoke Script transaction |
5 | payments | List[AttachedPayment] | Payments indicated in the invoke or reentrantInvoke function |
6 | transactionId | ByteVector | ID of the Invoke Script transaction |
7 | fee | Int | Transaction fee |
8 | feeAssetId | ByteVector|Unit | ID of a token to pay the fee. unit means WAVES |
The
originCaller
,originCallerPublicKey
,transactionId
,fee
, andfeeAssetId
values are the same for all dApp-to-dApp invocations within a single Invoke Script transaction.
# Example: Payments Processing
The following function checks that the first payment in the Invoke Script transaction is at least 1 WAVES or 5 in the specified asset.
{-# STDLIB_VERSION 5 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
func isPaymentOk(i: Invocation) = {
let acceptableAssetId = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg'
if (size(i.payments) == 0) then {
throw("Payment not attached")
} else {
let p = i.payments[0]
match p.assetId {
case assetId: ByteVector => assetId == acceptableAssetId && p.amount >= 500000000
case _ => p.amount >= 100000000
}
}
}
@Callable(i)
func foo() = {
if isPaymentOk(i) then ([],unit) else throw("Wrong payment amount or asset")
}