NFT
Hierarchy
- SmartContract
- NFT
Implements
Index
Constructors
externalconstructor
Parameters
externaladdress: PublicKey
externaloptionaltokenId: Field
Returns NFT
Properties
events
Events emitted by the NFT contract.
Type declaration
buy: typeof BuyEvent
ownershipChange: typeof OwnershipChangeEvent
pause: typeof PauseEvent
resume: typeof PauseEvent
sell: typeof SellEvent
transfer: typeof TransferEvent
update: typeof UpdateEvent
upgradeVerificationKey: typeof UpgradeVerificationKeyEvent
metadata
The metadata associated with the NFT (Field
).
metadataVerificationKeyHash
The hash of the verification key used for metadata proofs (Field
).
name
The name of the NFT (Field
).
owner
The current owner of the NFT (PublicKey
).
packedData
A packed field containing additional NFT data and flags (Field
).
storage
Holds off-chain storage information, e.g., IPFS hash (Storage
).
Methods
buy
Purchases the NFT, transferring ownership and handling payment.
Parameters
price: UInt64
The price at which to buy the NFT (
UInt64
).buyer: PublicKey
The public key of the buyer (
PublicKey
).
Returns Promise<BuyEvent>
An event emitted after the NFT is purchased (
BuyEvent
).
ensureOwnerSignature
Ensures that the transaction is authorized by the current owner.
Returns Promise<AccountUpdate>
A signed account update for the owner.
pause
Pauses the NFT, disabling certain actions.
Returns Promise<void>
A promise that resolves when the NFT is paused.
resume
Resumes the NFT, re-enabling actions.
Returns Promise<void>
A promise that resolves when the NFT is resumed.
sell
Lists the NFT for sale at a specified price.
Parameters
price: UInt64
The price at which to sell the NFT (
UInt64
).seller: PublicKey
The public key of the seller (
PublicKey
).
Returns Promise<SellEvent>
An event emitted after the NFT is listed for sale (
SellEvent
).
transfer
Transfers ownership of the NFT from one user to another.
Parameters
from: PublicKey
The public key of the current owner (
PublicKey
).to: PublicKey
The public key of the new owner (
PublicKey
).
Returns Promise<PublicKey>
The public key of the old owner (
PublicKey
).
update
Updates the NFT's state with provided proofs and permissions.
Parameters
input: NFTState
The current state of the NFT (
NFTState
).output: NFTState
The desired new state of the NFT (
NFTState
).creator: PublicKey
The public key of the creator (
PublicKey
).
Returns Promise<Field>
The hash of the metadata verification key (
Field
).
upgradeVerificationKey
Upgrades the verification key used by the NFT contract.
Parameters
vk: VerificationKey
The new verification key (
VerificationKey
).sender: PublicKey
The public key of the sender (
PublicKey
).
Returns Promise<UpgradeVerificationKeyEvent>
An event emitted after the verification key is upgraded (
UpgradeVerificationKeyEvent
).
The NFT Contract represents an individual NFT within a collection.
It manages the state and behavior of a single NFT, including ownership, metadata, storage, pricing, and permissions. The contract provides functionality for updating NFT properties with proofs and permissions, transferring ownership, selling and buying NFTs, upgrading the verification key, and pausing or resuming the NFT.