# 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")
}