Add or remove a bid on an auction
Prerequisites
Before getting started, make sure you have the following ready:
Create a Ternoa account with Alphanet CAPS
Install and set up your editor of choice (we will use Visual Studio Code [VSC] in this tutorial)
Install NodeJS v.14+ & NPM
Bid on an auction using Ternoa-JS
This function adds a bid to an existing auction NFT on the Ternoa chain. It returns an object promise containing the BidAddedEvent provided by the Ternoa blockchain.
import {
addBid,
initializeApi,
getKeyringFromSeed,
WaitUntil,
} from "ternoa-js";
const auctionBid = async () => {
try {
await initializeApi();
const keyring = await getKeyringFromSeed("//TernoaTestAccount");
const NFT_ID = // update with the nft id you want to bid on.
const bidAmount = // update with the amount to bid.
const res = await addBid(
NFT_ID,
bidAmount,
keyring,
WaitUntil.BlockInclusion
);
console.log(`Bid added to NFT ${res.nftId} for ${res.amountRounded}CAPS`);
} catch (e) {
console.error(e);
}
};The expected params
Response
The response provided from the blockchain event includes all the information below according to the parameters provided when bidding on an auction.
Remove a bid using Ternoa-JS
This function removes a bid from an auction on the Ternoa chain. It returns an object promise containing the BidRemovedEvent provided by the Ternoa blockchain.
The expected params
Response
The response provided from the blockchain event includes all the information below according to the parameters provided when removing a bid.
Support
If you face any trouble, feel free to reach out to our community engineers in our Discord.
Last updated