# Functions for Getting Data from Account Data Storage
Learn more about the account data storage.
Name | Description | Complexity |
---|---|---|
getBinary(Address|Alias, String): ByteVector|Unit | Gets an array of bytes by key | 10 |
getBinary(String): ByteVector|Unit | Gets an array of bytes by key from the dApp's own data storage | 10 |
getBinaryValue(Address|Alias, String): ByteVector | Gets an array of bytes by key. Fails if there is no data | 10 |
getBinaryValue(String): ByteVector | Gets an array of bytes by key from the dApp's own data storage. Fails if there is no data | 10 |
getBoolean(Address|Alias, String): Boolean|Unit | Gets a boolean value by key | 10 |
getBoolean(String): Boolean|Unit | Gets a boolean value by key from the dApp's own data storage | 10 |
getBooleanValue(Address|Alias, String): Boolean | Gets a boolean value by key. Fails if there is no data | 10 |
getBooleanValue(String): Boolean | Gets a boolean value by key from the dApp's own data storage. Fails if there is no data | 10 |
getInteger(Address|Alias, String): Int|Unit | Gets an integer by key | 10 |
getInteger(String): Int|Unit | Gets an integer by key from the dApp's own data storage | 10 |
getIntegerValue(Address|Alias, String): Int | Gets an integer by key. Fails if there is no data | 10 |
getIntegerValue(String): Int | Gets an integer by key from the dApp's own data storage. Fails if there is no data | 10 |
getString(Address|Alias, String): String|Unit | Gets a string by key | 10 |
getString(String): String|Unit | Gets a string by key from the dApp's own data storage | 10 |
getStringValue(Address|Alias, String): String | Gets a string by key. Fails if there is no data | 10 |
getStringValue(String): String | Gets a string by key from the dApp's own data storage. Fails if there is no data | 10 |
isDataStorageUntouched(Address|Alias): Boolean | Checks if the data storage of a given account never contained any entries | 10 |
# getBinary(Address|Alias, String): ByteVector|Unit
Gets an array of bytes by key.
getBinary(addressOrAlias: Address|Alias, key: String): ByteVector|Unit
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let t = address.getBinary("bin")
match t {
case v: ByteVector => v.toBase64String()
case _ => throw("No entry with the 'bin' key")
}
# Returns "SGVsbG8gV2F2ZXM="
# getBinary(String): ByteVector|Unit
Gets an array of bytes by key from the dApp's own data storage.
getBinary(key: String): ByteVector|Unit
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# getBinaryValue(Address|Alias, String): ByteVector
Gets an array of bytes by key. Fails if there is no data.
getBinaryValue(addressOrAlias: Address|Alias, key: String): ByteVector
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let b = address.getBinaryValue("bin").toBase64String() # "SGVsbG8gV2F2ZXM="
address.getBinaryValue("nosuchkey").toBase64String() # Fails
# getBinaryValue(String): ByteVector
Gets an array of bytes by key from the dApp's own data storage.
getBinaryValue(key: String): ByteVector
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# getBoolean(Address|Alias, String): Boolean|Unit
Gets a boolean value by key.
getBoolean(addressOrAlias: Address|Alias, key: String): Boolean|Unit
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let t = address.getBoolean("bool") # true
let u = address.getBoolean("nosuchkey") # unit
let v = address.getBoolean("int") # unit
# getBoolean(String): Boolean|Unit
Gets a boolean value by key by key from the dApp's own data storage.
getBoolean(key: String): Boolean|Unit
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# getBooleanValue(Address|Alias, String): Boolean
Gets a boolean value by key. Fails if there is no data.
getBooleanValue(addressOrAlias: Address|Alias, key: String): Boolean
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let t = address.getBooleanValue("bool") # true
address.getBooleanValue("str") # Fails
# getBooleanValue(String): Boolean
Gets a boolean value by key from the dApp's own data storage.
getBooleanValue(key: String): Boolean
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# getInteger(Address|Alias, String): Int|Unit
Gets an integer by key.
getInteger(addressOrAlias: Address|Alias, key: String): Int|Unit
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let t = address.getInteger("int") # 1234567
let u = address.getInteger("nosuchkey") # unit
let v = address.getInteger("str") # unit
# getInteger(String): Int|Unit
Gets an integer by key from the dApp's own data storage.
getInteger(key: String): Int|Unit
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# getIntegerValue(Address|Alias, String): Int
Gets an integer by key. Fails if there is no data.
getIntegerValue(addressOrAlias: Address|Alias, key: String): Int
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let t = address.getIntegerValue("int") # 1234567
address.getIntegerValue("nosuchkey") # Fails
# getIntegerValue(String): Int
Gets an integer by key from the dApp's own data storage.
getIntegerValue(key: String): Int
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# getString(Address|Alias, String): String|Unit
Gets a string by key.
getString(addressOrAlias: Address|Alias, key: String): String|Unit
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let t = address.getString("str") # "some text"
let u = address.getString("nosuchkey") # unit
let v = address.getString("int") # unit
# getString(String): String|Unit
Gets a string by key from the dApp's own data storage.
getString(key: String): String|Unit
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# getStringValue(Address|Alias, String): String
Gets a string by key. Fails if there is no data.
getStringValue(addressOrAlias: Address|Alias, key: String): String
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
key : String | Entry key |
# Example
let address = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
let t = address.getStringValue("str") # "some text"
address.getStringValue("bool") # Fails
# getStringValue(String): String
Gets a string by key from the dApp's own data storage.
getStringValue(key: String): String
# Parameters
Parameter | Description |
---|---|
key : String | Entry key |
# isDataStorageUntouched(Address|Alias): Boolean
Checks if the data storage of a given account never contained any entries.
Returns false
if there was at least one entry in the account data storage even if the entry was deleted.
isDataStorageUntouched(addressOrAlias: Address|Alias): Boolean
# Parameters
Parameter | Description |
---|---|
addressOrAlias : Address|Alias | Address or alias of the account |
# Example
let addr = Address(base58'3N4iKL6ikwxiL7yNvWQmw7rg3wGna8uL6LU')
isDataStorageUntouched(addr) # Returns false