0.0.2 • Published 2 years ago
@curvegrid/multibaas-nft v0.0.2
MultiBaas NFT Library
This document describes MultiBaas NFT as a UMD Bundle or NPM package.
UMD Bundle
For the UMD bundle, include the file in a script tag:
<script src="mb-nft-lib.js"></script>
Functions can then be accessed in the mb
namespace:
const mbClient = await new mb.MBClient({ ...
Otherwise, the functionality is equivalent to that described below.
NPM Package
cp mb-nft-v0.x.x.tgz /your-project-folder
cd /your-project-folder
npm install mb-nft-v0.x.x.tgz
MultiBaas Client
Initialize MultiBaas Client
import { MBClient } from 'mb-nft';
mbClient = new MBClient({
mbHost: 'https://xyz.multibaas.com',
apiKey: 'INSERT_YOUR_API_KEY',
});
Web3
Initialize Web3
import { Web3 } from 'mb-nft';
web3 = await Web3.initWeb3();
Auction House
Initialize Auction House
import { ZoraAuctionHouse } from 'mb-nft';
zoraAuctionHouse = await new ZoraAuctionHouse({
mbClient: mbClient,
web3: web3,
});
Create Auction
const auction = {
tokenId: 5, // Auction creator must be token owner
signer: web3.currentAccount,
duration: 3600,
reservePrice: '0.005',
// curator: ,
// curatorFeePercentage: ,
// auctionCurrency: ,
};
await zoraAuctionHouse.createAuction(auction);
Create Bid
const bid = {
auctionId: 5,
signer: web3.currentAccount,
bidPrice: '0.005',
};
await zoraAuctionHouse.createBid(bid);
Get Auction Details by Auction ID
Returns auction details included auction ID.
const auctionDetails = await zoraAuctionHouse.getAuctionDetailsByAuctionId({ auctionId: 12 });
Get Auction Details by Token ID
const auctionDetails = await zoraAuctionHouse.getAuctionDetailsByTokenId({ tokenId: 5 });
Get Remaining Time
Returns remaining time as an object { h, m, s } where h, m, s are the integer values of hours, minutes, and seconds respectively.
<span>Ends in {{ remainingTime.h }}H {{ remainingTime.m }}m {{ remainingTime.s }}s</span>
setInterval(async () => {
const requestArgs = {
auctionID: 6,
sync: true,
};
remainingTime = await zoraAuctionHouse.getRemainingTimeHMS(requestArgs);
}, 1000);