This document describes examples of address creation and recovery from a key pair using the NosoDart library.
To generate a new address, use the following example
AddressObject address = AddressHandler.createNewAddress();
The createNewAddress() method will return the AddressObject model with a hash and the corresponding key pair.
An example of recovering an address from a pair of secret keys. To do this, use the importAddressForKeysPair() method, which takes two parameters.
- String keys - a space separated string with keys,
- KeyPair? keysPair - is a pair of keys wrapped in the KeysPair model
var keysPairString = "examplePublic examplePrivate";
var keysPair = KeyPair(publicKey: "examplePublic", privateKey: "examplePrivate");
AddressObject? address = AddressHandler.importAddressForKeysPair(keysPairString);
//OR
AddressObject? address = AddressHandler.importAddressForKeysPair("",keyPair: keysPair);
The importAddressForKeysPair() method will return the AddressObject model if the recovery is successful, otherwise it will return null.
This example shows how to get an address hash with a public key.
String hash = AddressHandler.getAddressFromPublicKey("examplePublicKey");
The createNewAddress() method will return a hash generated from the public key.