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

grc721 source pure

Constants 1

Variables 1

var ErrInvalidTokenId, ErrInvalidAddress, ErrTokenIdNotHasApproved, ErrApprovalToCurrentOwner, ErrCallerIsNotOwner, ErrCallerNotApprovedForAll, ErrCannotTransferToSelf, ErrTransferFromIncorrectOwner, ErrTransferToNonGRC721Receiver, ErrCallerIsNotOwnerOrApproved, ErrTokenIdAlreadyExists, ErrInvalidRoyaltyPercentage, ErrInvalidRoyaltyPaymentAddress, ErrCannotCalculateRoyaltyAmount

 1var (
 2	ErrInvalidTokenId              = errors.New("invalid token id")
 3	ErrInvalidAddress              = errors.New("invalid address")
 4	ErrTokenIdNotHasApproved       = errors.New("token id not approved for anyone")
 5	ErrApprovalToCurrentOwner      = errors.New("approval to current owner")
 6	ErrCallerIsNotOwner            = errors.New("caller is not token owner")
 7	ErrCallerNotApprovedForAll     = errors.New("caller is not approved for all")
 8	ErrCannotTransferToSelf        = errors.New("cannot send transfer to self")
 9	ErrTransferFromIncorrectOwner  = errors.New("transfer from incorrect owner")
10	ErrTransferToNonGRC721Receiver = errors.New("transfer to non GRC721Receiver implementer")
11	ErrCallerIsNotOwnerOrApproved  = errors.New("caller is not token owner or approved")
12	ErrTokenIdAlreadyExists        = errors.New("token id already exists")
13
14	// ERC721Royalty
15	ErrInvalidRoyaltyPercentage     = errors.New("invalid royalty percentage")
16	ErrInvalidRoyaltyPaymentAddress = errors.New("invalid royalty paymentAddress")
17	ErrCannotCalculateRoyaltyAmount = errors.New("cannot calculate royalty amount")
18)
source

Functions 1

func NewBasicNFT

1func NewBasicNFT(name string, symbol string) *basicNFT
source

Returns new basic NFT

Types 4

type IGRC721Reader

interface
1type IGRC721Reader interface {
2	Name() string
3	Symbol() string
4	TokenCount() int64
5	BalanceOf(owner address) (int64, error)
6	OwnerOf(tid TokenID) (address, error)
7	GetApproved(tid TokenID) (address, error)
8	IsApprovedForAll(owner, operator address) bool
9}
source

IGRC721Reader is the read-only view of an NFT. Safe to receive across realm boundaries — has no rlm-typed methods, so a malicious impl can only lie about read results (data-integrity issue), not capture cur.

Writes are concrete methods on *basicNFT only — there is no IGRC721 writer interface. The owning realm should hold the concrete *basicNFT in an unexported package var and expose public rlm-validating wrappers like:

Example
1func TransferFrom(cur realm, from, to address, tid TokenID) error {
2	caller := cur.Previous().Address()
3	return nft.TransferFrom(caller, from, to, tid)
4}

This is the Reader/Writer split — stronger than the Authority-pattern because the writer interface doesn't exist at all, so no realm author can accidentally expose it. See `r/demo/foo721` for the canonical wrapper pattern.

type NFTGetter

func
1type NFTGetter func() IGRC721Reader
source

NFTGetter returns a reader-only view of an NFT. Aggregators (such as tokenhub) register and dispatch NFTGetters; the reader-only return type means even a malicious aggregator can't be used to leak cur.

type TokenID

ident
1type TokenID string
source

Methods on TokenID

func String

method on TokenID
1func (t TokenID) String() string
source

type TokenURI

ident
1type TokenURI string
source

Methods on TokenURI

func String

method on TokenURI
1func (t TokenURI) String() string
source

Imports 6

Source Files 5