write method
Implementation
@override
void write(Encoder encoder) {
var targetLists = targets?.map((e) => e.toUint8Array()).toList() ?? [];
var _targets = targets != null ? {"targets": targetLists} : {};
var res = {"pubkey": pubkey, "expiration": expiration.toInt(), ..._targets};
encoder.writeMap(res);
}