createMetadataOutput function
Implementation
ValueTransferOutput createMetadataOutput(String metadata) {
if (!isHexStringOfLength(metadata, 20)) {
throw TransactionError(-1, 'Metadata must be a 20-byte hex string');
}
final cleanMetadata =
metadata.startsWith('0x') ? metadata.substring(2) : metadata;
// Convert hex string into raw List of bytes
final metadataBytes = hex.decode(cleanMetadata);
final metadataPkh = PublicKeyHash()..hash = metadataBytes;
return ValueTransferOutput.fromJson({
'pkh': metadataPkh.address,
'value': 1,
'time_lock': 0,
});
}