Can't sign a transaction partially (partialSign)

As I was trying to sign a tx using a node script for multi-sig account, I got an error.
Here is my code snippet.

    const { blockhash } = await connection.getLatestBlockhash();

    const transaction = new Transaction().add(
      createMintToInstruction(
        mintPublicKey,
        destination,
        mintAuthority,
        addtionalSupply,
        signer,
        TOKEN_PROGRAM_ID
      )
    );

    transaction.recentBlockhash = blockhash;
    transaction.feePayer = publicKey;
    transaction.partialSign({
      publicKey: publicKey,
      secretKey: signer,
    });

Here is an error log:

Error while sign tx:  TypeError: Cannot read properties of undefined (reading 'toString')
Error while sign tx:  TypeError: Cannot read properties of undefined (reading 'toString')
    at E:\Recent\Sol-token-mint-script\node_modules\@solana\web3.js\lib\index.cjs.js:1503:47
    at Array.forEach (<anonymous>)
    at Transaction.compileMessage (E:\Recent\Sol-token-mint-script\node_modules\@solana\web3.js\lib\index.cjs.js:1502:18)
    at Transaction._compile (E:\Recent\Sol-token-mint-script\node_modules\@solana\web3.js\lib\index.cjs.js:1625:26)
    at Transaction.partialSign (E:\Recent\Sol-token-mint-script\node_modules\@solana\web3.js\lib\index.cjs.js:1754:26)
    at E:\Recent\Sol-token-mint-script\script1.js:51:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Any idea? Hope to hear from you.
Thanks.

1 Like