chaincode

package
v0.0.0-...-05edea0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Approval

type Approval struct {
	Owner    string `json:"owner"`
	Operator string `json:"operator"`
	Approved bool   `json:"approved"`
}

type Nft

type Nft struct {
	TokenID  string `json:"tokenId"`
	Owner    string `json:"owner"`
	TokenURI string `json:"tokenURI"`
	Approved string `json:"approved"`
}

Nft defines the non-fungible token struct used by chaincode.

type TokenERC721Contract

type TokenERC721Contract struct {
	contractapi.Contract
}

TokenERC721Contract contract for managing CRUD operations

func (*TokenERC721Contract) Approve

func (c *TokenERC721Contract) Approve(ctx contractapi.TransactionContextInterface, operator string, tokenID string) (bool, error)

Approve changes or reaffirms the approved client for a non-fungible token. operator is the new approved client. tokenID is the non-fungible token to approve. Returns true if the approval was successful.

func (*TokenERC721Contract) BalanceOf

BalanceOf counts all non-fungible tokens assigned to an owner. owner is the address for whom to query the balance. Returns the number of non-fungible tokens owned by owner, possibly zero.

func (*TokenERC721Contract) Burn

Burn destroys a non-fungible token. tokenID is the unique ID of the non-fungible token to burn. Returns true if the burn was successful.

func (*TokenERC721Contract) ClientAccountBalance

func (c *TokenERC721Contract) ClientAccountBalance(ctx contractapi.TransactionContextInterface) (int, error)

ClientAccountBalance returns the balance of the requesting client's account.

func (*TokenERC721Contract) ClientAccountID

ClientAccountID returns the id of the requesting client's account. In this implementation, the client account ID is the clientId itself. Users can use this function to get their own account id, which they can then give to others as the payment address

func (*TokenERC721Contract) GetApproved

GetApproved returns the approved client for a single non-fungible token. tokenID is the non-fungible token to find the approved client for. Returns the approved client for this non-fungible token, or an empty string if there is none.

func (*TokenERC721Contract) Initialize

Initialize sets information for a token and initializes the contract. name is the name of the token. symbol is the symbol of the token.

func (*TokenERC721Contract) IsApprovedForAll

func (c *TokenERC721Contract) IsApprovedForAll(ctx contractapi.TransactionContextInterface, owner string, operator string) (bool, error)

IsApprovedForAll returns if a client is an authorized operator for another client. owner is the client that owns the non-fungible tokens. operator is the client that acts on behalf of the owner. Returns true if operator is an approved operator for owner, false otherwise.

func (*TokenERC721Contract) MintWithTokenURI

func (c *TokenERC721Contract) MintWithTokenURI(ctx contractapi.TransactionContextInterface, tokenID string, tokenURI string) (*Nft, error)

MintWithTokenURI creates a new non-fungible token. tokenID is the unique ID of the non-fungible token to be minted. tokenURI is the URI containing metadata of the minted non-fungible token. Returns the minted non-fungible token.

func (*TokenERC721Contract) Name

Name returns a descriptive name for a collection of non-fungible tokens in this contract.

func (*TokenERC721Contract) OwnerOf

OwnerOf finds the owner of a non-fungible token. tokenID is the identifier for a non-fungible token. Returns the owner of the non-fungible token.

func (*TokenERC721Contract) SetApprovalForAll

func (c *TokenERC721Contract) SetApprovalForAll(ctx contractapi.TransactionContextInterface, operator string, approved bool) (bool, error)

SetApprovalForAll enables or disables approval for a third party ("operator") to manage all the message sender's assets. operator is a client to add to the set of authorized operators. approved is true if the operator is approved, false to revoke approval. Returns true if the approval was successful.

func (*TokenERC721Contract) Symbol

Symbol returns an abbreviated name for non-fungible tokens in this contract.

func (*TokenERC721Contract) TokenURI

TokenURI returns a distinct Uniform Resource Identifier (URI) for a given token. tokenID is the identifier for the non-fungible token.

func (*TokenERC721Contract) TotalSupply

TotalSupply counts non-fungible tokens tracked by this contract. Returns a count of valid non-fungible tokens tracked by this contract, where each one has an assigned and queryable owner.

func (*TokenERC721Contract) TransferFrom

func (c *TokenERC721Contract) TransferFrom(ctx contractapi.TransactionContextInterface, from string, to string, tokenID string) (bool, error)

TransferFrom transfers the ownership of a non-fungible token from one owner to another owner. from is the current owner of the non-fungible token. to is the new owner. tokenID is the non-fungible token to transfer. Returns true if the transfer was successful.

type Transfer

type Transfer struct {
	From    string `json:"from"`
	To      string `json:"to"`
	TokenID string `json:"tokenId"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL