createOpReturnSend function
Creates a SEND OP_RETURN buffer.
Implementation
List<int> createOpReturnSend(
int versionType,
List<int> tokenId,
List<BigInt> slpAmounts
) {
if (! [0x01, 0x41, 0x81].contains(versionType)) {
throw('unknown versionType');
}
if (tokenId.length != 32) {
throw('tokenIdHex must be 32 bytes');
}
if (slpAmounts.length < 1) {
throw('send requires at least one amount');
}
if (slpAmounts.length > 19) {
throw('too many slp amounts');
}
List<int> amounts = [];
slpAmounts.forEach((v) {
amounts.addAll(pushdata(BNToInt64BE(v)));
});
List<int> buf = [
0x6A, // OP_RETURN
...pushdata(hex.decode("534c5000")), // lokad for "SLP")),
...pushdata([versionType]), // versionType
...pushdata(utf8.encode("SEND")),
...pushdata(tokenId),
...amounts
];
return buf;
}