create method Null safety

TransactionModel create(
  1. Uint8List contents,
  2. KeyModel key,
  3. {String assetRef = 'AA=='}
)

Creates a TransactionModel with contents.

Uses the KeyModel.privateKey from key to sign the transaction. If the assetRef is not set, it defaults to AA==. The return is an uncommitted TransactionModel. The TransactionModel should be added to a BlockModel by setting the TransactionModel.block and TransactionModel.merkelProof values and calling the commit method.

Implementation

TransactionModel create(Uint8List contents, KeyModel key,
    {String assetRef = 'AA=='}) {
  TransactionModel txn = TransactionModel(
      address: key.address, contents: contents, assetRef: assetRef);
  txn.signature =
      Rsa.sign(key.privateKey, txn.serialize(includeSignature: false));
  txn.id = Digest("SHA3-256").process(txn.serialize());
  _repository.save(txn);
  return txn;
}