Class Utils
Convenience methods for algorand sdk.
Inheritance
Inherited Members
Namespace: Algorand
Assembly: Algorand.dll
Syntax
public class Utils
Methods
| Improve this Doc View SourceAlgosToMicroalgos(Double)
Declaration
public static ulong AlgosToMicroalgos(double algos)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | algos |
Returns
| Type | Description |
|---|---|
| System.UInt64 |
GetActivateAssetTransaction(Address, Nullable<UInt64>, TransactionParams, String)
DEPRECATED Please use GetAssetOptingInTransaction. Generate an opting in asset transaction All accounts that want recieve the new asset have to opt in
Declaration
public static Transaction GetActivateAssetTransaction(Address sender, ulong? assetId, TransactionParams trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | The account want to opt in |
| System.Nullable<System.UInt64> | assetId | Asset ID |
| TransactionParams | trans | The blockchain infomation |
| System.String | message | The message for the transaction(have no affect to the assect) |
Returns
| Type | Description |
|---|---|
| Transaction | transaction |
GetApplicationTransaction(Address, Int64, Int64, String, OnCompletion, Int64, List<Byte[]>, List<Address>, List<Int64>, List<Int64>)
Declaration
public static Transaction GetApplicationTransaction(Address sender, long firstValid, long lastValid, string genesishashb64, OnCompletion onCompletion, long applicationId, List<byte[]> applicationArgs, List<Address> accounts, List<long> foreignApps, List<long> foreignAssets)
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | |
| System.Int64 | firstValid | |
| System.Int64 | lastValid | |
| System.String | genesishashb64 | |
| OnCompletion | onCompletion | |
| System.Int64 | applicationId | |
| System.Collections.Generic.List<System.Byte[]> | applicationArgs | |
| System.Collections.Generic.List<Address> | accounts | |
| System.Collections.Generic.List<System.Int64> | foreignApps | |
| System.Collections.Generic.List<System.Int64> | foreignAssets |
Returns
| Type | Description |
|---|---|
| Transaction |
GetAssetOptingInTransaction(Address, Nullable<Int64>, TransactionParametersResponse, String)
Declaration
public static Transaction GetAssetOptingInTransaction(Address sender, long? assetID, TransactionParametersResponse trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | |
| System.Nullable<System.Int64> | assetID | |
| TransactionParametersResponse | trans | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetAssetOptingInTransaction(Address, Nullable<UInt64>, TransactionParams, String)
Generate an opting in asset transaction All accounts that want recieve the new asset have to opt in
Declaration
public static Transaction GetAssetOptingInTransaction(Address sender, ulong? assetId, TransactionParams trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | The account want to opt in |
| System.Nullable<System.UInt64> | assetId | Asset ID |
| TransactionParams | trans | The blockchain infomation |
| System.String | message | The message for the transaction(have no affect to the assect) |
Returns
| Type | Description |
|---|---|
| Transaction | transaction |
GetBidTransaction(Address, Address, SignedBid, TransactionParams)
Declaration
public static Transaction GetBidTransaction(Address bidder, Address auction, SignedBid signedBid, TransactionParams trans)
Parameters
| Type | Name | Description |
|---|---|---|
| Address | bidder | |
| Address | auction | |
| SignedBid | signedBid | |
| TransactionParams | trans |
Returns
| Type | Description |
|---|---|
| Transaction |
GetConfigAssetTransaction(Address, Asset, TransactionParametersResponse, String)
Declaration
public static Transaction GetConfigAssetTransaction(Address sender, Asset asset, TransactionParametersResponse trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | |
| Asset | asset | |
| TransactionParametersResponse | trans | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetConfigAssetTransaction(Address, Nullable<UInt64>, AssetParams, TransactionParams, String)
Generate an asset config transaction
Declaration
public static Transaction GetConfigAssetTransaction(Address sender, ulong? assetId, AssetParams asset, TransactionParams trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | The sender of the transaction, should be the manager of the asset. |
| System.Nullable<System.UInt64> | assetId | Asset ID |
| AssetParams | asset | Asset infomation |
| TransactionParams | trans | The blockchain infomation |
| System.String | message | The message for the transaction(have no affect to the assect) |
Returns
| Type | Description |
|---|---|
| Transaction | transaction |
GetCreateAssetTransaction(AssetParams, TransactionParams, String, Int32)
Generate a create asset transaction
Declaration
public static Transaction GetCreateAssetTransaction(AssetParams asset, TransactionParams trans, string message = "", int decimals = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| AssetParams | asset | The asset infomation |
| TransactionParams | trans | The blockchain infomation |
| System.String | message | The message for the transaction(have no affect to the assect) |
| System.Int32 | decimals | A value of 0 represents an asset that is not divisible, while a value of 1 represents an asset that is divisible into tenths and so on, i.e, the number of digits to display after the decimal place when displaying the asset. This value must be between 0 and 19 |
Returns
| Type | Description |
|---|---|
| Transaction | transaction |
GetCreateAssetTransaction(AssetParams, TransactionParametersResponse, String)
Generate a create asset transaction V2
Declaration
public static Transaction GetCreateAssetTransaction(AssetParams asset, TransactionParametersResponse trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| AssetParams | asset | The asset infomation |
| TransactionParametersResponse | trans | The blockchain infomation |
| System.String | message | The message for the transaction(have no affect to the assect) |
Returns
| Type | Description |
|---|---|
| Transaction | transaction |
GetDestroyAssetTransaction(Address, Nullable<Int64>, TransactionParametersResponse, String)
Declaration
public static Transaction GetDestroyAssetTransaction(Address manager, long? assetId, TransactionParametersResponse trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | manager | |
| System.Nullable<System.Int64> | assetId | |
| TransactionParametersResponse | trans | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetDestroyAssetTransaction(Address, Nullable<UInt64>, TransactionParams, String)
Declaration
public static Transaction GetDestroyAssetTransaction(Address manager, ulong? assetId, TransactionParams trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | manager | |
| System.Nullable<System.UInt64> | assetId | |
| TransactionParams | trans | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetDryrunResponse(AlgodApi, SignedTransaction, Byte[])
Declaration
public static DryrunResponse GetDryrunResponse(AlgodApi client, SignedTransaction stxn, byte[] source = null)
Parameters
| Type | Name | Description |
|---|---|---|
| AlgodApi | client | |
| SignedTransaction | stxn | |
| System.Byte[] | source |
Returns
| Type | Description |
|---|---|
| DryrunResponse |
GetFreezeAssetTransaction(Address, Address, Nullable<Int64>, Boolean, TransactionParametersResponse, String)
Declaration
public static Transaction GetFreezeAssetTransaction(Address sender, Address toFreeze, long? assetId, bool freezeState, TransactionParametersResponse trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | |
| Address | toFreeze | |
| System.Nullable<System.Int64> | assetId | |
| System.Boolean | freezeState | |
| TransactionParametersResponse | trans | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetFreezeAssetTransaction(Address, Address, Nullable<UInt64>, Boolean, TransactionParams, String)
Generate an asset freeze transaction
Declaration
public static Transaction GetFreezeAssetTransaction(Address sender, Address toFreeze, ulong? assetId, bool freezeState, TransactionParams trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | sender | The sender of the transaction, should be the freezer of the asset. |
| Address | toFreeze | The account which hold the asset will be frozen. |
| System.Nullable<System.UInt64> | assetId | Asset ID |
| System.Boolean | freezeState | true to frozen the asset, false to unfrozen the asset. |
| TransactionParams | trans | The blockchain infomation |
| System.String | message | The message for the transaction(have no affect to the assect) |
Returns
| Type | Description |
|---|---|
| Transaction | transaction |
GetPaymentTransaction(Address, Address, Nullable<UInt64>, String, TransactionParams)
Get a payment transaction
Declaration
public static Transaction GetPaymentTransaction(Address from, Address to, ulong? amount, string message, TransactionParams trans)
Parameters
| Type | Name | Description |
|---|---|---|
| Address | from | from address |
| Address | to | to address |
| System.Nullable<System.UInt64> | amount | amount(Unit:MicroAlgo) |
| System.String | message | message |
| TransactionParams | trans | Transaction Params(use AlgodApi.TransactionParams() function to get the params) |
Returns
| Type | Description |
|---|---|
| Transaction | payment transaction |
GetPaymentTransaction(Address, Address, Nullable<UInt64>, String, TransactionParametersResponse)
Get a payment transaction
Declaration
public static Transaction GetPaymentTransaction(Address from, Address to, ulong? amount, string message, TransactionParametersResponse trans)
Parameters
| Type | Name | Description |
|---|---|---|
| Address | from | from address |
| Address | to | to address |
| System.Nullable<System.UInt64> | amount | amount(Unit:MicroAlgo) |
| System.String | message | message |
| TransactionParametersResponse | trans | Transaction Params(use AlgodApi.TransactionParams() function to get the params) |
Returns
| Type | Description |
|---|---|
| Transaction | payment transaction |
GetPaymentTransactionWithInfo(Address, Address, Nullable<UInt64>, String, Nullable<UInt64>, Nullable<UInt64>, String, String)
Declaration
public static Transaction GetPaymentTransactionWithInfo(Address from, Address to, ulong? amount, string message, ulong? fee, ulong? lastRound, string genesisId, string genesishashb64)
Parameters
| Type | Name | Description |
|---|---|---|
| Address | from | |
| Address | to | |
| System.Nullable<System.UInt64> | amount | |
| System.String | message | |
| System.Nullable<System.UInt64> | fee | |
| System.Nullable<System.UInt64> | lastRound | |
| System.String | genesisId | |
| System.String | genesishashb64 |
Returns
| Type | Description |
|---|---|
| Transaction |
GetRandomAssetMetaHash()
Generate a 32 bytes string for asset metadata hash
Declaration
public static string GetRandomAssetMetaHash()
Returns
| Type | Description |
|---|---|
| System.String | a 32 bytes string |
GetRevokeAssetTransaction(Address, Address, Address, Nullable<Int64>, UInt64, TransactionParametersResponse, String)
Declaration
public static Transaction GetRevokeAssetTransaction(Address reserve, Address revokedFrom, Address receiver, long? assetId, ulong amount, TransactionParametersResponse trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | reserve | |
| Address | revokedFrom | |
| Address | receiver | |
| System.Nullable<System.Int64> | assetId | |
| System.UInt64 | amount | |
| TransactionParametersResponse | trans | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetRevokeAssetTransaction(Address, Address, Address, Nullable<UInt64>, UInt64, TransactionParams, String)
Declaration
public static Transaction GetRevokeAssetTransaction(Address reserve, Address revokedFrom, Address receiver, ulong? assetId, ulong amount, TransactionParams trans, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | reserve | |
| Address | revokedFrom | |
| Address | receiver | |
| System.Nullable<System.UInt64> | assetId | |
| System.UInt64 | amount | |
| TransactionParams | trans | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetTransferAssetTransaction(Address, Address, Nullable<Int64>, UInt64, TransactionParametersResponse, Address, String)
Declaration
public static Transaction GetTransferAssetTransaction(Address from, Address to, long? assetId, ulong amount, TransactionParametersResponse trans, Address closeTo = null, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | from | |
| Address | to | |
| System.Nullable<System.Int64> | assetId | |
| System.UInt64 | amount | |
| TransactionParametersResponse | trans | |
| Address | closeTo | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
GetTransferAssetTransaction(Address, Address, Nullable<UInt64>, UInt64, TransactionParams, Address, String)
Declaration
public static Transaction GetTransferAssetTransaction(Address from, Address to, ulong? assetId, ulong amount, TransactionParams trans, Address closeTo = null, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Address | from | |
| Address | to | |
| System.Nullable<System.UInt64> | assetId | |
| System.UInt64 | amount | |
| TransactionParams | trans | |
| Address | closeTo | |
| System.String | message |
Returns
| Type | Description |
|---|---|
| Transaction |
MicroalgosToAlgos(UInt64)
Declaration
public static double MicroalgosToAlgos(ulong microAlgos)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | microAlgos |
Returns
| Type | Description |
|---|---|
| System.Double |
SubmitTransaction(AlgodApi, SignedTransaction)
encode and submit signed transaction
Declaration
public static TransactionID SubmitTransaction(AlgodApi instance, SignedTransaction signedTx)
Parameters
| Type | Name | Description |
|---|---|---|
| AlgodApi | instance | |
| SignedTransaction | signedTx |
Returns
| Type | Description |
|---|---|
| TransactionID |
SubmitTransaction(AlgodApi, SignedTransaction)
encode and submit signed transaction using algod v2 api
Declaration
public static PostTransactionsResponse SubmitTransaction(AlgodApi instance, SignedTransaction signedTx)
Parameters
| Type | Name | Description |
|---|---|---|
| AlgodApi | instance | |
| SignedTransaction | signedTx |
Returns
| Type | Description |
|---|---|
| PostTransactionsResponse |
WaitTransactionToComplete(AlgodApi, String)
wait transaction to complete
Declaration
public static string WaitTransactionToComplete(AlgodApi instance, string txID)
Parameters
| Type | Name | Description |
|---|---|---|
| AlgodApi | instance | |
| System.String | txID |
Returns
| Type | Description |
|---|---|
| System.String |
WaitTransactionToComplete(AlgodApi, String)
wait transaction to complete using algod v2 api
Declaration
public static string WaitTransactionToComplete(AlgodApi instance, string txID)
Parameters
| Type | Name | Description |
|---|---|---|
| AlgodApi | instance | |
| System.String | txID |
Returns
| Type | Description |
|---|---|
| System.String |