تخطَّ إلى المحتوى الرئيسي
727 Finance
العربية

InstructionFallbackNotFound. رقم الخطأ: 101. رسالة الخطأ: دوال الاحتياط غير مدعومة

يجب عليك توفير مُعرّف التعليمات (instruction discriminator) إلى بيانات معاملتك كما ذكر أديمولا. ما يمكنك فعله هو جلب مُعرّف التعليمات ثم إلحاقه ببياناتك في أول 8 بايتات. جلب مُعرّف التعليمات في Rust pub fn sighash(namespace: &str, name: &str) -> [u8; 8] { let preimage = format!("{}:{}", namespace, name);

let mut sighash = [0u8; 8]; sighash.copy_from_slice( &anchor_client::anchor_lang::solana_program::hash::hash(preimage.as_bytes()).to_bytes() [..8], ); sighash }

println!("{:?}", sighash("global", "initialize"));

جلب مُعرّف التعليمات في typescript function sighash(nameSpace: string, ixName: string): Buffer { let name = snakeCase(ixName); let preimage = `${nameSpace}:${name}`; return Buffer.from(sha256.digest(preimage)).slice(0, 8); }

يجب أن تكون namespace هي global إليك مثال في Typescript // Craft the InstructionBuffer const ixBuffer = sighash('global','initialize');

const instructionBuffer = Buffer.concat([ ixBuffer, // namespace+method_name OtherBuffer, // Other Data that you want to pass to the instruction. ])

// Craft the Instruction const transactionInstruction = new TransactionInstruction({ programId: programAddress, data: instructionBuffer, keys : [ ... ] })