cardano_wallet_sdk library Null safety

Classes

AdaDateTime
Convert Cardano block time (secondsSinceEpoch in UTC) to DateTime and back.
AdaDateTimeDecoder
AdaDateTimeEncoder
AdaFormattter
ADA-specific currency formatter that expects all curreny to be in lovelace and converts it to ADA (1 ADA = 1,000,000 lovelace). Compact formatters replace groups of zeros with quantity abbreviation suffixes (i.e. K=thousond, M=million, B=billion & T=trillion). The simple formatters group zeros into threes. Decimal digits defaults to 6 places. The currency factory method allows complete customization.
AssetRequest
an single asset name and value under a MultiAsset policyId
Bip32KeyPair
Private/signing and public/varification key pair.
Block
Block record
BlockchainAdapter
High-level abstraction to blockchain tailored towards balences and transactions.
BlockchainAdapterFactory
Provides a properly configured BlockchainAdapter for the requirested network. Instances are cached and should be reused because they often cache invariant blockchain data allowing for faster updates.
BlockchainCache
The cache holds invariant block chain data.
BlockfrostApiKeyAuthInterceptor
BlockfrostBlockchainAdapter
Loads BlockFrost data into this wallet model
CardanoBlockchainExplorer
Cardano Blockchain Explorer url generator for common blockchain web pages. Supports both mainnet and testnet networks and i18n language translations.
CardanoScanBlockchainExplorer
Cardano Scan Blockchain Explorer url generator for common blockchain web pages. Supports both mainnet and testnet networks.
CBORMetadata
Allow arbitrary metadata via raw CBOR type. Use MapBuilder and ListBuilder instances to compose complex nested structures.
CoinGeckoApiFix
Coin Gecko service to get real-time exchange trading values.
CoingeckoPriceService
CoinSelection
CoinSelectionError
CurrencyAsset
CurrencyAssetMetadata
HdWallet
This class implements a hierarchical deterministic wallet that generates cryptographic keys and addresses given a root signing key. It also supports the creation/restoration of the root signing key from a set of nmemonic BIP-39 words. Cardano Shelley addresses are supported by default, but the code is general enough to support any wallet based on the BIP32-ED25519 standard.
LinearFee
Used in calculating Cardano transaction fees.
MultiAssetBuilder
Special builder for creating ShelleyValue objects containing multi-asset transactions.
MultiAssetRequest
Native Token multi-asset container.
MultiAssetRequestBuilder
Special builder for creating ShelleyValue objects containing multi-asset transactions.
Price
Used for tracking currency trading pair prices (i.e. ADA to USD).
PriceService
not being used at the moment. see price_polling_service
RawTransaction
Raw transactions mirror the data on the blockchain. Amounts in lovelace.
RawTransactionImpl
ReadOnlyWallet
Cardano read-only wallet that holds transactions, staking rewards and their associated addresses. A public, read-ony wallet can be built given a stakingAddress and a networkId. All blockchain data retrieval is delegated to the BlockchainAdapter.
ReadOnlyWalletImpl
Given a stakingAddress, generate a read-only wallet with balances of all native assets, transaction history, staking and reward history.
ShelleyAddress
ShelleyAddressKit
Everything you need to add a spend (or change) address to a UTxO transaction.
ShelleyAsset
an single asset name and value under a MultiAsset policyId
ShelleyMultiAsset
Native Token multi-asset container.
ShelleyNativeScript
TODO ShelleyNativeScript is just a place-holder for these concrete classes: ScriptPubkey, ScriptAll, ScriptAny, ScriptAtLeast, RequireTimeAfter, RequireTimeBefore
ShelleyTransaction
outer wrapper of a Cardano blockchain transaction.
ShelleyTransactionBody
Core of the Shelley transaction that is signed.
ShelleyTransactionInput
Points to an UTXO unspent change entry using a transactionId and index.
ShelleyTransactionOutput
Address to send to and amount to send.
ShelleyTransactionWitnessSet
this can be transaction signatures or a full blown smart contract
ShelleyValue
Can be a simple ADA amount using coin or a combination of ADA and Native Tokens and their amounts.
ShelleyVkeyWitness
A witness is a public key and a signature (a signed hash of the body) used for on-chain validation.
StakeAccount
StakePool
StakePoolMetadata
StakeReward
TransactionAmount
Amount and type for a specific native token.
TransactionBuilder
This builder manages the details of assembling a balanced transaction, including fee calculation, change callculation, time-to-live constraints (ttl) and signing.
TransactionInput
Inputs or outputs for a given transaction.
TransactionOutput
Wallet
Extend ReadOnlyWallet with signing and transactional capabilities. Signing (private), key, verify (public) key and address generation is handled by the HdWallet instance.
WalletBuilder
This builder creates both read-only and transactional wallets from provided properties. Generated from a staking addresses, read-only wallets can show a balance and recieve funds, but can't sign or send payment transactions. Transactional wallets require a cryptographic private/signing key and can sign and send payment transactions. Alternatively, private keys can be generated from a 24-word mnemonic phrase. A BlockchainAdapter is used to communicate with the blockchain, it defaults to BlockfrostBlockchainAdapter for which an authorization adapter key must be provided for the target network. Each wallet type has a sync-varient build method that will load it's transactions and calculate the current balance before returning. Finally, all wallets must choose to run on either the mainnet or testnet.
WalletCache<T>
Wallet cache interface.
WalletCacheMemory<T>
Implements an in-memory version of WalletCache.
WalletImpl
Build transactional wallet by combining features of HdWallet, TransactionBuilder and ReadOnlyWallet.
WalletTransaction
Transaction from owning wallet perspective (i.e. filters raw transaction deposits and withdrawals specific to owned addresses).
WalletTransactionImpl
WalletUpdate
Pass-back object used to update existing or new wallets.
WalletValue<T>

