build method

({KeyPair keyPair, Transaction transaction}) build(
  1. String seed,
  2. int index, {
  3. String? curve = 'ed25519',
  4. String? hashAlgo = 'sha256',
  5. bool isSeedHexa = true,
})

Generate the transaction address, keys and signatures

  • seed : Transaction chain seed (hexadecimal or binary buffer)
  • index : Number of transaction on the chain
  • curve : Elliptic curve to use for the key generation
  • hashAlgo : Hash algorithm to use for the address generation

Implementation

({Transaction transaction, KeyPair keyPair}) build(
  String seed,
  int index, {
  String? curve = 'ed25519',
  String? hashAlgo = 'sha256',
  bool isSeedHexa = true,
}) {
  final keypair = crypto.deriveKeyPair(
    seed,
    index,
    curve: curve!,
    isSeedHexa: isSeedHexa,
  );
  final transactionWithAddressAndPPK = copyWith(
    address: Address(
      address: crypto.deriveAddress(
        seed,
        index + 1,
        curve: curve,
        hashAlgo: hashAlgo!,
        isSeedHexa: isSeedHexa,
      ),
    ),
    previousPublicKey: uint8ListToHex(
      Uint8List.fromList(
        keypair.publicKey!,
      ),
    ),
  );
  return (
    transaction: transactionWithAddressAndPPK.copyWith(
      previousSignature: uint8ListToHex(
        crypto.sign(
          transactionWithAddressAndPPK.previousSignaturePayload(),
          keypair.privateKey,
        ),
      ),
    ),
    keyPair: keypair
  );
}