write method
Implementation
@override
void write(Encoder encoder) {
final res = {
'pubkey': pubkey,
'expiration': expiration.toInt(),
if (targets != null)
'targets': targets?.map((e) => e.toUint8List()).toList(),
};
encoder.writeMap(res);
}