I have an IDL here and I am trying to convert a function, but it is giving me errors. I am trying to use it on the browser. Can you please help as this is urgent? Thanks.
IDL:
{
"name": "initPurchase",
"accounts": [
{
"name": "buyer",
"isMut": true,
"isSigner": true
},
{
"name": "item",
"isMut": true,
"isSigner": false
},
{
"name": "merchant",
"isMut": false,
"isSigner": false
},
{
"name": "transaction",
"isMut": true,
"isSigner": false
},
{
"name": "vault",
"isMut": true,
"isSigner": false
},
{
"name": "buyerWallet",
"isMut": true,
"isSigner": false
},
{
"name": "mint",
"isMut": false,
"isSigner": false
},
{
"name": "tokenProgram",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
},
{
"name": "rent",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "amount",
"type": "u64"
}
]
},
My code:
const purchaseInitiation = await this.program.methods
.initPurchase(itemAmountBN)
.accounts({
//@ts-ignore
buyer: this.userPubKey,
item: itemPDA,
merchant: merchantPDA,
transaction: transactionPDA,
vault: vaultPDA,
//@ts-ignore
buyerWallet: this.userPubKey,
mint: itemCurrencyMintAddress,
})
.transaction();
const transactionSignature =
await this.sendAndConfirmTransactionWithAnchorWallet(purchaseInitiation);
Is there anything I am missing, because I keep getting this error:
index.browser.esm.js?156f:7826 Uncaught (in promise) Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0xbbf
at Connection.sendEncodedTransaction (index.browser.esm.js?156f:7826:1)
at async Connection.sendRawTransaction (index.browser.esm.js?156f:7783:1)
Any help would be greatly appreciated. Thanks.