NAME
Net::Nostr::Timestamp - NIP-03 OpenTimestamps attestations for events
SYNOPSIS
use Net::Nostr::Timestamp;
# Create a timestamp attestation
my $ts = Net::Nostr::Timestamp->new(
pubkey => $my_pubkey,
event_id => $target_event_id,
kind => 1,
ots_data => $ots_base64,
relay_url => 'wss://relay.example.com', # optional
);
my $event = $ts->to_event;
$key->sign_event($event);
$client->publish($event);
# Parse a received timestamp attestation
my $ts2 = Net::Nostr::Timestamp->from_event($event);
say $ts2->event_id; # target event ID
say $ts2->kind; # target event kind
say $ts2->ots_data; # base64-encoded OTS proof
DESCRIPTION
Implements NIP-03 OpenTimestamps attestations. A timestamp attestation is a kind 1040 event containing an OpenTimestamps proof for another event.
The content field contains the full base64-encoded .ots file data. The proof MUST prove the referenced event ID as its digest. The .ots file SHOULD contain a single Bitcoin attestation and no pending attestations.
CONSTRUCTOR
new
my $ts = Net::Nostr::Timestamp->new(
pubkey => $pubkey_hex,
event_id => $target_event_id,
kind => 1,
ots_data => $ots_base64,
relay_url => 'wss://relay.example.com', # optional
);
Creates a new timestamp attestation. pubkey, event_id, kind, and ots_data are required. relay_url is optional and will be included in the e tag if provided. Croaks on unknown arguments.
from_event
my $ts = Net::Nostr::Timestamp->from_event($event);
Parses a kind 1040 event into a Timestamp object. Croaks if the event is not kind 1040.
my $ts = Net::Nostr::Timestamp->from_event($event);
say $ts->event_id;
say $ts->ots_data;
METHODS
to_event
my $event = $ts->to_event;
my $event = $ts->to_event(created_at => time());
Creates a kind 1040 Net::Nostr::Event from the timestamp attestation. Extra arguments are passed through to the Event constructor.
event_id
my $id = $ts->event_id;
Returns the target event ID referenced by the e tag.
kind
my $kind = $ts->kind;
Returns the target event kind from the k tag.
ots_data
my $data = $ts->ots_data;
Returns the base64-encoded OpenTimestamps proof data.
pubkey
my $pk = $ts->pubkey;
Returns the pubkey of the attestation author.
relay_url
my $url = $ts->relay_url;
Returns the relay URL from the e tag, or undef if none was provided.