waves_logo Docs
  • Ride Programming Language
    Ride Programming Language
  • Getting Started
    Getting Started
  • Syntax Basics
    • Directives
      Directives
    • Definition
      Definition
    • Expression
      Expression
    • Constant
      Constant
    • Variable
      Variable
    • Function
      Function
    • Exception
      Exception
    • Comment
      Comment
    Syntax Basics
  • Script Types
    • dApp Script
      • Annotations
        Annotations
      • Callable Function
        Callable Function
      • Verifier Function
        Verifier Function
      dApp Script
    • Account Script
      Account Script
    • Asset Script
      Asset Script
    Script Types
  • Standard Library
    Standard Library
  • Data types
    • Boolean
      Boolean
    • ByteVector
      ByteVector
    • Int
      Int
    • String
      String
    • Unit
      Unit
    • List
      List
    • Tuple
      Tuple
    • Union
      Union
    Data types
  • Structures
    • Script Actions
      • BinaryEntry (v4)
        BinaryEntry (v4)
      • BooleanEntry (v4)
        BooleanEntry (v4)
      • Burn (v4)
        Burn (v4)
      • DataEntry (v3)
        DataEntry (v3)
      • DeleteEntry (v4)
        DeleteEntry (v4)
      • IntegerEntry (v4)
        IntegerEntry (v4)
      • Issue (v4)
        Issue (v4)
      • Reissue (v4)
        Reissue (v4)
      • ScriptTransfer (v3 and v4)
        ScriptTransfer (v3 and v4)
      • SponsorFee (v4)
        SponsorFee (v4)
      • StringEntry (v4)
        StringEntry (v4)
      Script Actions
    • Script Results (v3)
      • ScriptResult
        ScriptResult
      • TransferSet
        TransferSet
      • WriteSet
        WriteSet
      Script Results (v3)
    • Common Structures
      • Address
        Address
      • Alias
        Alias
      • Asset
        Asset
      • AssetPair
        AssetPair
      • AttachedPayment
        AttachedPayment
      • BalanceDetails
        BalanceDetails
      • BlockInfo
        BlockInfo
      • Invocation
        Invocation
      • Order
        Order
      • Transfer
        Transfer
      Common Structures
    • Transaction Structures
      • BurnTransaction
        BurnTransaction
      • CreateAliasTransaction
        CreateAliasTransaction
      • DataTransaction
        DataTransaction
      • ExchangeTransaction
        ExchangeTransaction
      • GenesisTransaction
        GenesisTransaction
      • InvokeScriptTransaction
        InvokeScriptTransaction
      • IssueTransaction
        IssueTransaction
      • LeaseCancelTransaction
        LeaseCancelTransaction
      • LeaseTransaction
        LeaseTransaction
      • MassTransferTransaction
        MassTransferTransaction
      • ReissueTransaction
        ReissueTransaction
      • SetAssetScriptTransaction
        SetAssetScriptTransaction
      • SetScriptTransaction
        SetScriptTransaction
      • SponsorFeeTransaction
        SponsorFeeTransaction
      • TransferTransaction
        TransferTransaction
      • UpdateAssetInfoTransaction
        UpdateAssetInfoTransaction
      Transaction Structures
    Structures
  • Built-in Variables
    Built-in Variables
  • Built-in Functions
    • Account Data Storage Functions
      Account Data Storage Functions
    • Blockchain Functions
      Blockchain Functions
    • Byte Array Functions
      Byte Array Functions
    • Converting Functions
      Converting Functions
    • Data Transaction Functions
      Data Transaction Functions
    • Decoding Functions
      Decoding Functions
    • Encoding Functions
      Encoding Functions
    • Exception Functions
      Exception Functions
    • Hashing Functions
      Hashing Functions
    • List Functions
      List Functions
    • Math Functions
      Math Functions
    • String Functions
      String Functions
    • Union Functions
      Union Functions
    • Verification Functions
      Verification Functions
    Built-in Functions
  • Operators
    Operators
  • Pattern Matching: match-case
    Pattern Matching: match-case
  • Interations with FOLD<N>
    Interations with FOLD<N>
  • Limitations
    • Complexity
      Complexity
    • Data Weight
      Data Weight
    Limitations
  • Version 5 (Stagenet)
    • dApp-to-dApp Invocation
      dApp-to-dApp Invocation
    • Continued Computations
      Continued Computations
    • Strict Variable
      Strict Variable
    • Callable Function
      Callable Function
    • Data types
      • Any
        Any
      • Boolean
        Boolean
      • ByteVector
        ByteVector
      • Int
        Int
      • String
        String
      • Unit
        Unit
      • List
        List
      • Tuple
        Tuple
      • Union
        Union
      Data types
    • Structures
      • Script Actions
        • BinaryEntry
          BinaryEntry
        • BooleanEntry
          BooleanEntry
        • Burn
          Burn
        • DeleteEntry
          DeleteEntry
        • IntegerEntry
          IntegerEntry
        • Issue
          Issue
        • Lease
          Lease
        • LeaseCancel
          LeaseCancel
        • Reissue
          Reissue
        • ScriptTransfer
          ScriptTransfer
        • SponsorFee
          SponsorFee
        • StringEntry
          StringEntry
        Script Actions
      • Common Structures
        • Address
          Address
        • Alias
          Alias
        • Asset
          Asset
        • AssetPair
          AssetPair
        • AttachedPayment
          AttachedPayment
        • BalanceDetails
          BalanceDetails
        • BlockInfo
          BlockInfo
        • Invocation
          Invocation
        • Order
          Order
        • Transfer
          Transfer
        Common Structures
      • Transaction Structures
        • BurnTransaction
          BurnTransaction
        • CreateAliasTransaction
          CreateAliasTransaction
        • DataTransaction
          DataTransaction
        • ExchangeTransaction
          ExchangeTransaction
        • GenesisTransaction
          GenesisTransaction
        • InvokeScriptTransaction
          InvokeScriptTransaction
        • IssueTransaction
          IssueTransaction
        • LeaseCancelTransaction
          LeaseCancelTransaction
        • LeaseTransaction
          LeaseTransaction
        • MassTransferTransaction
          MassTransferTransaction
        • ReissueTransaction
          ReissueTransaction
        • SetAssetScriptTransaction
          SetAssetScriptTransaction
        • SetScriptTransaction
          SetScriptTransaction
        • SponsorFeeTransaction
          SponsorFeeTransaction
        • TransferTransaction
          TransferTransaction
        • UpdateAssetInfoTransaction
          UpdateAssetInfoTransaction
        Transaction Structures
      Structures
    • Built-in Variables
      Built-in Variables
    • Built-in Functions
      • Account Data Storage Functions
        Account Data Storage Functions
      • Blockchain Functions
        Blockchain Functions
      • Byte Array Functions
        Byte Array Functions
      • Converting Functions
        Converting Functions
      • Data Transaction Functions
        Data Transaction Functions
      • Decoding Functions
        Decoding Functions
      • Encoding Functions
        Encoding Functions
      • Exception Functions
        Exception Functions
      • Hashing Functions
        Hashing Functions
      • dApp-to-dApp Invocation Function
        dApp-to-dApp Invocation Function
      • List Functions
        List Functions
      • Math Functions
        Math Functions
      • String Functions
        String Functions
      • Union Functions
        Union Functions
      • Verification Functions
        Verification Functions
      Built-in Functions
    • Operators
      Operators
    • Limitations
      Limitations
    Version 5 (Stagenet)
  • Ride Components
    Ride Components
  • Script performance tests
    Script performance tests
      • English
      • Русский
      On this page
        • Invoke
        • Example
      waves_logo Docs

          # [Ride v5] dApp-to-dApp Invocation Function

          ⚠️ This is the documentation for the Standard Library version 5, which is currently available for Stagenet only.

          Name Description Complexity
          Invoke Вызывает вызываемую функцию dApp TBDL

          # Invoke

          Invokes a dApp callable function.

          The Invoke function can be used by a callable function of a dApp script, but not by a verifier function, account script or asset script.

          Via the Invoke function, the callable function can invoke a callable function of another dApp, or another callable function of the same dApp, or even itself, and then use the invocation results in subsequent operations. For details, see the dApp-to-dApp Invocation article.

          The invocation can contain payments that will be transferred from the balance of the invoking dApp to the balance of the invoked dApp. Payments are forbidden if the dApp invokes itself.

          If a payment token is a smart asset, the asset script verifies the Invoke as if it were InvokeScriptTransaction with the following fields:

          • dApp, payments, function, args indicated in the Invoke function;
          • sender, senderPublicKey of the dApp that performs the invocation;
          • id, timestamp, fee, feeAssetId indicated in the original Invoke Script transaction;
          • version = 0;

          If the asset script denies the action, the Invoke Script transaction is either denied or saved on the blockchain as failed, see the Transaction Validation.

          Invoke(dApp: Address|Alias, function: String, arguments: List[Boolean|ByteVector|Int|String|List[Boolean|ByteVector|Int|String]], payments: List[AttachedPayments]): Any
          

          Any means any valid type.

          💡 To ensure executing callable functions and applying their actions in the right order, initialize a strict variable by the return value of an Invoke function.

          # Parameters

          Parameter Description
          dApp: Address|Alias Address or alias of a dApp to invoke
          function: String|Unit Name of a callable function. unit for a default function invocation
          arguments: List[Boolean|ByteVector|Int|String|List[Boolean|ByteVector|Int|String]]|Unit Parameters of a callable function. unit for a default function invocation
          payments: List[AttachedPayment] Payments to transfer from the invoking dApp to the invoked dApp, up to 2

          # Example

          A user sends an Invoke Script transaction that invokes the callable function foo of dApp1.

          The foo function invokes the bar function of dApp2 passing the number a and attaching a payment of 1 USDN.

          The bar function transfers 1 WAVES to dApp1 and returns the doubled number a.

          The foo function writes to dApp1 data storage:

          • the value returned by bar,
          • the new balance of dApp2 (reduced by 1 WAVES transferred to dApp1).

          dApp1:

          {-# STDLIB_VERSION 5 #-}
          {-# CONTENT_TYPE DAPP #-}
          {-# SCRIPT_TYPE ACCOUNT #-}
          
          @Callable(i)
          func foo(dapp2: String, a: Integer, key1: String, key2: String) = {
             strict r = Invoke(addressFromStringValue(dapp2),bar,[a],[AttachedPayment(base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p',1000000)])
             (
                [
                   IntegerEntry(key1, r),
                   IntegerEntry(key2, wavesBalance(dapp2).regular)
                ],
                unit
             )
          }
          

          dApp2:

          {-# STDLIB_VERSION 5 #-}
          {-# CONTENT_TYPE DAPP #-}
          {-# SCRIPT_TYPE ACCOUNT #-}
          
          @Callable(i)
          func bar(a: Int) = {
             let 
             (
                [
                   ScriptTransfer(i.caller, 100000000, unit),
                ],
                a*2
             )
          }
          
          Hashing Functions
          List Functions
          Hashing Functions
          List Functions