5
votes
Accepted
What method should a dApp use to detect a change in Wallet Network for any wallet supported in the Solana Wallet Adapter?
I'll answer this as comprehensively as I can.
Unfortunately you may be displeased (as am I!) to know that this isn't generally possible.
Let's cover network changes first.
This issue (which is quite ...
3
votes
Errors when using `@project-serum/anchor` with Next.js v14 using Webpack 5
You don't need to roll back to previous versions. NextJS allows you to opt out of bundling packages that use NodeJS features.
Add the following to your nextjs.config.mjs:
experimental: {
...
3
votes
Accepted
Issue with Next.js 13 and Solana Wallet Adapter packages
Solved this by separating the WalletProvider component as a Client component. All components inside the app/ directory will be treated as Server components, unless you annotate the file with 'use ...
3
votes
sendAndConfirmTransaction returns Cannot read properties of undefined (reading 'toString')
Presuming that useWallet() is from @solana/wallet-adapter, its return value is not a Signer.
The return value of useWallet is a WalletContextState.
WalletContextState does not expose the private key ...
2
votes
Accepted
sendAndConfirmTransaction returns Cannot read properties of undefined (reading 'toString')
I found the solution and turns out it was just a rookie mistake on my side.
The mintPublicKey I was passing to the "getAssociatedAddress" function was the mint address in the string form ...
2
votes
Display Updated Wallet Balance After Transaction Confirmed
figured out a solution with onAccountChange
https://solana-labs.github.io/solana-web3.js/classes/Connection.html#onAccountChange
here's my solution
https://github.com/Unboxed-Software/solana-send-sol-...
2
votes
I am prevented from creating a next app by my PC
The problem you are facing isn't related to Solana but is a Windows limitation.
Windows doesn't let you create a directory a directory in C:\Windows. If you try creating it on your desktop it will ...
2
votes
Accepted
Add spl-token balance to wallet balance context provider
You can easily add any token to your existing context. There are various ways to do this. I am using the most basic (using spl-token library):
First import spl-token library:
import * as token from &...
2
votes
Accepted
src.toArrayLike is not a function
The parameter that you are passing, which is 0.005, must be of BigNumber type.
Import BN class from anchor and put the number inside it, that will fix your problem.
It should look like:
import { BN } ...
1
vote
Accepted
TypeError: Cannot read properties of undefined (reading 'size')
The problem could be related to incorrect IDL loading. Then it's good to verify the contents of your ./id.json file. While based on the discussion, it seems this isn't the issue.
Then, I encountered a ...
1
vote
anchor build not working for my project
Could you try clearing your $HOME/.cache/solana as suggested by this answer https://solana.stackexchange.com/a/3378/1708
1
vote
Fresh development environment fails to install required packages (NextJS/Typescript Env)
It looks like you might be missing some dependencies. According to https://github.com/anza-xyz/wallet-adapter/blob/master/APP.md#quick-setup-using-react-ui, you should run:
yarn add \
@solana/...
1
vote
TypeError: off is not a from solanaWalletAdapter
I have experienced this when using the OKX wallet. Removing/disabling the wallet the issue is fixed.
1
vote
Accepted
Cannot use solana TS packages on CommonJS module
Ok, this is the tsconfig.json that solved my problem:
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"lib&...
1
vote
umi functions causing Application error: a client-side exception has occurred
When fetching a candy machine account, the type of candyMachine.itemsRedeemed will always be a bigint. Therefore:
(candyMachine.itemsRedeemed === 500 as BigIntInput)
is strictly comparing a number ...
1
vote
How to update items available count on candy machine UI after someone mints? Next app using umi
The presented code does refresh after mint occurs, the problem is with "candyMachine.data.itemsAvailable" It shows the total amount inserted into the candyMachine. Use candyMachine....
1
vote
How to dynamically import clusterApiUrl in next js
this is the typescript signature of next.js dynamic
function dynamic<P = {}>(dynamicOptions: DynamicOptions<P> | Loader<P>, options?: DynamicOptions<P>)
// ...
1
vote
How to dynamically import clusterApiUrl in next js
You can use the same principle to import external libraries using import() at the point where that module is needed. Architect your code such that clusterApiUrl is only needed in a codepath that's ...
1
vote
Transaction working locally and with ngrok (https), but not working when deploying to aws amplify
In the next.config.js
Remove the swcMinify: true
Worked!
1
vote
Phantom: WalletSendTransactionError: Something went wrong nextjs
Solution
File: next.config.js
Remove: swcMinify: true
It works for me
1
vote
Accepted
Conditional rendering with Solana Wallet Adapter & NextJS
I think the Backend API Protection should be there for sure and better bring in the AdminList from the backend and then validate. I would suggest to make the publickey validation more secure better ...
1
vote
Accepted
Detect account switching in Phantom Wallet?
From the docs: establishing-a-connection#changing-accounts
There are different methods to detect the provider.
provider.on('accountChanged', (publicKey) => {
if (publicKey) {
// Set new ...
1
vote
Accepted
How do I use WalletPovider for a function outside of return()?
You need to move the providers a level up in the component tree. The provider and consumer cannot be defined in the same component.
This is less about WalletProvider specifically and more of a general ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
nextjs × 33solana-wallet-adapter × 17
web3.js × 15
anchor × 5
react × 5
spl-token × 4
typescript × 4
solana-program × 3
phantom × 3
dapp × 3
metaplex × 2
rust × 2
nft × 2
staking × 2
solana-cli × 2
spl-associated-token-account × 2
wallet × 1
javascript × 1
anchor-program-idl × 1
solana-pay × 1
balance × 1
send-transaction × 1
freeze-token-account × 1
gemfarm × 1
walletprovider × 1