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
        • addressFromPublicKey(ByteVector): Address
        • parseBigInt(String): BigInt&#124;Unit
        • parseBigIntValue(String): BigInt
        • toBigInt(ByteVector): BigInt
        • toBigInt(ByteVector, Int, Int): BigInt
        • toBigInt(Int): BigInt
        • toBytes(Boolean): ByteVector
        • toBytes(Int): ByteVector
        • toBytes(String): ByteVector
        • toBytes(BigInt): ByteVector
        • toInt(BigInt): Int
        • toInt(ByteVector): Int
        • toString(Address): String
        • toString(BigInt): String
        • transferTransactionFromProto
      waves_logo Docs

          # Converting functions

          Name Description Complexity
          addressFromPublicKey(ByteVector): Address Gets the corresponding address of the account public key 1
          parseBigInt(String): BigInt|Unit Converts the string representation of a number to its big integer equivalent 1 for Standard library version 8
          65 for Standard library version 7 or 6
          parseBigIntValue(String): BigInt Converts the string representation of a number to its big integer equivalent.
          Fails if the string cannot be parsed
          1 for Standard library version 8
          65 for Standard library version 7 or 6
          parseInt(String): Int|Unit Converts the string representation of a number to its integer equivalent 2
          parseIntValue(String): Int Converts the string representation of a number to its integer equivalent.
          Fails if the string cannot be parsed
          2
          toBigInt(ByteVector): BigInt Converts an array of bytes to a big integer 1 for Standard library version 8
          65 for Standard library version 7 or 6
          toBigInt(ByteVector, Int, Int): BigInt Converts an array of bytes starting from a certain index to a big integer 1 for Standard library version 8
          65 for Standard library version 7 or 6
          toBigInt(Int): BigInt Converts an integer to a big integer 1
          toBytes(Boolean): ByteVector Converts a boolean value to an array of bytes 1
          toBytes(Int): ByteVector Converts an integer to an array of bytes 1
          toBytes(String): ByteVector Converts a string to an array of bytes 8
          toBytes(BigInt): ByteVector Converts a big integer to an array of bytes 1 for Standard library version 8
          65 for Standard library version 7 or 6
          toInt(BigInt): Int Converts a big integer to an integer.
          Fails if the number cannot be converted
          1
          toInt(ByteVector): Int Converts an array of bytes to an integer 1
          toInt(ByteVector, Int): Int Converts an array of bytes to an integer starting from a certain index 1
          toString(Address): String Converts an array of bytes of an address to a string 1
          toString(Boolean): String Converts a boolean value to a string 1
          toString(Int): String Converts an integer to a string 1
          toString(BigInt): String Converts a big integer to a string 1
          toUtf8String(ByteVector): String Converts an array of bytes to a UTF-8 string 7
          transferTransactionFromProto(ByteVector): TransferTransaction|Unit Deserializes transfer transaction 5

          # addressFromPublicKey(ByteVector): Address

          Gets the corresponding address of the account public key.

          Since version 6, the function fails if the key size is other than 32 bytes (Waves account) or 64 bytes (MetaMask account).

          addressFromPublicKey(publicKey: ByteVector): Address
          

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

          # Parameters

          Parameter Description
          publicKey: ByteVector Public key

          # Examples

          let address = addressFromPublicKey(base58'J1t6NBs5Hd588Dn7mAPytqkhgeBshzv3zecScfFJWE2D')
          

          # parseBigInt(String): BigInt|Unit

          Converts the string representation of a number to its big integer equivalent.

          parseBigInt(str: String): BigInt|Unit
          

          # Parameters

          Parameter Description
          str: String String to parse

          # parseBigIntValue(String): BigInt

          Converts the string representation of a number to its big integer equivalent.

          Fails if the string cannot be parsed.

          parseBigIntValue(str: String): BigInt
          

          # Parameters

          Parameter Description
          str: String String to parse

          # parseInt(String): Int|Unit

          Converts the string representation of a number to its integer equivalent.

          parseInt(str: String): Int|Unit
          

          # Parameters

          Parameter Description
          str: String String to parse

          # Examples

          parseInt("10") # Returns 10
          parseInt("010") # Returns 10
          parseInt("Ride") # Returns Unit
          parseInt("10.30") # Returns Unit
          

          # parseIntValue(String): Int

          Converts the string representation of a number to its integer equivalent.

          Fails if the string cannot be parsed.

          parseIntValue(str: String): Int
          

          # Parameters

          Parameter Description
          str: String String to parse

          # Examples

          parseIntValue("10") # Returns 10
          parseIntValue("010") # Returns 10
          parseIntValue("Ride") # Error while parsing string to integer
          parseIntValue("10.30") # Error while parsing string to integer
          parseIntValue("20 WAVES") # Error while parsing string to integer
          

          # toBigInt(ByteVector): BigInt

          Converts an array of bytes to a big integer using the big-endian byte order.

          toBigInt(bin: ByteVector): BigInt
          

          # Parameters

          Parameter Description
          bin: ByteVector Array of bytes to convert. Up to 64 bytes

          # toBigInt(ByteVector, Int, Int): BigInt

          Converts an array of bytes starting from a certain index to a big integer using the big-endian byte order.

          toBigInt(bin: ByteVector, offset: Int, size: Int): BigInt
          

          # Parameters

          Parameter Description
          bin: ByteVector Array of bytes to convert
          offset: Int Index to start from
          size: Int Number of bytes (subarray length) to convert. Up to 64

          # toBigInt(Int): BigInt

          Converts an integer to a big integer.

          toBigInt(n: Int): BigInt
          

          # Parameters

          Parameter Description
          n: Int Integer to convert

          # toBytes(Boolean): ByteVector

          Converts a boolean value to an array of bytes.

          toBytes(b: Boolean): ByteVector
          

          # Parameters

          Parameter Description
          b: Boolean Boolean to convert

          # Examples

          toBytes(true) # Returns base58'2'
          toBytes(false) # Returns base58'1'
          

          # toBytes(Int): ByteVector

          Converts an integer to an array of bytes using the big-endian byte order.

          toBytes(n: Int): ByteVector
          

          # Parameters

          Parameter Description
          n: Int Integer to convert

          # Examples

          toBytes(10) # Returns base58'1111111B'
          

          # toBytes(String): ByteVector

          Converts a string to an array of bytes.

          toBytes(s: String): ByteVector
          

          # Parameters

          Parameter Description
          s: String String to convert

          # Examples

          toBytes("Ride") # Returns base58'37BPKA'
          

          # toBytes(BigInt): ByteVector

          Converts a big integer to an array of bytes using the big-endian byte order.

          toBytes(n: BigInt): ByteVector
          

          # Parameters

          Parameter Description
          n: BigInt Big integer to convert

          # toInt(BigInt): Int

          Converts a big integer to an integer.

          Fails if the number cannot be converted

          toInt(n: BigInt): Int
          

          # Parameters

          Parameter Description
          n: BigInt Big integer to convert

          # toInt(ByteVector): Int

          Converts the initial 8 bytes of an array to an integer using the big-endian byte order.

          toInt(bin: ByteVector) : Int
          

          # Parameters

          Parameter Description
          bin: ByteVector Array of bytes to convert. The length of the array must be at least 8 bytes

          # Examples

          toInt(base64'AAAAAAAAAAw=')  # Returns 12
          toInt(base64'AAAAAw=')       # Fails: Array length is less than 8
          

          # toInt(ByteVector, Int): Int

          Converts 8 bytes starting at a specified index to an integer using the big-endian byte order.

          toInt(bin: ByteVector, offset: Int): Int
          

          # Parameters

          Parameter Description
          bin: ByteVector Array of bytes to convert
          offset: Int Index to start from. The length of the array starting from the index must be at least 8 bytes

          # Examples

          let bytes = toBytes("Ride on Waves")
          toInt(bytes, 2)  # Returns 7234224039401641825
          toInt(bytes, 6)  # Fails: Index out of bounds
          

          # toString(Address): String

          Converts an array of bytes of an address to a string.

          toString(addr: Address): String
          

          # Parameters

          Parameter Description
          addr: Address Address to convert

          # Examples

          let address = Address(base58'3NADPfTVhGvVvvRZuqQjhSU4trVqYHwnqjF')
          toString(address) # Returns "3NADPfTVhGvVvvRZuqQjhSU4trVqYHwnqjF"
          

          # toString(Boolean): String

          Converts a boolean value to a string.

          toString(b: Boolean): String
          

          # Parameters

          Parameter Description
          b: Boolean Boolean to convert

          # Examples

          toString(true) # Returns "true"
          toString(false) # Returns "false"
          

          # toString(Int): String

          Converts an integer to a string.

          toString(n: Int): String
          

          # Parameters

          Parameter Description
          n: Int Integer to convert

          # Examples

          toString(10) # Returns "10"
          

          # toString(BigInt): String

          Converts a big integer to a string.

          toString(n: BigInt): String
          

          # Parameters

          Parameter Description
          n: BigInt Big integer to convert

          # toUtf8String(ByteVector): String

          Converts an array of bytes to a UTF-8 string.

          Fails if the array of bytes cotains an invalid UTF-8 sequence.

          toUtf8String(u: ByteVector): String
          

          # Parameters

          Parameter Description
          u: ByteVector Array of bytes to convert

          # Examples

          let bytes = toBytes("Ride on Waves")
          toUtf8String(bytes) # Returns "Ride on Waves"
          

          # transferTransactionFromProto

          Deserializes transfer transaction: converts protobuf-encoded binary format specified in transaction.proto to a TransferTransaction structure. Returns unit if deserialization failed.

          transferTransactionFromProto(b: ByteVector): TransferTransaction|Unit
          

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

          # Parameters

          Parameter Description
          b: ByteVector Transfer transaction in protobuf-encoded binary format

          # Examples

          let transfer = base64'Cr4BCFQSIA7SdnwUqEBY+k4jUf9sCV5+xj0Ry/GYuwmDMCdKTdl3GgQQoI0GIPLIyqL6LSgDwgaHAQoWChT+/s+ZWeOWzh1eRnhdRL3Qh9bxGRIkCiBO/wEBhwH/f/+bAWBRMv+A2yiAOUeBc9rY+UR/a4DxKBBkGkcaRYCcAQAB//9/AX9//0695P8EiICAfxgBgIkefwHYuDmA//83/4ABJgEBAf8d9N+8AAERyo1/j3kAGn/SAb7YIH8y/4CAXg=='
          let x = match transferTransactionFromProto(transfer) {
              case ttx:TransferTransaction =>
                  ttx.amount # 3500000000
              case _ => throw("Can't find transaction")
          }
          
          Byte Array Functions
          dApp-to-dApp Invocation Function
          Byte Array Functions
          dApp-to-dApp Invocation Function