build method Null safety
- {required Uint8List contents,
- required KeysModel keys,
- String assetRef = 'AA=='}
Builds a TransactionModel with contents
.
Uses the wallet address from keys
(KeysModel.address) to sign the transaction.
If the assetRef
is not set, it defaults to AA==.
The return is a uncommited TransactionModel. The TransactionModel
should be added to a BlockModel
by providing its TransactionModel.block
and TransactionModel.merkelProof values and calling the commit method.
Implementation
TransactionModel build(
{required Uint8List contents,
required KeysModel keys,
String assetRef = 'AA=='}) {
TransactionModel txn = TransactionModel(
address: keys.address, contents: contents, assetRef: assetRef);
txn.signature = UtilsRsa.sign(keys.privateKey, txn.serialize());
txn.id = Digest("SHA3-256").process(txn.serialize());
txn = _repository.save(txn);
return txn;
}