1

I got the following .tsx code and when I trigger the tx it sucesfully prompts on phantom, however on accept, I get a console log error:

app-index.tsx:25 GOT ERROR Error: Unexpected error
    at Bi.<anonymous> (<anonymous>:3:235262)
    at Generator.next (<anonymous>)
    at s (<anonymous>:1:1456) window.console.error @ app-index.tsx:25 console.error @ hydration-error-info.ts:72 overrideMethod @ console.js:273 (anonymous) @ VM75581:3 s @ VM75581:1 Promise.then (async) u @ VM75581:1 (anonymous) @ VM75581:1 He @ VM75581:1 (anonymous) @ VM75581:3 (anonymous) @ VM75581:3 (anonymous) @ VM75581:1 He @ VM75581:1 Ay.signAndSendTransaction @ VM75581:3 (anonymous) @ VM75581:3 (anonymous) @ VM75581:1 He @ VM75581:1 (anonymous) @ VM75581:3 sendTransaction @ adapter.js:171 await in sendTransaction (async) eval @ WalletProviderBase.js:152 initMaster @ UserContext.tsx:160 await in initMaster (async) callCallback @ react-dom.development.js:20565 invokeGuardedCallbackImpl @ react-dom.development.js:20614 invokeGuardedCallback @ react-dom.development.js:20689 invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:20703 executeDispatch @ react-dom.development.js:32128 processDispatchQueueItemsInOrder @ react-dom.development.js:32160 processDispatchQueue @ react-dom.development.js:32173 dispatchEventsForPlugins @ react-dom.development.js:32184 eval @ react-dom.development.js:32374 batchedUpdates$1 @ react-dom.development.js:24953 batchedUpdates @ react-dom.development.js:28844 dispatchEventForPluginEventSystem @ react-dom.development.js:32373 dispatchEvent @ react-dom.development.js:30141 dispatchDiscreteEvent @ react-dom.development.js:30112 Show 1 more frame Show less app-index.tsx:25 WalletSendTransactionError: Unexpected error
    at StandardWalletAdapter.sendTransaction (adapter.js:205:1)
    at async eval (WalletProviderBase.js:152:1)
    at async initMaster (UserContext.tsx:160:46) 

What might be causing this?

Here's my function call on frontend:


console.log("Master Address: " + masterAddress);
console.log("Payer: " + user?.wallet_address);
console.log("ProgramId: " + PROGRAM_ID);

let tx = new Transaction();
console.log("Tryinf rx");

const instructone: TransactionInstruction = await program.methods
    .initMaster()
    .accounts({
        master: masterAddress,
        payer: user?.wallet_address,
        systemProgram: PROGRAM_ID,
    })
    .instruction();

tx.add(instructone);
const transactionSignature = await sendTransaction(tx, connection);

console.log("tx signature: " + transactionSignature);

Idl/Types:

    "instructions": [
        {
          "name": "initMaster",
          "accounts": [
            {
              "name": "master",
              "isMut": true,
              "isSigner": false
            },
            {
              "name": "payer",
              "isMut": true,
              "isSigner": true
            },
            {
              "name": "systemProgram",
              "isMut": false,
              "isSigner": false
            }
          ],
          "args": []
        },

I am not sure if it's handling Phantom on my end or something on the tx itself

enter image description here

enter image description here

1 Answer 1

3

Is systemProgram: PROGRAM_ID, the system program ID - 11111111111111111111111111111111?

import { SystemProgram } from "@solana/web3.js";

const instructone: TransactionInstruction = await program.methods
    .initMaster()
    .accounts({
        master: masterAddress,
        payer: user?.wallet_address,
        systemProgram: SystemProgram.programId,
    })
    .instruction();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.