Extensions

ShelleyTransactionBodyLogic
Handle balance checks and generating/modifying the correct change output so that the sum of inputs and output is zero (i.e. is balanced).
ShelleyTransactionLogic
Extends ShelleyTransaction to handle signature verification.
TransactionScanner
Transaction extension - wallet attribute collection methods

Constants

adaDateTime → const AdaDateTime
baseDiscrim → const int
0x00
changeRole → const int
role 1=internal/change
1
cip16ExtendedSigningKeySize → const int
Extended private key size in bytes
96
cip16ExtendedVerificationgKeySize → const int
Extended public key size in bytes
64
coinZero → const Coin
placeholder for future BigInt.zero
0
defaultAccountIndex → const int
Is zero. This returns the base account address.
0 | hardenedOffset
defaultAddressIndex → const int
0
defaultAddrHrp → const String
'addr'
defaultCoinSelectionLimit → const int
20
defaultCoinType → const int
Coin-type for Cardano ADA. Ada Lovelace's year of birth.
1815 | hardenedOffset
defaultFee → const int
default fee for simple ADA transaction
170000
defaultLinearFee → const LinearFee
fee calculation factors TODO update this from blockchain TODO verify fee calculation context of this values
LinearFee(coefficient: minFeeA, constant: minFeeB)
defaultPurpose → const int
Default purpose. The year Ada Lovelace passed away. Reference: CIP-1852
1852 | hardenedOffset
defaultRewardHrp → const String
'stake'
enterpriseDiscrim → const int
0x60
firstOneSecondEpoch → const int
208
firstSlotOfEpoch208 → const int
4492800
hardenedOffset → const int
Hardended chain values should not have public keys. They are denoted by a single quote in chain values.
0x80000000
lenHackAddition → const int
5
lovelaceAssetId → const String
lovelaceHex
lovelaceHex → const String
'lovelace' encoded as a hex string (i.e. str2hex.encode('lovelace') or '6c6f76656c616365').
'6c6f76656c616365'
millisecondsPerEpoch0_207 → const int
slotsPerEpoch0_207 * millisecondsPerSlot0_207
millisecondsPerEpochGt207 → const int
slotsPerEpochGt207 * millisecondsPerSlotGt207
millisecondsPerSlot0_207 → const int
20 * 1000
millisecondsPerSlotGt207 → const int
1 * 1000
minFeeA → const int
44
minFeeB → const int
155381
paymentRole → const int
role 0=external/payments
0
pointerDiscrim → const int
0x40
rewardDiscrim → const int
0xe0
secretKeyLength → const int
32
slotsPerEpoch0_207 → const int
21600
slotsPerEpochGt207 → const int
432000
stakingRole → const int
role 2=staking
2
testnetHrpSuffix → const String
'_test'

