Buying
This guide explains how to buy an NFT by its current renter
1. Retrieve Market Contract:
First you need to access to the Market contract:
const contracts = stash.contracts;
const market = contracts.market;
2. Call Buy Function:
To perform the buying operation, you can directly call buy
function on the market contract:
market.buy(
tokenId,
standard,
(response) => {
// On success
// response.transactions[0].txn_hash will give the transactoin hash
console.log('buy success callback triggered', response);
},
(error) => {
// On error
console.log('error triggered', error);
}
)
If any error occurs (e.g. user declines approval request or contract call fails) during the process, the error object error
contains respective information about the reason of the failure. You can find more information about the error structure under Error Handling section in Integration docs.
If the buying has been successfully performed, then the success callback is called where the response object contains information about the executed transactions.
Updated 4 months ago