wallet-adapter: WalletSignTransactionError: Something went wrong.

Describe the bug

When I’m testing in local development (w/ mainnet-beta and custom RPC), our airdrop code works perfectly. but when moving it into prod, it complains WalletSignTransactionError: Something went wrong.. I checked all the ENV variables and made sure it was the same.

To Reproduce

const transaction = new Transaction();

      // create token account
      if (receiverAccount == null) {
        transaction.add(
          createAssociatedTokenAccountInstruction(
            sender,
            receiverATA,
            receiver,
            mint
          )
        );
      }

      // add transfer instruction
      transaction.add(
        createTransferCheckedInstruction(
          senderATA,
          mint,
          receiverATA,
          sender,
          1,
          0
        )
      );

      const recentBlockhash = await connection.getLatestBlockhash();
      transaction.recentBlockhash = recentBlockhash?.blockhash;
      transaction.feePayer = sender;

      await signTransaction(transaction);

Expected behavior I expected to work in both production and development

Screenshots Screen Shot 2022-10-04 at 3 45 21 PM Screen Shot 2022-10-04 at 3 45 18 PM

Screen Shot 2022-10-04 at 5 13 04 PM

Desktop (please complete the following information):

  • OS: MacOS monterey
  • Browser chrome
  • Version latest

Additional context NA

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 21 (1 by maintainers)

Most upvoted comments

This is fixed in vercel/next.js v12.3.2-canary.32. Update and you’re on your way!

@steveluscher You’re right. swcMinify is the problem. Setting it to false in next.config.js makes the site works: https://nextsol.ibcoder.com

@YoungMahesh great! I might go ahead and do some testing with a vanilla Next app just to understand what the issue is and why the starter works if that doesn’t.

Can you try to deploy the Next.js starter project and tell me if there are issues there? I’ve run this locally without a problem, but haven’t deployed it recently. You may have to update the config to include the wallets you’re testing.

@jordansexton , I had exactly same problem mentioned by @stanleycyang on the top and using Next.js starter resolved my issue. (I also tried Downgrading to Next.js ^11.1.4 as mentioned by @kimpers but it didn’t worked for me)

This fails in local after build as well. Have similar issue but not entirely same, here in my devnet (so it doesn’t have any relation with devnet, testnet, mainnet) -> https://nextsol.ibcoder.com. GitHub code: https://github.com/vasudeveloper001/solana-next-app

It definitely fails during build in nextjs. image

Using source-map debugging, it is pointing to wallet-adapter’s code around here:

adapter.js code piece pointed by source-maps.

async sendTransaction(transaction, connection, options = {}) {
        try {
            const wallet = this._wallet;
            if (!wallet)
                throw new WalletNotConnectedError();
            try {
                const { signers, ...sendOptions } = options;
                transaction = await this.prepareTransaction(transaction, connection, sendOptions);
                signers?.length && transaction.partialSign(...signers);
                sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;
                const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions);
                return signature;
            }
            catch (error) {
                if (error instanceof WalletError)
                    throw error;
                throw new WalletSendTransactionError(error?.message, error);
            }
        }
        catch (error) {
            this.emit('error', error);
            throw error;
        }
    }

Wallet-Provider calls adapter.js above

const sendTransaction = useCallback(
  async (transaction, connection, options) => {
    if (!adapter) throw handleError(new WalletNotSelectedError());
    if (!connected) throw handleError(new WalletNotConnectedError());
    return await adapter.sendTransaction(transaction, connection, options);
  },
  [adapter, handleError, connected]
);

Weird thing, this used to work like few months back!

EDIT: Also tried changing the checkout page to getServerSideProps type. Doesn’t work. Removing authentication check on the page, doesn’t work either. And it fails with SolFare as well, so have nothing to do with Wallets either.

Thanks! I’ll test that.

Thanks, looking into this!