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.

drand package

Overview

Package drand is a Sinopia randomness provider (core.RandomnessProvider) backed by the drand "evmnet" beacon, every round verified on chain.

Verification is gno.land/p/drand/v0 from gnolang/gno#6268, imported from its unmodified copy in Sinopia's namespace (realms/p/drand/v0/README.md; pure Gno on the crypto/bn254, keccak256, modexp natives of gno v1.7.0): evmnet signs on BN254 (scheme bls-bn254-unchained-on-g1, one round every 3 s), and Verify checks e(sig, G2) == e(H(round), pk). The randomness of a round is sha256(signature), the same value drand's API serves.

Trust: nobody. Submit is permissionless and only stores a round whose signature verifies against drand's group key, so a submitter can deliver a round or not, never choose or alter its value. Liveness needs at least one submitter (the Sinopia keeper, any relayer, the creator, a collector); if nobody submits, core falls back after ProviderWaitBlocks (CV-M1).

How core uses it (realms/r/core/randomness.gno):

  1. Target() is read in the transaction that binds a collection (the creator's reveal, RequestRandomness in the grace period, or the first Finalize after the deadline). It names the first evmnet round published more than MarginSeconds after the current block time, so its value is unknown to everyone, including the caller, when the bind is committed. Nobody passes a round: the caller cannot choose one.
  2. Anyone fetches that round from drand once it is published and calls Submit(round, signature) here.
  3. Anyone calls core.FulfillRandomness (or Finalize): core reads Randomness(round) and finalizes.

Clock assumptions (see README "drand provider"): time.Now() is the block header time, which tm2 sets to the median of the previous commit's vote times (BFT time), so a single proposer cannot move it. It lags wall clock by about one block (measured on Onyx: 4–7 s behind the newest block, blocks 3.3–5.4 s). MarginSeconds (30 s = 10 rounds) covers that lag, the 3 s propose timeout and ordinary validator clock skew. The one known case where block time is much older than wall clock is the first block after a chain halt (its time comes from the pre-halt commit); Target() then refuses (0) whenever a later round is already verified here, and core lets the bind happen later. An honest keeper submitting rounds as they are published makes that check effective.

Function

Register

func Register(cur realm) string
Ask AI Claude ChatGPT

Register registers this provider with Sinopia core (once; anyone may send it). It stays inert until the admin approves it (timelocked randomness.add).

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand" -func "Register" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand" -func "Register" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx
  

Gno Expression Evaluator

Evaluate any read-only Gno expression against gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand, for example a function call with arguments.