Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source pure

Package royalty is a stackable GRC721 extension implementing EIP-2981 in basis points. Writes are issuer-only so a ho...

Overview

Package royalty is a stackable GRC721 extension implementing EIP-2981 in basis points. Writes are issuer-only so a holder cannot zero out a royalty on a token they just received.

Constants 3

const FeeDenominator

1const FeeDenominator = 10000
source

FeeDenominator is the EIP-2981 basis-point denominator: bps/10000, 10000 == 100%.

Variables 1

Functions 1

func NewRoyalty

1func NewRoyalty(coreLedger *grc721.PrivateLedger, maxBps int64) (*Royalty, *Ledger)
source

NewRoyalty attaches a royalty extension; maxBps caps every rate and must be 0..10000.

Types 3

type Ledger

struct
1type Ledger struct {
2	core *grc721.Token
3	st   *storage
4}
source

Methods on Ledger

func DeleteTokenRoyalty

method on Ledger
1func (led *Ledger) DeleteTokenRoyalty(tid grc721.TokenID)
source

DeleteTokenRoyalty clears the per-token override, falling back to the default.

func OnBurn

method on Ledger
1func (led *Ledger) OnBurn(tid grc721.TokenID)
source

OnBurn clears the per-token override (cannot resurface on re-mint) but keeps the default, which is collection-level policy, not per-token state.

func OnMint

method on Ledger
1func (led *Ledger) OnMint(to address, tid grc721.TokenID)
source

func OnTransfer

method on Ledger
1func (led *Ledger) OnTransfer(from, to address, tid grc721.TokenID)
source

func SetDefaultRoyalty

method on Ledger
1func (led *Ledger) SetDefaultRoyalty(receiver address, bps int64) error
source

SetDefaultRoyalty sets the collection default for tokens without an override; issuer-only.

func SetTokenRoyalty

method on Ledger
1func (led *Ledger) SetTokenRoyalty(tid grc721.TokenID, receiver address, bps int64) error
source

SetTokenRoyalty sets a per-token override for tid; issuer-only.

type Royalty

struct
1type Royalty struct {
2	core *grc721.Token
3	st   *storage
4}
source

Methods on Royalty

func DefaultRoyalty

method on Royalty
1func (r *Royalty) DefaultRoyalty() (RoyaltyInfo, bool)
source

func MaxBps

method on Royalty
1func (r *Royalty) MaxBps() int64
source

func RoyaltyInfo

method on Royalty
1func (r *Royalty) RoyaltyInfo(tid grc721.TokenID, salePrice int64) (address, int64, error)
source

RoyaltyInfo implements EIP-2981; per-token override takes precedence over the default, and no royalty returns (zeroAddress, 0) — the "no royalty" signal.

func TokenID

method on Royalty
1func (r *Royalty) TokenID() string
source

func TokenRoyalty

method on Royalty
1func (r *Royalty) TokenRoyalty(tid grc721.TokenID) (RoyaltyInfo, bool)
source

type RoyaltyInfo

struct
1type RoyaltyInfo struct {
2	Receiver address
3	Bps      int64
4}
source

RoyaltyInfo is a royalty policy: send Bps/10000 of a sale to Receiver.

Imports 6

Source Files 4