PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/r/g1nmqhha0ua730vejxqhrelldm4pga5j5ptle5ea/guardians

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
guardians
Namespace
g1nmqhha0ua730vejxqhrelldm4pga5j5ptle5ea
Files
10 (gnomod.toml)
Exported functions
81
Module
gno.land/r/g1nmqhha0ua730vejxqhrelldm4pga5j5ptle5ea/guardians
gno
0.9

Files (10)

  • gnomod.tomltoml
  • allowlist.gnogno
  • extensions.gnogno
  • guardians.gnogno
  • marketplace.gnogno
  • mint.gnogno
  • reserve.gnogno
  • reveal.gnogno
  • sale.gnogno
  • snapshot.gnogno
  • allowlist.gnogno
    1package guardians23import (4	"chain"5	"chain/runtime"6	"chain/runtime/unsafe"7	"crypto/sha256"8

    Functions

    • Admin() string

    • AdminMint(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, to string, quantity int)

    • AllowlistEnd() int64

    • AllowlistLeaf(owner string, allowance int, unitPrice int64) string

    • AllowlistMinted(owner string) int

    • AllowlistMintedSupply() int64

    • AllowlistPrice() int64

    • AllowlistReservedSupply() int64

    • AllowlistReserveReleased() bool

    • AllowlistReserveRemaining() int64

    • AllowlistRoot() string

    • AllowlistRootLocked() bool

    • AllowlistStart() int64

    • AllowlistUnclaimedSupply() int64

    • AllowlistWalletLimit() int

    • ApplyRevealBatch(startTokenID int64, quantity int)

    • Approve(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, to string, tokenID string)

    • AuthorizedMarketplace() string

    • BalanceOf(owner string) int64

    • CollectionID() string

    • ComputeRevealCommitment(secret string) string

    • ConfigureReveal(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, provenance string, commitment string, baseURI string, deadline int64)

    • ConfigureSale(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, allowlistStart int64, allowlistEnd int64, publicStart int64, publicEnd int64, allowlistPrice int64, publicPrice int64, allowlistLimit int, publicLimit int, treasury string)

    • DefaultRoyalty() (string, int64)

    • EnumerableSupply() int64

    • FinalBaseURI() string

    • FreezeMetadata(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string})

    • GetApproved(tokenID string) string

    • IsApprovedForAll(owner string, operator string) bool

    • LaunchVersion() string

    • MarketplaceTransfer(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, seller string, buyer string, tokenID string, grossPrice int64, nonce int64)

    • MaxSupply() int64

    • MetadataID(tokenID int64) int64

    • Mint(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, freeQuantity int, paidQuantity int, allowance int, unitPrice int64, proof string)

    • MintAllowlist(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, quantity int, allowance int, unitPrice int64, proof string)

    • MintPublic(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, quantity int)

    • Name() string

    • NextSaleTimestamp() int64

    • OwnerOf(tokenID string) string

    • ProvenanceRoot() string

    • PublicEnd() int64

    • PublicMintableSupply() int64

    • PublicMinted(owner string) int

    • PublicPrice() int64

    • PublicStart() int64

    • PublicWalletLimit() int

    • ReleaseAllowlistReserve(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string})

    • Render(path string) string

    • Reveal(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, secret string)

    • RevealCommitment() string

    • RevealDeadline() int64

    • RevealOverdue() bool

    • RevealProcessed() int64

    • RevealSeedHash() string

    • RevealState() string

    • RevealTarget() int64

    • RoyaltyInfo(tokenID string, salePrice int64) (string, int64)

    • RoyaltyMaxBps() int64

    • SaleConfigured() bool

    • SalePaused() bool

    • SalePhase() string

    • SalePhaseAt(unixTime int64) string

    • SaleSnapshot() string

    • SaleTreasury() string

    • SetAllowlistRoot(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, root string)

    • SetApprovalForAll(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, operator string, approved bool)

    • SetAuthorizedMarketplace(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, marketplace string)

    • SetDefaultRoyalty(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, receiver string, bps int64)

    • SetPublicEnd(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, end int64)

    • SetSalePaused(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, paused bool)

    • SetVeiledURI(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, uri string)

    • Status() string

    • Symbol() string

    • TokenByIndex(index int64) string

    • TokenOfOwnerByIndex(owner string, index int64) string

    • TokenURI(tokenID string) string

    • TotalSupply() int64

    • TransferFrom(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, from string, to string, tokenID string)

    • VeiledURI() string

    • VerifyAllowlist(owner string, allowance int, unitPrice int64, proof string) bool

    • WalletSnapshot(owner string) string

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.

    Rendered

    RenderedRawgnoweb ↗

    vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.

    "encoding/hex"
    9 "strings"
    10 "time"
    11
    12 "gno.land/p/nt/ufmt/v0"
    13)
    14
    15const maxMerkleProofDepth = 32
    16
    17var (
    18 allowlistRoot string
    19 allowlistRootLocked bool
    20)
    21
    22func AllowlistRoot() string { return allowlistRoot }
    23
    24func AllowlistRootLocked() bool { return allowlistRootLocked }
    25
    26// SetAllowlistRoot accepts a lowercase/uppercase 32-byte SHA-256 hash in hex.
    27// The first sale unpause permanently locks the root for this deployment.
    28func SetAllowlistRoot(cur realm, root string) {
    29 assertAdmin(cur.Previous().Address())
    30 if !salePaused {
    31 panic("guardians: pause sale before setting allowlist root")
    32 }
    33 if allowlistRootLocked {
    34 panic("guardians: allowlist root is locked")
    35 }
    36 decoded, ok := decodeMerkleHash(root)
    37 if !ok || len(decoded) != sha256.Size {
    38 panic("guardians: invalid allowlist root")
    39 }
    40 allowlistRoot = hex.EncodeToString(decoded)
    41 chain.Emit("AllowlistRootConfigured", "root", allowlistRoot)
    42}
    43
    44// AllowlistLeaf binds a claim to this chain, collection, phase, address,
    45// individual allowance and configured unit price.
    46func AllowlistLeaf(owner address, allowance int, unitPrice int64) string {
    47 payload := runtime.ChainID() + "|" +
    48 CollectionID() + "|" +
    49 salePhaseAllowlist + "|" +
    50 owner.String() + "|" +
    51 ufmt.Sprintf("%d", allowance) + "|" +
    52 ufmt.Sprintf("%d", unitPrice)
    53 return hashBytes([]byte(payload))
    54}
    55
    56// VerifyAllowlist expects comma-separated 64-character hex sibling hashes.
    57// Pair hashing is sorted, so proofs do not need left/right direction flags.
    58func VerifyAllowlist(owner address, allowance int, unitPrice int64, proof string) bool {
    59 if allowlistRoot == "" || allowance < 1 || allowance > maxSupplyAsInt() {
    60 return false
    61 }
    62
    63 computed := AllowlistLeaf(owner, allowance, unitPrice)
    64 siblings, ok := parseMerkleProof(proof)
    65 if !ok {
    66 return false
    67 }
    68 for _, sibling := range siblings {
    69 computed = hashMerklePair(computed, sibling)
    70 }
    71 return computed == allowlistRoot
    72}
    73
    74func MintAllowlist(cur realm, quantity, allowance int, unitPrice int64, proof string) {
    75 if !cur.Previous().IsUserCall() {
    76 panic("guardians: only direct user calls can mint")
    77 }
    78 if !allowlistSaleOpenAt(time.Now().Unix()) {
    79 panic("guardians: allowlist sale is not active")
    80 }
    81 if unitPrice != saleConfig.allowlistPrice {
    82 panic("guardians: allowlist price mismatch")
    83 }
    84 if allowance < 1 || allowance > saleConfig.allowlistLimit {
    85 panic("guardians: invalid allowlist allowance")
    86 }
    87
    88 caller := cur.Previous().Address()
    89 if !VerifyAllowlist(caller, allowance, unitPrice, proof) {
    90 panic("guardians: invalid allowlist proof")
    91 }
    92 assertSaleMint(quantity, AllowlistMinted(caller), allowance)
    93 required := requiredPayment(unitPrice, quantity)
    94 sent := unsafe.OriginSend()
    95 assertExactPayment(sent, required)
    96
    97 mintAllocatedTokens(caller, quantity, 0)
    98 allowlistMintedByWallet.Set(caller.String(), AllowlistMinted(caller)+quantity)
    99 forwardPayment(cur, sent)
    100
    101 chain.Emit(
    102 "AllowlistMint",
    103 "minter", caller.String(),
    104 "quantity", ufmt.Sprintf("%d", quantity),
    105 "allowance", ufmt.Sprintf("%d", allowance),
    106 "paid", ufmt.Sprintf("%d", required),
    107 )
    108}
    109
    110func parseMerkleProof(proof string) ([]string, bool) {
    111 if proof == "" {
    112 return []string{}, true
    113 }
    114 parts := strings.Split(proof, ",")
    115 if len(parts) > maxMerkleProofDepth {
    116 return nil, false
    117 }
    118 for i, part := range parts {
    119 decoded, ok := decodeMerkleHash(part)
    120 if !ok {
    121 return nil, false
    122 }
    123 parts[i] = hex.EncodeToString(decoded)
    124 }
    125 return parts, true
    126}
    127
    128func hashMerklePair(first, second string) string {
    129 left, leftOK := decodeMerkleHash(first)
    130 right, rightOK := decodeMerkleHash(second)
    131 if !leftOK || !rightOK {
    132 return ""
    133 }
    134 if second < first {
    135 left, right = right, left
    136 }
    137 combined := make([]byte, 0, sha256.Size*2)
    138 combined = append(combined, left...)
    139 combined = append(combined, right...)
    140 return hashBytes(combined)
    141}
    142
    143func hashBytes(data []byte) string {
    144 sum := sha256.Sum256(data)
    145 return hex.EncodeToString(sum[:])
    146}
    147
    148func decodeMerkleHash(value string) ([]byte, bool) {
    149 if len(value) != sha256.Size*2 {
    150 return nil, false
    151 }
    152 decoded, err := hex.DecodeString(value)
    153 if err != nil || len(decoded) != sha256.Size {
    154 return nil, false
    155 }
    156 return decoded, true
    157}
    158
    159func maxSupplyAsInt() int { return int(maxSupply) }
    160