-
Notifications
You must be signed in to change notification settings - Fork 973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WalletSendTransactionError: failed to get recent blockhash: TypeError: Failed to fetch #461
Comments
Don't follow any support links. There is no Solana Support, this is a scam. |
Thanks, it didn’t look legit lol. Any idea what could be causing this issue? Could it maybe something with React 18? |
Does the starter example work for you? https://solana-labs.github.io/wallet-adapter/example/ |
Yeah, and I’ve built a number of other apps before that work but when starting a new project this issue persists now. I linked a barebones repo showing the problem |
Oh, I looked at your reproduction repo. The problem is that CRA doesn't work out of the box with ESM projects that don't polyfill Node deps. Check out the CRA starter project we ship: https://github.com/solana-labs/wallet-adapter/tree/master/packages/starter/create-react-app-starter It includes the config you need. |
I can't say 100% that this is the only issue, but it's definitely going to cause a problem, so if the example works, it's likely the project build config. |
I was using craco to polyfill the node dependencies, i may have forgotten to include the craco files in the repo i linked. I’m getting the same Failed to fetch error with or without node deps being polyfilled though. |
Unfortunately I can only see from your reproduction repo that it's using CRA without Craco or react-app-rewired: https://github.com/billyjacoby/solana-tx-issue/blob/d59b88ff7da9246da961113dc903d426f272c9bb/package.json#L28-L33 Additionally, I just added this component (derived from the example project) to the create-react-app-starter project that uses react-app-rewired: import { useConnection, useWallet } from '@solana/wallet-adapter-react';
import { PublicKey, Transaction, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
import { FC, useCallback } from 'react';
export const SendTransaction: FC = () => {
const { connection } = useConnection();
const { publicKey, sendTransaction } = useWallet();
const onClick = useCallback(async () => {
if (!publicKey) {
console.error('error', 'Wallet not connected!');
return;
}
let signature: TransactionSignature = '';
try {
const transaction = new Transaction().add(
new TransactionInstruction({
data: Buffer.from('Hello, from the Solana Wallet Adapter example app!'),
keys: [],
programId: new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'),
})
);
signature = await sendTransaction(transaction, connection);
console.info('info', 'Transaction sent:', signature);
await connection.confirmTransaction(signature, 'processed');
console.info('success', 'Transaction successful!', signature);
} catch (error: any) {
console.error('error', `Transaction failed! ${error?.message}`, signature);
return;
}
}, [publicKey, connection, sendTransaction]);
return (
<button onClick={onClick} disabled={!publicKey}>
Send Transaction (devnet)
</button>
);
}; Because the example works and the CRA starter project works, I'm going to close this issue. It appears to be a problem with your project's configuration. If you find out it's an issue with Brave instead, please let me know. But if the example project works for you in Brave, then it's almost certainly a project config issue. |
Just updated my repo to include the proper Craco config. Can you confirm that if you clone the repo it works for you? @jordansexton |
I'm looking @ https://github.com/billyjacoby/solana-tx-issue and it doesn't depend on Craco or have any config for it. |
I copy and pasted the example you provided as well with the same results: https://github.com/billyjacoby/solana-tx-issue |
Looks like Github just updated. You're not importing |
Please just use the starter project provided. I promise you it works. |
I am though: https://github.com/billyjacoby/solana-tx-issue/blob/b44e8098d93f22a98562c075f607973071323baa/src/index.tsx#L12 |
https://github.com/dilanx/craco
|
Craco doesn't work with CRA 5, and CRA 4 doesn't handle ESM imports properly. All of this is avoided by using one of the provided starter projects. |
Also, what the heck: https://github.com/billyjacoby/solana-tx-issue/blob/b44e8098d93f22a98562c075f607973071323baa/package.json#L19 You're depending on Craco is on version 6.4.4 You have the wrong package. The correct one is |
That is weird, idk why its relying on that version there. I'm getting the exact same error with the starter. Pushing to repo now |
https://github.com/billyjacoby/solana-CRA-issue This is a CRA copied right from the starter provided with the SendTransaction code from above included and I'm getting the same errors. |
Actually this looks like it might be an issue with Phantom. In both repos i was able to send the transaction using Slope just now, though I tried this the other day and was unable to. |
Yep, I just cloned that repo and it works fine. git clone https://github.com/billyjacoby/solana-CRA-issue.git
cd solana-CRA-issue
yarn
yarn start This is in Firefox with Phantom. |
Do you not have Phantom set to use devnet? Because that will do this. |
Ahhhhh that's it exactly. That makes it work with the starter repo. I did try that with the other repo and was getting the same results but it seems like that was probably a Craco issue. It's been a few months since I've been developing on Solana, I don't think Phantom used to care what network you were on when sending a transaction which i always thought was a bit dangerous so I'm glad to see that's not possible anymore. As always, thanks a ton for your help Jordan! |
It's possible that's because of this change: 67df674 We always set the recent blockhash and fee payer, even if the wallet wants to change them. Perhaps Phantom was being loose when it was empty and defaulting to whatever the hash was on the currently selected cluster. |
I encountered the same problem in this code:
the output:
I use wsl2, ubuntu 20.04. What I miss? |
Describe the bug
Unable to send any transactions using multiple wallet adapters - Slope and Phantom tried.
Unable to even get latestBlockhash from devnet or testenet when trying to create a simple test transaction
To Reproduce
Steps to reproduce the behavior:
Here is a public repo that has a barebones React app created that shows the issue:
https://github.com/billyjacoby/solana-tx-issue
Expected behavior
I can make transactions using wallet-adapters
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: