Skip to content

Signed record

Save a record with an attestation signature attached.

Lexicon type: procedure

local time = require("internal.time")
local record = require("happyview.record")
local atproto = require("happyview.atproto")
function handle(input, ctx)
local body = { text = input.text, createdAt = time.to_iso8601(time.now()) }
local ok, sig = pcall(atproto.sign, body)
if ok then
body.signature = sig
end
local ref = record.create(ctx.collection, body)
return { uri = ref.uri, cid = ref.cid, signature = body.signature }
end
  1. Build the record body.
  2. Sign it with sign on happyview.atproto. The pcall lets the script work without a signer configured, where sign raises NO_SIGNER. Signing also needs a caller: it fails when no account is signed in.
  3. Attach the signature to the body as body.signature, then save the record with record.create. The record lexicon must allow a signature field, or the write is refused.
  4. Return the signature alongside the URI.

The signature’s $type defaults to games.gamesgamesgamesgames.attestation. Set ATTESTATION_SIG_TYPE to use another type.

The DPoP proof is signed per request; an app built on the HappyView SDK gets this from its session.

const response = await fetch("http://127.0.0.1:3000/xrpc/xyz.example.createPost", {
method: "POST",
headers: {
"X-Client-Key": CLIENT_KEY,
Authorization: `DPoP ${ACCESS_TOKEN}`,
DPoP: DPOP_PROOF,
"Content-Type": "application/json",
},
body: JSON.stringify({ text: "Hello world" }),
});
const data = await response.json();
{
"uri": "at://did:plc:abc/xyz.example.post/3abc123",
"cid": "bafyrei...",
"signature": {
"$type": "games.gamesgamesgamesgames.attestation",
"key": "did:web:happyview.example.com#attestation",
"signature": { "$bytes": "..." }
}
}

Attestation signatures let clients verify that a record was processed by your HappyView instance — useful for contributions, moderation decisions, or cross-instance data where provenance matters. The signature covers both the record content and the author’s DID, so it can’t be replayed across users or tampered with.

See Attestation Signing for setup and configuration, or Verify Signed Record for the read-side counterpart.