Converting functions

# Name Description Complexity
1 addressFromPublicKey(ByteVector): Address Gets the corresponding address of the account public key 82
2 addressFromRecipient(Address|Alias): Address Gets the corresponding address of the alias 100
3 parseInt(String): Int|Unit Converts the string representation of a number to its integer equivalent 20
4 parseIntValue(String): Int Converts the string representation of a number to its integer equivalent.
Raises an exception if the string cannot be parsed
20
5 toBytes(Boolean): ByteVector Converts a boolean value to an array of bytes 1
6 toBytes(Int): ByteVector Converts an integer to an array of bytes 1
7 toBytes(String): ByteVector Converts a string to an array of bytes 1
8 toInt(ByteVector): Int Converts an array of bytes to an integer 10
9 toInt(ByteVector, Int): Int Converts an array of bytes to an integer starting from a certain index 10
10 toString(Address): String Converts an array of bytes of an address to a string 10
11 toString(Boolean): String Converts a boolean value to a string 1
12 toString(Int): String Converts an integer to a string 1
13 toUtf8String(ByteVector): String Converts an array of bytes to a UTF-8 string 20

addressFromPublicKey(ByteVector): Address

Gets the corresponding address of the account public key.

addressFromPublicKey(publicKey: ByteVector): Address

Parameters

publicKey: ByteVector

Public key.

Examples

let address = addressFromPublicKey(base58'J1t6NBs5Hd588Dn7mAPytqkhgeBshzv3zecScfFJWE2D')

addressFromRecipient(Address|Alias): Address

Gets the corresponding address of the alias.

addressFromRecipient(AddressOrAlias: Address|Alias): Address

Parameters

AddressOrAlias: Address|Alias

Address or alias, usually tx.recipient.

Examples

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

parseInt(String): Int|Unit

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

parseInt(str: String): Int|Unit

Parameters

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.

Raises an exception if the string cannot be parsed.

parseIntValue(str: String): Int

Parameters

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

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

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

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

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

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

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

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

n: Int

Integer to convert.

Examples

toString(10) # Returns "10"

toUtf8String(ByteVector): String

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

toUtf8String(u: ByteVector): String

Parameters

u: ByteVector

Array of bytes to convert.

Examples

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

results matching ""

    No results matching ""