Create buy offer
// XVerse Wallet example of creating a signing request
// when buying an Ordinal
// Create the purchase PSBT by calling /marketplace/create-offer
const { data } = await axios({
method: 'post'
url: 'https://api.ordinalsbot.com/marketplace/create-offer',
data: {
ordinalId: id,
buyerPaymentAddress: paymentAddress,
buyerOrdinalAddress: ordinalsAddress,
buyerPaymentPublicKey: paymentPublicKey
},
headers: {
'x-api-key': API_KEY,
});
// returned response has a base64 encoded psbt to sign and an array of input
// indices which the buyer needs to sign with the payment address wallet
const buyerInput = {
address: paymentAddress, // Buyer's payment wallet address
signingIndexes: data.buyerInputIndices
};
// When using XVerse Wallet
// Create the payload for signing the buyer transaction
const payload = {
network: { type: "Mainnet" },
message: "Sign Buyer Transaction",
psbtBase64: data.psbt,
broadcast: false,
inputsToSign: [buyerInput],
};
// Make signing request
await signTransaction({
payload,
onFinish: async (response) => {
try {
// Here make a call to /submit-offer
// Things to do after successful signing
} catch (Error) {
// error handling
}
},
onCancel: () => { // User cancelled signing request }
});
POST Buy an ordinal
POST Buy an ordinalBuy a listed ordinal
Request Body
Name
Type
Description
Last updated