Create Auction
The create Auction functionality allows you to run generic auction without or with an asset. Asset can be an NFT. You can also bid on an Auction or get more infos about a specific Auction.
- OTR
- HTTPS
To create auction, you must call create on dataset(Dataset.AUCTION).
create takes an object of type AuctionCreateTangleRequest as parameter.
const otrCreateRequest = otr(otrAddress).dataset(Dataset.AUCTION).create({
auctionFloorPrice: 1000000,
auctionFrom: new Date(),
auctionLength: 8.64e7, // 1 day in milliseconds
maxBids: 1,
minimalBidIncrement: 1000000,
network: Network.RMS,
space: 'build5spaceid',
});
create returns an oject of type OtrRequest<AuctionCreateTangleRequest>
The SDK provides the helper functions getFireflyDeepLink() and getBloomDeepLink() to generate deep links for OTR requests.
The response transaction to your OTR will include an Auction ID which others can use to bid on your auction or to get more info about your Auction.
To create auction, you must call create on dataset(Dataset.AUCTION).
create takes an object of type AuctionCreateRequest as parameter.
let auction = await https(origin)
.project(SoonaverseApiKey[origin])
.dataset(Dataset.AUCTION)
.create({
address: address.bech32,
signature: userSign.signature,
publicKey: {
hex: userSign.publicKey,
network: Network.RMS,
},
body: {
auctionFloorPrice: 1000000,
auctionFrom: new Date(),
auctionLength: 8.64e7, // 1 day in milliseconds
maxBids: 1,
minimalBidIncrement: 1000000,
network: Network.RMS,
space: 'build5spaceid',
},
});
console.log('Auction created with id: ', auction.uid);
create returns an oject of type Auction.
You can use the Auction ID to bid on the Auction or get more info about it.
Full How-To Code
- OTR
- HTTPS
import { Dataset, Network } from '@build-5/interfaces';
import { Build5, SoonaverseOtrAddress, otr } from '@build-5/sdk';
async function main() {
const origin = Build5.TEST;
// @ts-ignore
const otrAddress = SoonaverseOtrAddress[origin];
try {
// To create a generic auction we send an otr request with the needed params
const otrCreateRequest = otr(otrAddress).dataset(Dataset.AUCTION).create({
auctionFloorPrice: 1000000,
auctionFrom: new Date(),
auctionLength: 8.64e7, // 1 day in milliseconds
maxBids: 1,
minimalBidIncrement: 1000000,
network: Network.RMS,
space: 'build5spaceid',
});
const fireflyDeeplink = otrCreateRequest.getFireflyDeepLink();
console.log(fireflyDeeplink);
} catch (error) {
console.error('Error: ', error);
}
}
main().then(() => process.exit());
import { Dataset, Network } from '@build-5/interfaces';
import { Build5, SoonaverseApiKey, https } from '@build-5/sdk';
import { address } from '../../utils/secret';
import { walletSign } from '../../utils/utils';
async function main() {
const origin = Build5.TEST;
const userSign = await walletSign(address.bech32, address);
try {
// To create a generic auction we send an https request with the needed params
let auction = await https(origin)
.project(SoonaverseApiKey[origin])
.dataset(Dataset.AUCTION)
.create({
address: address.bech32,
signature: userSign.signature,
publicKey: {
hex: userSign.publicKey,
network: Network.RMS,
},
body: {
auctionFloorPrice: 1000000,
auctionFrom: new Date(),
auctionLength: 8.64e7, // 1 day in milliseconds
maxBids: 1,
minimalBidIncrement: 1000000,
network: Network.RMS,
space: 'build5spaceid',
},
});
console.log('Auction created with id: ', auction.uid);
} catch (error) {
console.error('Error: ', error);
}
}
main().then(() => process.exit());