waves_logo Docs
  • Ride Programming Language
    Ride Programming Language
  • Getting Started
    Getting Started
  • Syntax Basics
    • Directives
      Directives
    • Definition
      Definition
    • Expression
      Expression
    • 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
    • Any
      Any
    • BigInt
      BigInt
    • 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
    • dApp-to-dApp Invocation Function
      dApp-to-dApp Invocation Function
    • 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
  • match ... case: Pattern Matching
    match ... case: Pattern Matching
  • Iterations with FOLD<N>
    Iterations with FOLD<N>
  • dApp-to-dApp Invocation
    dApp-to-dApp Invocation
  • Limitations
    • Complexity
      Complexity
    • Data Weight
      Data Weight
    Limitations
  • Previous Versions
    • Version 5
      • Callable Function
        Callable Function
      • Data types
        • Any
          Any
        • BigInt
          BigInt
        • 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
        • dApp-to-dApp Invocation Function
          dApp-to-dApp Invocation Function
        • 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
      • Limitations
        • Data Weight
          Data Weight
        Limitations
      Version 5
    • Version 4 and 3
      • Callable Function
        Callable Function
      • 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
      • Limitations
        • Data Weight
          Data Weight
        Limitations
      Version 4 and 3
    Previous Versions
  • Import Libraries
    Import Libraries
  • Ride Components
    Ride Components
      • English
      • Русский
      On this page
        • addressFromRecipient(Address|Alias): Address
        • assetBalance
        • assetInfo
        • blockInfoByHeight
        • calculateAssetId
        • calculateLeaseId
        • scriptHash
        • transactionHeightById
        • transferTransactionById
        • wavesBalance
      waves_logo Docs

          # [Ride v5] Blockchain functions

          ⚠️ This is the documentation for the Standard library version 5. We recommend to use version 6. Go to version 6

          Name Description Complexity
          addressFromRecipient(Address|Alias): Address Gets the corresponding address of the alias 5
          assetBalance(Address|Alias, ByteVector): Int Gets account balance by token ID 10
          assetInfo(ByteVector): Asset|Unit Gets the information about a token 15
          blockInfoByHeight(Int): BlockInfo|Unit Gets the information about a block by the block height 5
          calculateAssetId(Issue): ByteVector Calculates ID of the token formed by the Issue structure when executing the callable function 10
          calculateLeaseId(Lease): ByteVector Calculates ID of the lease formed by the Lease structure when executing the callable function 1
          scriptHash(Address|Alias): ByteVector|Unit Returns BLAKE2b-256 hash of the script assigned to a given account 200
          transactionHeightById(ByteVector): Int|Unit Gets the block height of a transaction 20
          transferTransactionById(ByteVector): TransferTransaction|Unit Gets the data of a transfer transaction 60
          wavesBalance(Address|Alias): BalanceDetails Gets account balance in WAVES 10

          # addressFromRecipient(Address|Alias): Address

          Gets the corresponding address of the alias.

          addressFromRecipient(AddressOrAlias: Address|Alias): Address
          

          For a description of the return value, see the Address article.

          # Parameters

          Parameter Description
          AddressOrAlias: Address|Alias
          Address or alias, usually tx.recipient

          # Examples

          let address =Address(base58'3NADPfTVhGvVvvRZuqQjhSU4trVqYHwnqjF')
          addressFromRecipient(address)
          

          # assetBalance

          Gets account balance by token ID.

          The balance takes into account payments attached to the script invocation. Transfers (ScriptTransfer) made by the current callable function do not affect the balance (however, nested invocations do).

          assetBalance(addressOrAlias: Address|Alias, assetId: ByteVector): Int
          

          # Parameters

          Parameter Description
          addressOrAlias: Address|Alias Address or alias of the account
          assetId: ByteVector Token ID

          # assetInfo

          Gets the information about a token.

          assetInfo(id: ByteVector): Asset|Unit
          

          For a description of the return value, see the Asset article.

          # Parameters

          Parameter Description
          id: ByteVector ID of the token

          # Example

          let bitcoinId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
          let x = match assetInfo(bitcoinId) {
              case asset:Asset =>
                  asset.decimals # 8
              case _ => throw("Can't find asset")
          }
          

          # blockInfoByHeight

          Gets the information about a block by the block height.

          blockInfoByHeight(height: Int): BlockInfo|Unit
          

          For a description of the return value, see the BlockInfo article.

          # Parameters

          Parameter Description
          height: Int Block height

          # Example

          let x = match blockInfoByHeight(1234567) {
              case block:BlockInfo =>
                  block.generator.toString() # "3P38Z9aMhGKAWnCiyMW4T3PcHcRaTAmTztH"
              case _ => throw("Can't find block")
          }
          

          # calculateAssetId

          Calculates ID of the token formed by the Issue structure when executing the callable function.

          calculateAssetId(issue: Issue): ByteVector
          

          # Parameters

          Parameter Description
          issue: Issue Structure that sets the parameters of the token issue

          # Example

          {-# STDLIB_VERSION 5 #-}
          {-# CONTENT_TYPE DAPP #-}
          {-# SCRIPT_TYPE ACCOUNT #-}
            
          @Callable(inv)
          func issueAndId() = {
            let issue = Issue("CryptoRouble", "Description", 1000, 2, true)
            let id = calculateAssetId(issue)
            (
              [
                issue,
                BinaryEntry("id", id)
              ],
              unit
            )
          }
          

          # calculateLeaseId

          Calculates ID of the lease formed by the Lease structure when executing the callable function.

          calculateLeaseId(lease: Lease): ByteVector
          

          # Parameters

          Parameter Description
          lease: Lease Structure that sets the lease parameters

          # Example

          {-# STDLIB_VERSION 5 #-}
          {-# CONTENT_TYPE DAPP #-}
          {-# SCRIPT_TYPE ACCOUNT #-}
            
          @Callable(i)
          func foo() = {
            let lease = Lease(Alias("merry"),100000000)
            let id = calculateLeaseId(lease)
            (
              [
                lease,
                BinaryEntry("lease", id)
              ],
              unit
            )
          }
          

          # scriptHash

          Returns BLAKE2b-256 hash of the script assigned to a given account. Returns unit if there is no script.

          The function can be used to verify that the script is exactly the same as expected.

          scriptHash(addressOrAlias: Address|Alias): ByteVector|Unit
          

          # Parameters

          Parameter Description
          addressOrAlias: Address|Alias Address or alias of the account

          # Example

          let addr = Address(base58'3MxBZbnN8Z8sbYjjL5N3oG5C8nWq9NMeCEm')
          
          scriptHash(addr) # Returns base58'G6ihnWN5mMedauCgNa8TDrSKWACPJKGQyYagmMQhPuja'
          

          # transactionHeightById

          Gets the block height of a transaction. Returns unit for failed transactions (see the Transaction Validation article) and transactions elided due to challenging a block (see the section Waves 1.5: Light Node).

          transactionHeightById(id: ByteVector): Int|Unit
          

          # Parameters

          Parameter Description
          id: ByteVector ID of the transaction

          # Example

          let bitcoinId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
          let x = match transactionHeightById(bitcoinId) {
              case h:Int => h # 257457
              case _ => throw("Can't find transaction")
          }
          

          # transferTransactionById

          Gets the data of a Transfer transaction. Returns unit for transactions elided due to challenging a block (see the section Waves 1.5: Light Node).

          transferTransactionById(id: ByteVector): TransferTransaction|Unit
          

          For a description of the return value, see the TransferTransaction article.

          # Parameters

          Parameter Description
          id: ByteVector ID of the transfer transaction

          # Example

          let transferId = base58'J2rcMzCWCZ1P3SFZzvz9PR2NtBjomDh57HTcqptaAJHK'
          let x = match transferTransactionById(transferId) {
              case ttx:TransferTransaction =>
                  ttx.amount # 3500000000
              case _ => throw("Can't find transaction")
          }
          

          # wavesBalance

          Gets all types of WAVES balances. For description of balance types, see the Account Balance article.

          The balances take into account payments attached to the script invocation. Transfers (ScriptTransfer) made by the current callable function do not affect the balances (however, nested invocations do).

          wavesBalance(addressOrAlias: Address|Alias): BalanceDetails
          

          For a description of the return value, see the BalanceDetails article.

          # Parameters

          Parameter Description
          addressOrAlias: Address|Alias Address or alias of the account
          Account Data Storage Functions
          Byte Array Functions
          Account Data Storage Functions
          Byte Array Functions