# [Ride v5] Invocation
⚠️ This is the documentation for the Standard Library version 5, which is currently available for Stagenet only. Go to Mainnet version
Structure that contains the fields of the script invocation that the callable function can use.
# Constructor
Invocation(caller: Address, callerPublicKey: 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 transaction |
2 | callerPublicKey | ByteVector | Public key of the account that sent the transaction |
3 | payments | List[AttachedPayment] | Payments indicated in the transaction |
4 | transactionId | ByteVector | ID of the transaction |
5 | fee | Int | Transaction fee |
6 | feeAssetId | ByteVector|Unit | ID of the fee token |
If the callable function is invoked by an Invoke function:
# | 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 | payments | List[AttachedPayment] | Payments indicated in the Invoke function |
4 | transactionId | ByteVector | ID of the Invoke Script transaction |
5 | fee | Int | Transaction fee |
6 | feeAssetId | ByteVector|Unit | ID of the fee token |
The
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 ([],null) else throw("Wrong payment amount or asset")
}