# [Ride v4 and v3] Blockchain functions
⚠️ This is the documentation for the Standard library version 4 and 3. We recommend to use version 6. Go to version 6
Name | Description | Complexity |
---|---|---|
addressFromRecipient(Address|Alias): Address | Gets the corresponding address of the alias | 100 for Standard Library version 3 5 for Standard Library version 4 |
assetBalance(Address|Alias, ByteVector): Int | Gets account balance by token ID | 100 for Standard Library version 3 10 for Standard Library version 4 |
assetInfo(ByteVector): Asset|Unit | Gets the information about a token | 100 for Standard Library version 3 15 for Standard Library version 4 |
blockInfoByHeight(Int): BlockInfo|Unit | Gets the information about a block by the block height | 100 for Standard Library version 3 5 for Standard Library version 4 |
calculateAssetId(Issue): ByteVector | Calculates the ID of the asset, created by Issue structure during invoke script transaction execution | 10 |
transactionHeightById(ByteVector): Int|Unit | Gets the block height of a transaction | 100 for Standard Library version 3 20 for Standard Library version 4 |
transferTransactionById(ByteVector): TransferTransaction|Unit | Gets the data of a transfer transaction | 100 for Standard Library version 3 60 for Standard Library version 4 |
wavesBalance(Address|Alias): BalanceDetails | Gets account balance in WAVES | 100 for Standard Library version 3 10 for Standard Library version 4 |
# addressFromRecipient(Address|Alias): Address
Gets the corresponding address of the alias.
addressFromRecipient(AddressOrAlias: Address|Alias): Address
For a description of the return value, see the Address article.
# Parameters
Parameter | Description |
---|---|
AddressOrAlias: Address|Alias | |
Address or alias, usually tx.recipient |
# Examples
let address =Address(base58'3NADPfTVhGvVvvRZuqQjhSU4trVqYHwnqjF')
addressFromRecipient(address)
# assetBalance
Gets account balance by token ID.
The balance does not take into account payments attached to the script invocation (this only applies to version 4 and 3 of the Standard library). The balance does not take into account transfers (ScriptTransfer
) made by the callable function.
assetBalance(addressOrAlias: Address|Alias, assetId: ByteVector): Int
# Parameters
Parameter | Description |
---|---|
addressOrAlias: Address|Alias | Address or alias of the account |
assetId: ByteVector | Token ID |
# assetInfo
Gets the information about a token.
assetInfo(id: ByteVector): Asset|Unit
For a description of the return value, see the Asset article.
# Parameters
Parameter | Description |
---|---|
id : ByteVector | ID of the token |
# Example
let bitcoinId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
let x = match assetInfo(bitcoinId) {
case asset:Asset =>
asset.decimals # 8
case _ => throw("Can't find asset")
}
# blockInfoByHeight
Gets the information about a block by the block height.
blockInfoByHeight(height: Int): BlockInfo|Unit
For a description of the return value, see the BlockInfo article.
# Parameters
Parameter | Description |
---|---|
height : Int | Block height |
# Example
let x = match blockInfoByHeight(1234567) {
case block:BlockInfo =>
block.generator.toString() # "3P38Z9aMhGKAWnCiyMW4T3PcHcRaTAmTztH"
case _ => throw("Can't find block")
}
# calculateAssetId
Calculates the ID of the asset, created by Issue structure during invoke script transaction execution.
⚠️ The
calculateAssetId
function is added in Standard library version 4.
calculateAssetId(issue: Issue): ByteVector
# Parameters
Parameter | Description |
---|---|
issue : Issue | The structure by which the asset is formed |
# Example
{-# STDLIB_VERSION 4 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
@Callable(inv)
func issueAndSend() = {
let issue = Issue("CryptoRouble", "Description", 1000, 2, true)
let id = calculateAssetId(issue)
[
issue,
ScriptTransfer(inv.caller, issue.quantity, id),
BinaryEntry("id", id)
]
}
// Result:
// {
// "type": "string",
// "value": "55jbTUxWkbLbfd6Z7Wy93DcyD7xikBg5GRDmccD4s8uv",
// "key": "id"
// }
# transactionHeightById
Gets the block height of a transaction. Returns unit
for failed transactions (see the Transaction Validation article) and transactions elided due to challenging a block (see the section Waves 1.5: Light Node).
transactionHeightById(id: ByteVector): Int|Unit
# Parameters
Parameter | Description |
---|---|
id : ByteVector | ID of the transaction |
# Example
let bitcoinId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
let x = match transactionHeightById(bitcoinId) {
case h:Int => h # 257457
case _ => throw("Can't find transaction")
}
# transferTransactionById
Gets the data of a Transfer transaction. Returns unit
for transactions elided due to challenging a block (see the section Waves 1.5: Light Node).
transferTransactionById(id: ByteVector): TransferTransaction|Unit
For a description of the return value, see the TransferTransaction article.
# Parameters
Parameter | Description |
---|---|
id : ByteVector | ID of the transfer transaction |
# Example
let transferId = base58'J2rcMzCWCZ1P3SFZzvz9PR2NtBjomDh57HTcqptaAJHK'
let x = match transferTransactionById(transferId) {
case ttx:TransferTransaction =>
ttx.amount # 3500000000
case _ => throw("Can't find transaction")
}
# wavesBalance
# For Standard Library Version 3
Gets available balance of WAVES.
The balance does not take into account payments attached to the script invocation (this only applies to version 4 and 3 of the Standard library). The balance does not take into account transfers (ScriptTransfer
) made by the callable function.
wavesBalance(addressOrAlias: Address|Alias): Int
# For Standard Library Version 4
Gets all types of WAVES balances. For description of balance types, see the Account Balance article.
The balances do not take into account payments attached to the script invocation (this only applies to version 4 and 3 of the Standard library). The balances do not take into account transfers (ScriptTransfer
) made by the callable function.
wavesBalance(addressOrAlias: Address|Alias): BalanceDetails
For a description of the return value, see the BalanceDetails article.
# Parameters
Parameter | Description |
---|---|
addressOrAlias: Address|Alias | Address or alias of the account |