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.

Functions

Has

func Has(round int64) bool
Ask AI Claude ChatGPT

Has reports whether round's randomness is stored here.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand.Has()"

Result

Info

func Info() string
Ask AI Claude ChatGPT

Info returns the provider's parameters and state as JSON.

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand.Info()"

Result

Latest

func Latest() int64
Ask AI Claude ChatGPT

Latest is the highest round verified here (0 if none).

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand.Latest()"

Result

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
  

Render

func Render(path string) string
Ask AI Claude ChatGPT

Render shows the provider on gnoweb.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand.Render()"

Result

Rounds

func Rounds(offset, limit int64) string
Ask AI Claude ChatGPT

Rounds lists stored rounds, newest first, as "round:randomness" lines.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand.Rounds(,)"

Result

Submit

func Submit(cur realm, round int64, signature string) string
Ask AI Claude ChatGPT

Submit verifies round's drand evmnet signature (hex, the "signature" field of https://api.drand.sh/<ChainHash>/public/<round>) and stores its randomness. Permissionless; the caller is never trusted. A round already stored is a no-op (returns the stored value), so concurrent submitters never fail each other. Returns the randomness (64 hex characters).

Params

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 "Submit" -args $'' -args $'' -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 "Submit" -args $'' -args $'' -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
  

TargetAt

func TargetAt(unix int64) int64
Ask AI Claude ChatGPT

TargetAt is the round a bind at block time unix would get, without the staleness check. For keepers and UIs.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand.TargetAt()"

Result

TimeOf

func TimeOf(round int64) int64
Ask AI Claude ChatGPT

TimeOf is the unix time at which evmnet publishes round.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/randomness/drand.TimeOf()"

Result

Gno Expression Evaluator

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