Configure a marketplace
Prerequisites
How to set the marketplace configuration on-chain?
import {
setMarketplaceConfiguration,
initializeApi,
getKeyringFromSeed,
WaitUntil,
} from "ternoa-js";
//First import the helpers for every parameter you need. Helpers expect the values (strings, number, boolean (..)) and return the corresponding expected object.
import {
formatMarketplaceFee,
formatMarketplaceAccountList,
formatMarketplaceOffchainData,
formatMarketplaceCollectionList,
} from "ternoa-js/marketplace/utils";
const createContract = async () => {
try {
await initializeApi();
const keyring = await getKeyringFromSeed("//TernoaTestAccount");
const marketplaceId = //to be updated
const offchainDataHash = //to be updated
const collectionId = //to be updated
const address = //to be updated
// Here you create some constants with each helper and value you want. We use some random values:
const formattedCommissionFee = formatMarketplaceFee(
"set",
"percentage",
10
);
const formattedListingFee = formatMarketplaceFee("set", "flat", 100);
const formattedAccountList = formatMarketplaceAccountList("set", [
address,
]);
const formattedOffchainData = formatMarketplaceOffchainData(
"set",
offchainDataHash
);
const formattedCollectionList = formatMarketplaceCollectionList(
"set",
[collectionId]
);
// Provide each const one by one as parameters in our function below:
const mpEvent = await setMarketplaceConfiguration(
marketplaceId,
formattedCommissionFee,
formattedListingFee,
formattedAccountList,
formattedOffchainData,
formattedCollectionList,
keyring,
WaitUntil.BlockInclusion
);
console.log(`Marketplace: ${mpEvent.nftId} correctly updated`);
} catch (e) {
console.error(e);
}
};The expected params
Response
Support
Last updated