Add or remove a bid on an auction

Prerequisites

Before getting started, make sure you have the following ready:

  1. Create a Ternoa account with Alphanet CAPS

  2. Install and set up your editor of choice (we will use Visual Studio Code [VSC] in this tutorial)

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.

circle-info

Use your own account by updating the //TernoaTestAccount with your account seed when retrieving the keyring from the example below. Replace the NFT_ID with the existing one to bid on, and the bidAmount.

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.

circle-info

Use your own account by updating the //TernoaTestAccount with your account seed when retrieving the keyring from the example below. Replace the NFT_ID with the existing one to remove the bid.

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 Discordarrow-up-right.

Last updated