Skip to content

Latest commit

 

History

History
55 lines (33 loc) · 1.71 KB

address_handler_doc.md

File metadata and controls

55 lines (33 loc) · 1.71 KB

Interaction with addresses

This document describes examples of address creation and recovery from a key pair using the NosoDart library.

Table of contents

Generate new address

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.


Recover an address from a 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.


Get hash using a public key

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.