Properties

epoch0Slot0Utc DateTime
final
epoch0Slot0UtcMs int
final
hex2str Codec<String, String>
final
lovelacePseudoAsset CurrencyAsset
Pseudo ADA asset instance allows principal asset to be treated like other native tokens. Blockfrost returns 'lovelace' as the currency unit, whereas all other native tokens are identified by their assetId, a hex string. For consistency, 'lovelace' unit values must be converted to lovelaceHex strings.
final
str2hex Codec<String, String>
Various encoders, decoders and type converters.
final

Functions

alwaysUnused(dynamic _) bool
UnusedAddressFunction that will always return true (i.e. You'll always get the base spend/change address).
b2s(List<int> bytes, {String prefix = 'bytes'}) String
Dump byte array. Example: bytes20: 244,155,227,187,150,186,199,61,202,241,76,208,46,192,219,56,241,103,253,67
bech32ShelleyAddressFromBytes(Uint8Buffer bytes) String
Convert bytes to bech32 Shelley address. TODO move to shelley_address.dart
blake2bHash(List<int> stringBytes, {required int digestSize}) List<int>
Base blake2b hash function can produce hashes of arbirary size.
blake2bHash160(List<int> stringBytes) List<int>
blake2bHash224(List<int> stringBytes) List<int>
blake2bHash256(List<int> stringBytes) List<int>
calculateFingerprint({required String policyId, required String assetNameHex, String hrp = 'asset'}) String
given a asset policyId and an assetName in hex, generate a bech32 asset fingerprint
convertBits(List<int> data, int fromWidth, int toWidth, bool pad) List<int>
dioCall<T extends Object>({required NetworkRquest request, OneArgFunction? onSuccess, ResponseFunction? onError, String? errorSubject}) Future<Result<T, String>>
DIO network request wrapper that handles checking response and packaging result or error message. Returns an oxidizer Result.
epochToDateTime({int epoch = 0}) DateTime
convert epoch to UTC timestamp
epochToMilliseconds({int epoch = 0}) int
convert epoch to unix time in milliseconds
harden(int index) int
Hardens index, meaning it won't have a public key
hexFromShelleyAddress(String bech32, {bool uppercase = false}) String
Convert bech32 address payload to hex string. Optionaly uppercase hex string. TODO move to shelley_address.dart
hexFromUnit8Buffer(Uint8Buffer bytes) String
isHardened(int index) bool
Returns true if index is hardened.
largestFirst({required List<WalletTransaction> unspentInputsAvailable, required List<MultiAssetRequest> outputsRequested, required Set<ShelleyAddress> ownedAddresses, int coinSelectionLimit = defaultCoinSelectionLimit, bool logSelection = false}) Future<Result<CoinSelection, CoinSelectionError>>
signEd25519({required Uint8List message, required Uint8List privateKey}) Uint8List
Cryptographic signature methods.
signEd25519Extended({required Uint8List message, required Uint8List privateKey, required Uint8List publicKey}) Uint8List
Sign a message with a ed25519 expanded private key and return signature
simpleMinFee({required ShelleyTransaction transaction, LinearFee linearFee = defaultLinearFee}) Coin
calculate transaction fee based on transaction lnegth and minimum constant
slotToDateTime({int slot = 0}) DateTime
convert slot to UTC timestamp
slotToMilliseconds({int slot = 0}) int
convert slot to unix time in milliseconds
translateErrorMessage({required DioError dioError, String? subject}) String
blockfrost error codes to user readable messages
uint8BufferFromHex(String hex, {bool utf8EncodeOnHexFailure = false}) Uint8Buffer
convert hex string to Uint8Buffer. Strips off 0x prefix if present.
uint8ListFromBytes(List<int> bytes) Uint8List
Convert List
unit8BufferFromBytes(List<int> bytes) Uint8Buffer
Convert List
unit8BufferFromShelleyAddress(String bech32) Uint8Buffer
Convert bech32 address payload to hex adding network prefix. TODO move to shelley_address.dart
validAda({required String ada, int decimalPrecision = 6, bool allowNegative = false, bool zeroAllowed = false}) Result<String, String>
If ADA string is all digits, not negative and the correct decimal precision, then the normalized correct form is returned. If it's not legal, then an explanation is returned in the error message.
validBech32({required String bech32, required List<String> hrpPrefixes, int? dataPartRequiredLength}) Result<String, String>
if bech32 string has the correct prefix, '1' seperator, legal data characters and optionaly correct length, the normalized correct form is returned. If it's not legal, then an explanation is returned in the error message.
validMnemonic({required String phrase, int requiredNumberOfWords = 24}) Result<String, String>
If the mnemonic or recovery phrase has all legal characters and the requiredNumberOfWords, then the normalized correct form is returned. If it's not legal, then an explanation is returned in the error message.
validMnemonicWord(String word) bool
Return true if a valid mnemonic word
validMnemonicWords(List<String> words) Result<bool, String>
Return true if a all the provided mnemonic words are valid.
verifyEd25519({required Uint8List signature, required Uint8List message, required Uint8List publicKey}) bool

Enums

AddressType
Encapsulates Shelley address types. Handles proper bech32 encoding and decoding mainnet and testnet addresses.
CoinSelectionErrorEnum
CredentialType
NetworkId
The Cardano testnet and mainnet are two independent blockchains and this value determines which one your code will run on.
TemperalSortOrder
TransactionStatus
TransactionType

Typedefs

AssetId = String
Native Token policyId appended to hex encoded coin name. ADA has no policyId so its assetId is just 'lovelace' in hex: '6c6f76656c616365'. Simalur to 'unit' but 'lovelace' is not hex encoded.
Bech32Address = String
String representation of bech32 address
BlockHashHex = String
Hex encoded block hash ID
Coin = int
Represents ADA amount in lovelace.
CoinSelectionAlgorithm = Future<Result<CoinSelection, CoinSelectionError>> Function({int coinSelectionLimit, bool logSelection, required List<MultiAssetRequest> outputsRequested, required Set<ShelleyAddress> ownedAddresses, required List<WalletTransaction> unspentInputsAvailable})
Coin selection is the process of picking UTxO inputs to perticipate in a spending transaction. There is a dedicated Cardano Improvement Proposal that this implementation is attempting to follo in spirit:
CurrentEpochFunction = Future<int> Function()
MinFeeFunction = Coin Function({LinearFee linearFee, required ShelleyTransaction transaction})
NetworkRquest = Future<Response> Function()
OneArgFunction = void Function(dynamic)
ResponseFunction = void Function({DioError? dioError, Exception? exception, Response? response})
TxIdHex = String
Hex encoded transaction hash ID
UnusedAddressFunction = bool Function(ShelleyAddress address)
Function used to test address usage. Returns true if it has not been used in a transaction.
WalletId = String
Wallet ID - stakingPublicKey for Shelley wallets

Exceptions / Errors

CborDeserializationException
These classes define the data stored on the Cardano blockchain as defined by the shelley.cddl specification.
InvalidAddressTypeError