Mint a Rental NFT
Prerequisites
How to create a rental NFT on-chain?
import {
createContract,
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 {
formatAcceptanceType,
formatCancellationFee,
formatDuration,
formatRentFee,
} from "ternoa-js/rent/utils";
const createContract = async () => {
try {
await initializeApi();
const keyring = await getKeyringFromSeed("//TernoaTestAccount");
// Here you create some constants with each helper and value you want. We use some random values:
const duration = formatDuration("subscription", 30, 100, true);
const acceptanceType = formatAcceptanceType("manual", null);
const rentFee = formatRentFee("tokens", 1);
const renterCancellationFee = formatCancellationFee("fixed", 1);
const renteeCancellationFee = formatCancellationFee("none");
// Create or retrieve the NFT you want to convert into a rental NFT.
const { nftId } = await createNft(
"hello world",
0,
undefined,
false,
keyring,
WaitUntil.BlockInclusion
);
// Provide each const one by one as parameters in our function below:
const rentalContractData = await createContract(
nftId,
duration,
acceptanceType,
true,
rentFee,
renterCancellationFee,
renteeCancellationFee,
keyring,
WaitUntil.BlockInclusion
);
console.log(`Contract created for NFT: ${rentalContractData.nftId}`);
} catch (e) {
console.error(e);
}
};The expected params
Response
Support
Last updated