import { Lux, BN, Buffer } from "lux/dist" import { XVMAPI, KeyChain as XVMKeyChain, UTXOSet, UnsignedTx, Tx, MinterSet } from "lux/dist/apis/xvm" import { GetUTXOsResponse } from "lux/dist/apis/xvm/interfaces" import { PrivateKeyPrefix, DefaultLocalGenesisPrivateKey, UnixNow } from "lux/dist/utils" const ip: string = "localhost" const port: number = 9650 const protocol: string = "http" const networkID: number = 1337 const lux: Lux = new Lux(ip, port, protocol, networkID) const xchain: XVMAPI = lux.XChain() const xKeychain: XVMKeyChain = xchain.keyChain() const privKey: string = `${PrivateKeyPrefix}${DefaultLocalGenesisPrivateKey}` xKeychain.importKey(privKey) const xAddresses: Buffer[] = xchain.keyChain().getAddresses() const xAddressStrings: string[] = xchain.keyChain().getAddressStrings() const threshold: number = 1 const locktime: BN = new BN(0) const asOf: BN = UnixNow() const memo: Buffer = Buffer.from( "XVM utility method buildCreateNFTAssetTx to create an NFT" ) const name: string = "non fungible token" const symbol: string = "NFT" const main = async (): Promise => { const xvmUTXOResponse: GetUTXOsResponse = await xchain.getUTXOs( xAddressStrings ) const utxoSet: UTXOSet = xvmUTXOResponse.utxos const minterSets: MinterSet[] = [new MinterSet(threshold, xAddresses)] const unsignedTx: UnsignedTx = await xchain.buildCreateNFTAssetTx( utxoSet, xAddressStrings, xAddressStrings, minterSets, name, symbol, memo, asOf, locktime ) const tx: Tx = unsignedTx.sign(xKeychain) const txid: string = await xchain.issueTx(tx) console.log(`Success! TXID: ${txid}`) } main()