Wallet class
Wallet manages assets, query state from blockchain, and send transactions to blockchain.
Constructors
- Wallet({required WalletConfig walletConfig})
Properties
- address ↔ String
-
NKN wallet address
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- keystore ↔ String
-
NKN wallet keystore
getter/setter pair
- publicKey ↔ Uint8List
-
NKN wallet public key
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seed ↔ Uint8List
-
NKN wallet seed
getter/setter pair
- walletConfig ↔ WalletConfig
-
getter/setter pair
Methods
-
getBalance(
) → Future< double> - getBalance RPC returns the balance of a wallet address
-
getNonce(
{bool txPool = true}) → Future< int?> - getNonce RPC gets the next nonce to use of an address. If txPool is false, result only counts transactions in ledger; if txPool is true, transactions in txPool are also counted.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
subscribe(
{String identifier = '', required String topic, int duration = 400000, String fee = '0', String meta = '', int? nonce}) → Future< String?> - subscribe to a topic with an identifier for a number of blocks. Client using the same key pair and identifier will be able to receive messages from this topic. If this (identifier, public key) pair is already subscribed to this topic, the subscription expiration will be extended to current block height + duration. The signerRPCClient can be a client, multiclient or wallet.
-
toString(
) → String -
A string representation of this object.
inherited
-
transfer(
String address, String amount, {String fee = '0', int? nonce, Uint8List? attributes}) → Future< String?> - transfer sends asset to a wallet address with a transaction fee. Amount is the string representation of the amount in unit of NKN to avoid precision loss. For example, "0.1" will be parsed as 0.1 NKN. The signerRPCClient can be a client, multiclient or wallet.
-
unsubscribe(
{String identifier = '', required String topic, String fee = '0', int? nonce}) → Future< String?> - unsubscribe from a topic for an identifier. Client using the same key pair and identifier will no longer receive messages from this topic. The signerRPCClient can be a client, multiclient or wallet.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
Uint8List? seed, {required WalletConfig config}) → Future< Wallet> - create creates a wallet from an account and an optional config. For any zero value field in config, the default wallet config value will be used. If config is nil, the default wallet config will be used. However, it is strongly recommended to use non-empty password in config to protect the wallet, otherwise anyone can recover the wallet and control all assets in the wallet from the generated wallet JSON.
-
getBalanceByAddr(
String address, {WalletConfig? config}) → Future< double> - getBalanceByAddr is the same as getBalance
-
getHeight(
{RpcConfig? config}) → Future< int?> - getHeight RPC returns the latest block height.
-
getNonceByAddress(
String address, {bool txPool = true, RpcConfig? config}) → Future< int?> - getNonceByAddress is the same as getNonce
-
getSubscribers(
{required String topic, int offset = 0, int limit = 10000, bool meta = true, bool txPool = true, Uint8List? subscriberHashPrefix, RpcConfig? config}) → Future< Map< String, dynamic> ?> -
getSubscribers RPC returns the number of subscribers of a topic
(not including txPool). If
subscriberHashPrefix
is not empty, only subscriber whose sha256(pubkey+identifier) contains this prefix will be counted. Each prefix byte will reduce result count to about 1/256, and also reduce response time to about 1/256 if there are a lot of subscribers. This is a good way to sample subscribers randomly with low cost. -
getSubscribersCount(
String topic, {Uint8List? subscriberHashPrefix, RpcConfig? config}) → Future< int> -
getSubscribersCount RPC returns the number of subscribers of a topic
(not including txPool). If
subscriberHashPrefix
is not empty, only subscriber whose sha256(pubkey+identifier) contains this prefix will be counted. Each prefix byte will reduce result count to about 1/256, and also reduce response time to about 1/256 if there are a lot of subscribers. This is a good way to sample subscribers randomly with low cost. -
getSubscription(
String topic, String subscriber, {RpcConfig? config}) → Future< Map< String, dynamic> ?> - getSubscription RPC gets the subscription details of a subscriber in a topic.
-
install(
) → dynamic - Need to install before use.
-
measureSeedRPCServer(
List< String> seedRPCServerAddr, int? timeout) → Future<List< String> ?> - measureSeedRPCServer measures the latency to seed rpc node list, only select the ones in persist finished state, and sort them by latency (from low to high). If none of the given seed rpc node is accessable or in persist finished state, returned string array will contain zero elements. Timeout is in millisecond.
-
pubKeyToWalletAddr(
String publicKey) → Future< String?> - pubKeyToWalletAddr converts a public key to its NKN wallet address
-
restore(
String keystore, {required WalletConfig config}) → Future< Wallet> - restore recovers a wallet from wallet JSON and wallet config. The password in config must match the password used to create the wallet