Durable-Nonces: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toBuffer')

Durable-Nonces: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toBuffer')

Manage alerts

Loading saved threads...

Eduardo Chongkan · External communityPost link
External question — Solana Stack Exchange Author: Eduardo Chongkan Original post: https://solana.stackexchange.com/questions/12974 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. On the Client/Browser When trying to initialize a new NonceAccount following the recipe from the [Cookbook][1] & Phantom Solana Coobook Instruction: https://solanacookbook.com/references/offline-transactions.html#create-nonce-account SystemProgram.nonceInitialize({ noncePubkey: nonceAccount.publicKey, // nonce account pubkey authorizedPubkey: nonceAccountAuth.publicKey, // nonce account authority (for advance and close) }) Problem 1: Only works in scenarios where both accounts are being generated at runtime or all Keypairs are available from storage. (All Signers in the same Device and Runtime) The Nonce account is generated at the client side, and it makes sense given that it is a nonce account and it is closely tied to that specific user. Storing the Keypair, encrypted in a safe place on the client is a concern. ( to be discussed elsewhere ) Issue : The given example only works when both accounts are being created in the same runtime or if the Keypairs are available in the same runtime. Meaning the Client has complete control over the NonceAccount. Removing the error**: In order to provide an Authority that is not in the same runtime/device, I needed to pass the PublicKey Object (removed the property) dapp could be a merchant, a website, etc. const dapp = new PublicKey('Atts2amU6HedVyHrouhvqGogHw1FzgJFjbabD8iRmvhi'); SystemProgram.nonceInitialize({ noncePubkey: nonceAccount.publicKey, // nonce account pubkey authorizedPubkey: dapp, // nonce account authority (for advance and close) }) Problem 2: The instruction presents no more problems at this point, but it then throws a new error when trying to send the transaction ( and sign ) console.log( `txhash: ${await connection.sendTransaction(tx, [feePayer, nonceAccount])}` ); The new error is: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toString') at legacy.ts:446:47 And is caused by the previous Instruction (weird) let tx = new Transaction().add( // create nonce account SystemProgram.createAccount({ fromPubkey: feePayer.publicKey, newAccountPubkey: nonceAccount.publicKey, lamports: await connection.getMinimumBalanceForRentExemption( NONCE_ACCOUNT_LENGTH ), space: NONCE_ACCOUNT_LENGTH, programId: SystemProgram.programId, }), ... ); Solution for problem 2**: Similar to the previous solution, removing the .publicKey property and passing the feePyer object (PublicKey Obj) resolved the problem. Problem 3: The cause of the new error is that the Phantom object doesn't contain the PublicKey object properties & methods, specifically the toBase58 method. I am currently stuck at this point. I also tried different combinations for sending and signing using the provider ( Phantom ) but each one ended in some error. https://docs.phantom.app/solana/sending-a-transaction
Quote
Report
Eduardo Chongkan · External communityPost link
External answer — Solana Stack Exchange Author: Eduardo Chongkan Original post: https://solana.stackexchange.com/a/13244 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Solution or Workaround : This is how I managed to get it working: https://gist.github.com/chongkan/edffe0613cad007322ea486e323e0f72 However, I am not sure this is the best approach. Feedback is appreciated.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Solana Stack Exchange Author: Eduardo Chongkan Source score (net votes, not local likes): 0 Original post: https://solana.stackexchange.com/a/13244 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Solution or Workaround : This is how I managed to get it working: https://gist.github.com/chongkan/edffe0613cad007322ea486e323e0f72 However, I am not sure this is the best approach. Feedback is appreciated.

Cancel quote

Checking account access…