I have a very weird use case.
I have a method in a program, my method is call "bid"
When i try to call it with program.transaction.bid(...) it worked 2 times, and it's not working anymore, i get the error above.
I haven't changed anything in the meantime. Nor the IDL, nor the deployed program.
I'm 100% sure that the loaded IDL is okay (i checked it with a console.log of program)
I'm aware that this error usually comes from misspelled instruction names, or case, but here it should not be the case since it worked, and it's not working anymore with no updates linked to this.
is there a way to try to understand the error thru logging stuff ? (try to see how anchor encode the instruction for example, check discriminator, etc ?)
May be someone have experienced the same problem ?
thanks in advance !
Edit after @0xShuk answer :
I have a method like this in the IDL :
{
"name": "bid",
"accounts": [
{
"name": "mint",
"isMut": false,
"isSigner": false
},
{
"name": "buyer",
"isMut": true,
"isSigner": true,
"docs": [
"CHECK"
]
},
{
"name": "seller",
"isMut": true,
"isSigner": false,
"docs": [
"CHECK"
]
},
{
"name": "escrowAccount",
"isMut": true,
"isSigner": false,
"docs": [
"CHECK"
]
},
{
"name": "vaultAuthority",
"isMut": false,
"isSigner": false,
"docs": [
"CHECK"
]
},
{
"name": "vaultAccount",
"isMut": true,
"isSigner": false,
"docs": [
"CHECK"
]
},
{
"name": "escrowAccountAuction",
"isMut": true,
"isSigner": false,
"docs": [
"CHECK"
]
},
{
"name": "chainlinkFeed",
"isMut": false,
"isSigner": false
},
{
"name": "chainlinkProgram",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false,
"docs": [
"CHECK"
]
},
{
"name": "rent",
"isMut": false,
"isSigner": false
},
{
"name": "tokenProgram",
"isMut": false,
"isSigner": false,
"docs": [
"CHECK"
]
}
],
"args": [
{
"name": "price",
"type": "u64"
},
{
"name": "numberRandomForSeeds",
"type": "u8"
}
]
},
and the client side code looks like this :
var transaction = await program.value.transaction.bid(
new BN(bidAmount),
number_random_for_seeds,
{
accounts: {
mint: mintAddress,
buyer: buyer,
seller: seller,
escrowAccount: escrowAccountBid.publicKey,
escrowAccountAuction: escrowAccountAuction,
vaultAuthority: vaultAccountAuthority,
vaultAccount: vaultAccountPda,
chainlinkFeed: CHAINLINK_FEED,
chainlinkProgram: CHAINLINK_PROGRAM,
systemProgram: SystemProgram.programId,
rent: SYSVAR_RENT_PUBKEY,
tokenProgram: TOKEN_PROGRAM_ID
},
instructions: [
await program.value.account.escrowAccountAuctionBid.createInstruction(escrowAccountBid)
]
}
)
for information, i use program.value because i'm in a vue3 reactive env, and the program.value variable is equal to "program" that we usually use with anchor.
Edit after some more reasearch
There is something even more weird :
i have this code :
let preimage = 'global:bid';
let result = Buffer.from(sha256.digest(preimage)).slice(0, 8);
const toHexString = (bytes) => {
return Array.from(bytes, (byte) => {
return ('0' + (byte & 0xff).toString(16)).slice(-2);
}).join('');
};
console.log(toHexString(result));
in my app (vue + vite app) this logs "27719e5294ef89c7" which is the wrong discriminator, and in another app (node app) this logs "c738552692f3259e" which is the right discriminator.
In other words, the discriminator creation in my app is broken for some reason. Could it be linked with this line in my code ?
var global = global || window;
Seems like there is something breaking "sha256" code...
bid
, the discriminator should bec738552692f3259e
like this tx: solscan.io/tx/…. The problem is most probably either in the client side code or in IDL, share both in the question for further look.