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
        • addressFromPublicKey(ByteVector): Address
        • toBytes(Boolean): ByteVector
        • toBytes(Int): ByteVector
        • toBytes(String): ByteVector
        • toInt(ByteVector): Int
        • toString(Address): String
        • transferTransactionFromProto
      waves_logo Docs

          # Converting functions

          Name Description Complexity
          addressFromPublicKey(ByteVector): Address Gets the corresponding address of the account public key 82 for Standard Library version 3
          63 for Standard Library version 4
          parseInt(String): Int|Unit Converts the string representation of a number to its integer equivalent 20 for Standard Library version 3
          2 for Standard Library version 4
          parseIntValue(String): Int Converts the string representation of a number to its integer equivalent.
          Fails if the string cannot be parsed
          20 for Standard Library version 3
          2 for Standard Library version 4
          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 1 for Standard Library version 3
          8 for Standard Library version 4
          toInt(ByteVector): Int Converts an array of bytes to an integer 10 for Standard Library version 3
          1 for Standard Library version 4
          toInt(ByteVector, Int): Int Converts an array of bytes to an integer starting from a certain index 10 for Standard Library version 3
          1 for Standard Library version 4
          toString(Address): String Converts an array of bytes of an address to a string 10
          toString(Boolean): String Converts a boolean value to a string 1
          toString(Int): String Converts an integer to a string 1
          toUtf8String(ByteVector): String Converts an array of bytes to a UTF-8 (opens new window) string 20 for Standard Library version 3
          7 for Standard Library version 4
          transferTransactionFromProto(ByteVector): TransferTransaction|Unit Deserializes transfer transaction 5

          # addressFromPublicKey(ByteVector): Address

          Gets the corresponding address of the account public key.

          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')
          

          # 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
          

          # 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 2
          toBytes(false) # Returns 1
          

          # toBytes(Int): ByteVector

          Converts an integer to an array of bytes.

          toBytes(n: Int): ByteVector
          

          # Parameters

          Parameter Description
          n: Int Integer to convert

          # Examples

          toBytes(10) # Returns 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 37BPKA
          

          # toInt(ByteVector): Int

          Converts an array of bytes to an integer.

          toInt(bin: ByteVector) : Int
          

          # Parameters

          Parameter Description
          bin: ByteVector Array of bytes to convert

          # Examples

          toInt(bytes) # Returns 10
          

          # toInt(ByteVector, Int): Int

          Converts an array of bytes to an integer starting from a certain index.

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

          # Parameters

          Parameter Description
          bin: ByteVector Array of bytes to convert
          offset: Int Index to start from

          # Examples

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

          # toString(Address): String

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

          toString(Address: Address): String
          

          # Parameters

          Parameter Description
          Address: 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"
          

          # toUtf8String(ByteVector): String

          Converts an array of bytes to a UTF-8 (opens new window) string.

          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 (opens new window) to a TransferTransaction structure. Returns unit if deserialization failed.

          ⚠️ The functions is added in Standard library version 4.

          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
          Data Transaction Functions
          Byte Array Functions
          Data Transaction Functions