lotus-sdk
Version:
Central repository for several classes of tools for integrating with, and building for, the Lotusia ecosystem
164 lines • 5.72 kB
TypeScript
import { PublicKey } from '../publickey.js';
import { PrivateKey } from '../privatekey.js';
import { Script } from '../script.js';
import { type TapNode, type TapLeaf } from '../taproot.js';
import { Transaction } from '../transaction/transaction.js';
import { Output } from '../transaction/output.js';
import { UnspentOutput, UnspentOutputData } from '../transaction/unspentoutput.js';
import { Address } from '../address.js';
import { Network } from '../networks.js';
export interface NFTMetadata {
name: string;
description: string;
image: string;
attributes?: NFTAttribute[];
collection?: string;
creator?: string;
external_url?: string;
animation_url?: string;
background_color?: string;
}
export interface NFTAttribute {
trait_type: string;
value: string | number;
display_type?: 'number' | 'boost_percentage' | 'boost_number' | 'date';
}
export interface NFTCollectionMetadata {
name: string;
description: string;
totalSupply: number;
creator: string;
royalty?: number;
image?: string;
external_url?: string;
}
export interface NFTData {
script: Script;
address: Address;
metadataHash: Buffer;
metadata: NFTMetadata;
satoshis: number;
txid?: string;
outputIndex?: number;
}
export interface NFTTransfer {
txid: string;
from: string | null;
to: string;
metadataHash: string;
timestamp: number;
blockHeight?: number;
}
export interface NFTMintConfig {
ownerKey: PrivateKey;
metadata: NFTMetadata;
satoshis?: number;
collectionHash?: Buffer;
network?: Network;
}
export interface NFTUtxo {
txid: string;
outputIndex: number;
script: Script;
satoshis: number;
}
export interface NFTTransferConfig {
currentOwnerKey: PrivateKey;
newOwnerKey: PublicKey;
nftUtxo: NFTUtxo;
metadataHash: Buffer;
fee?: number;
}
export interface NFTWithScriptPath extends NFTData {
commitment: PublicKey;
merkleRoot: Buffer;
leaves: TapLeaf[];
}
export interface NFTWithCollection extends NFTData {
collectionHash: Buffer;
}
export interface NFTInfo {
commitment: PublicKey;
metadataHash: Buffer;
address: Address;
}
export interface NFTObject {
script: string;
address: string;
metadataHash: string;
metadata: NFTMetadata;
satoshis: number;
txid?: string;
outputIndex?: number;
commitment?: string;
merkleRoot?: string;
collectionHash?: string;
}
export declare class NFT {
private _script;
private _address;
private _metadataHash;
private _metadata;
private _satoshis;
private _txid?;
private _outputIndex?;
private _commitment?;
private _merkleRoot?;
private _leaves?;
private _collectionHash?;
constructor(config: {
metadata: NFTMetadata;
ownerKey: PublicKey;
satoshis?: number;
network?: Network;
scriptTree?: TapNode;
collectionHash?: Buffer;
txid?: string;
outputIndex?: number;
});
static fromScript(script: Script, metadata: NFTMetadata, satoshis: number, txid?: string, outputIndex?: number): NFT;
static fromUTXO(utxo: UnspentOutput | NFTUtxo | UnspentOutputData, metadata: NFTMetadata): NFT;
get script(): Script;
get address(): Address;
get metadataHash(): Buffer;
get metadata(): NFTMetadata;
get satoshis(): number;
get txid(): string | undefined;
get outputIndex(): number | undefined;
get commitment(): PublicKey | undefined;
get merkleRoot(): Buffer | undefined;
get leaves(): TapLeaf[] | undefined;
get collectionHash(): Buffer | undefined;
hasScriptTree(): boolean;
isCollectionNFT(): boolean;
verifyMetadata(): boolean;
transfer(newOwnerKey: PublicKey, currentOwnerKey: PrivateKey, fee?: number): Transaction;
updateUTXO(txid: string, outputIndex: number): void;
getInfo(): NFTInfo;
toOutput(): Output;
toUnspentOutput(): UnspentOutput;
getUtxo(): NFTUtxo;
toJSON(): NFTObject;
toObject(): NFTData;
toString(): string;
}
export declare class NFTUtil {
static hashMetadata(metadata: NFTMetadata): Buffer;
static hashCollection(collectionInfo: NFTCollectionMetadata): Buffer;
static hashCollectionNFT(collectionHash: Buffer, nftMetadata: NFTMetadata): Buffer;
static verifyMetadata(metadata: NFTMetadata, hash: Buffer): boolean;
static verifyCollectionNFT(collectionHash: Buffer, nftMetadata: NFTMetadata, hash: Buffer): boolean;
static extractMetadataHash(script: Script): Buffer | null;
static createKeyPathNFT(ownerKey: PublicKey, metadata: NFTMetadata, satoshis?: number, network?: Network): NFTData;
static createScriptPathNFT(ownerKey: PublicKey, metadata: NFTMetadata, scriptTree: TapNode, satoshis?: number, network?: Network): NFTWithScriptPath;
static createCollectionNFT(ownerKey: PublicKey, collectionHash: Buffer, nftMetadata: NFTMetadata, satoshis?: number, network?: Network): NFTWithCollection;
static mintNFT(config: NFTMintConfig): Transaction;
static mintBatch(ownerKey: PrivateKey, nftMetadataList: NFTMetadata[], satoshisPerNFT?: number, network?: Network): Transaction;
static mintCollection(ownerKey: PrivateKey, collectionInfo: NFTCollectionMetadata, nftMetadataList: NFTMetadata[], satoshisPerNFT?: number, network?: Network): Transaction;
static transferNFT(config: NFTTransferConfig): Transaction;
static validateTransfer(inputScript: Script, outputScript: Script): boolean;
static verifyProvenance(transfers: NFTTransfer[]): boolean;
static isNFT(script: Script): boolean;
static getNFTInfo(script: Script): NFTInfo;
}
//# sourceMappingURL=nft.d.ts.map