Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v2 source realm

Package heirrealm is a dead-man's-switch inheritance realm for Gno.land.

Overview

Package heirrealm is a dead-man's-switch inheritance realm for Gno.land.

The problem: a Gno holder dies, loses their keys, or simply disappears, and their GNOT is locked forever. No will, no custodian, no recovery.

HeirRealm lets the holder name a beneficiary and a check-in window. As long as the holder checks in before the window expires, nothing happens. Miss the window and anyone — an incentivised keeper, not a trusted custodian — can trigger the release. The keeper earns a small fee for doing the work; the rest goes to the beneficiary. The keeper can never release early, never change the beneficiary, and never touch the funds before the deadline.

Design choices (all documented in README.md):

  • Denomination is ugnot only (GNOT). One coin type keeps the accounting auditable.
  • Keeper fee is 2% (200 basis points) of the vault balance at release time. Integer math: fee = balance * 200 / 10000. For balances under 50 ugnot the fee rounds to 0.
  • Check-in interval must be between 60 seconds (1 minute, so the 60-second demo can fast-forward) and 365 days.
  • CheckIn only works BEFORE the deadline. Once the deadline has passed, the vault is claimable and the owner can no longer rescue it by checking in — that is the whole point of a dead-man's switch.
  • Cancel (owner refund) only works BEFORE the deadline and only while the vault is still active. After expiry the funds belong to the beneficiary.
  • The keeper may not be the owner or the beneficiary.
  • Time is block time: time.Now(), the same timelock primitive used by examples/gno.land/r/demo/defi/atomicswap in gnolang/gno.

Caller authentication follows the atomicswap pattern: payment functions require cur.Previous().IsUserCall() and read the attached coins from unsafe.OriginSend(). A realm in the middle of a call chain cannot fake a payment, because OriginSend describes the transaction envelope and IsUserCall rejects non-wallet callers.

Social/voice recovery is intentionally NOT in this MVP. It is listed as a future extension in README.md.

Constants 6

const Denom

1const Denom = "ugnot"
source

Denom is the only coin this realm accepts: ugnot (GNOT).

const GracePeriodSeconds

1const GracePeriodSeconds = 60 // 60s for demo, 7 days in production
source

GracePeriodSeconds is the grace window after Deadline during which TriggerRelease is still blocked and only the owner's Heartbeat can revive the vault: 60s for demo, 7 days in production.

const KeeperFeeBPS

1const KeeperFeeBPS = 200
source

KeeperFeeBPS is the keeper's cut of a released vault, in basis points. 200 bps = 2%.

const MaxCheckInIntervalSeconds

1const MaxCheckInIntervalSeconds = 365 * 24 * 60 * 60
source

MaxCheckInIntervalSeconds is the longest check-in window: 365 days.

const MinCheckInIntervalSeconds

1const MinCheckInIntervalSeconds = 60
source

MinCheckInIntervalSeconds is the shortest check-in window: 60s. It exists so the demo can fast-forward through a full lifecycle in about a minute.

const ProductionGracePeriodSeconds

1const ProductionGracePeriodSeconds = 7 * 24 * 60 * 60
source

ProductionGracePeriodSeconds is the production default grace period (7 days = 604,800s) before an expired vault becomes claimable.

Functions 9

func Cancel

crossing Action
1func Cancel(cur realm, id int) int64
source

Cancel closes an active vault and refunds the full balance to the owner. Only the owner may cancel, and only BEFORE the deadline. After expiry the funds belong to the beneficiary and the owner can no longer claw them back.

func CheckIn

crossing Action
1func CheckIn(cur realm, id int) time.Time
source

CheckIn resets the vault's deadline to now + the check-in interval. Only the owner may check in, only while the vault is active, and only BEFORE the deadline has passed. After the deadline the vault is claimable and checking in can no longer save it.

func CreateVault

crossing Action
1func CreateVault(cur realm, beneficiary address, intervalSeconds int64) int
source

CreateVault opens a vault for beneficiary with a check-in window of intervalSeconds. Attach the initial deposit with -send ugnot.

The caller becomes the owner. The beneficiary must not be the owner. The deposit must be more than 0 ugnot.

func Deposit

crossing Action
1func Deposit(cur realm, id int) int64
source

Deposit tops up an active vault. Only the owner may deposit, and only ugnot is accepted. The check-in timer is NOT reset by a deposit — only CheckIn resets it.

func Heartbeat

crossing Action
1func Heartbeat(cur realm, id int) time.Time
source

Heartbeat revives a vault during its post-deadline grace period and resets its deadline to now + the check-in interval, identically to CheckIn. Only the vault owner may call Heartbeat, and only strictly during the grace window (after Deadline, before Deadline + GracePeriod).

func Render

1func Render(path string) string
source

Render is the gnoweb homepage for the realm. It lists every vault with its owner, beneficiary, balance, deadline and status, plus a short how-to. A single vault can be viewed at /<id>.

func TriggerRelease

crossing Action
1func TriggerRelease(cur realm, id int) (beneficiaryShare int64, keeperFee int64)
source

TriggerRelease releases an expired vault once both its check-in deadline AND its post-deadline grace period have passed. Anyone may call it — that is the keeper's job — but the keeper may not be the owner or the beneficiary. The keeper earns 2% of the balance; the beneficiary receives the remaining 98%.

func GetVault

Action
1func GetVault(id int) Vault
source

GetVault returns a copy of the vault with the given ID. Read-only: callable as a query, no transaction needed.

Types 1

type Vault

struct
 1type Vault struct {
 2	ID          int
 3	Owner       address
 4	Beneficiary address
 5	Balance     int64 // ugnot held by this vault
 6	Interval    int64 // check-in window, in seconds
 7	GracePeriod int64 // post-deadline grace window, in seconds
 8	Deadline    time.Time
 9	CreatedAt   time.Time
10	Released    bool
11	Cancelled   bool
12	Keeper      address   // set on release; zero address until then
13	ReleasedAt  time.Time // zero until released
14}
source

Vault is one inheritance vault.

Methods on Vault

func BeneficiaryShare

method on Vault
1func (v Vault) BeneficiaryShare() int64
source

BeneficiaryShare returns what the beneficiary receives at release.

func GraceEnd

method on Vault
1func (v Vault) GraceEnd() time.Time
source

GraceEnd returns the end of the vault's grace period (Deadline + GracePeriod). Keepers can only call TriggerRelease strictly after GraceEnd.

func KeeperFee

method on Vault
1func (v Vault) KeeperFee() int64
source

KeeperFee returns the keeper's cut of the vault balance at release.

func Status

method on Vault
1func (v Vault) Status() string
source

Status returns a human-readable state for the vault.

Dependencies

Source Files 4