Questions tagged [web3.js]

Questions regarding the JavaScript SDK @solana/web3.js.

Filter by
Sorted by
Tagged with
0 votes
0 answers
4 views

Start using Jupiter SDK, load

I try to use Jupiter SDK, but receive incorrect account name during parsing Error: Failed to parse tick array DVL89XGZmTAZNwvNQHfxUiNVvt4GpBHYn4kT3yoJ8NKP code: this.jupiter = await Jupiter.load({ ...
  • 341
2 votes
0 answers
11 views

What's the best way to restore a keyPair from a string, extracted with secretKey.toString()?

Say I have a secretKeyString extracted from a keyPair using keyPair.secretKey.toString(); I know I can restore a keyPair from the string with: const secretKeyStringToKeypair = (secretKeyString: string)...
1 vote
1 answer
47 views

How can I use TypeScript to change the mint authority of a token account?

I know it is possible to change the mint authority using solana-spl as shown here. How can I achieve the same thing using TypeScript/JS?
  • 55
0 votes
1 answer
16 views

How do I filter token accounts by amount of tokens?

I understand how to use memcmp to get accounts for a particular token using getParsedProgramAccounts, however since memcmp is an equality, I can't really query for "greater than" a certain ...
0 votes
0 answers
14 views

Can we upload more than 1 media file for 1 NFT with sugar

I want to know if I can upload more than 1 media file for a single NFT with sugar candy machine V3 or not. What I mean is I want to upload an image and an MP4 file for the same NFT and want to put ...
2 votes
1 answer
23 views

Calling the getSignaturesForAddress returns empty

Context: I am trying to get a history of transactions for an address. I plan to use the getSignaturesForAddress() to get all the signatures I could use to find all the confirmed transactions using the ...
  • 31
0 votes
0 answers
12 views

Error downloading the ComputeBudget program to use on local validator

Per the Solana Cookbook, I'd like to set a transaction priority by using fees. transaction.add( ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000, }) ); transaction.add( ...
3 votes
2 answers
42 views

how can i check / verify past events of my smartcontract?

I want to check my past event emitted by smart contract during function call so that I can verify that the function is actually called. ``program.addEventListner()``` is used only for real-time I need ...
2 votes
1 answer
118 views

Transaction is not getting signed while using glow wallet from solana-wallet-adapters

Signing using glow wallet is not working with @solana/wallet-adapter-react , I am getting the signature as 11111111111111111111111111111111111111. import { useWallet } from '@solana/wallet-adapter-...
  • 73
2 votes
3 answers
155 views

How do I mint an SPL token with custom Metadata using @solana/web3.js and @solana/spl-token?

Similar to https://stackoverflow.com/questions/69701491/add-meta-data-to-solana-token-with-solana-web3-js, however, the only answer for that question is in Rust and the question asker ended up moving ...
0 votes
1 answer
8 views

GetMultiple for Mints?

Let's say we have an array of Pubkeys: let arr: Pubkey[] = [whatever] We have connection.getMultipleAccountsInfo(arr) to get many AccountInfo in one RPC call. We have getMint() from the spl-token ...
  • 1,040
3 votes
2 answers
34 views

How to check what network your wallet is on, ReactJs

I am using @solana/wallet-adapter-react How can I check what network I am on? because I want to show an alert to users that they are on devnet and should switch to mainnet
3 votes
1 answer
54 views

Find what cluster is being operated on from Connection object

If I a have a Connection object from web3js, is there a way I can determine from this if it is operating on mainnet or devnet (or some local network)? The only thing in this direction I could think of ...
2 votes
1 answer
23 views

I need help with changing the contents of a page once a wallet has been connected

Im currently building a project using Create React App with Typescript, web3.js and ChakraUI. I've set up the 'connect to wallet' button using the Solana Wallet Adapter, and the wallet stays connected ...
1 vote
1 answer
10 views

What is the proper way to get current inflation rate with solana web3.js

I'm attempting to get the current total network inflation rate in my application. I thought that historically there was a method for this provided by web3.js, but that doesn't seem to be the case. The ...
  • 41
0 votes
1 answer
32 views

Using Address Lookup table in jupiter

I using Jupiter for swapping. Can I extend Jupiter Address Lookup table, or I should use own lookup table for my addresses ?
  • 341
0 votes
1 answer
31 views

Signature Verification failed while transfering sol NFT

import * as web3 from "@solana/web3.js"; import { Token, TOKEN_PROGRAM_ID } from "@solana/spl-token"; async function transfer(tokenMintAddress: string, to: string) { const ...
1 vote
1 answer
29 views

Adding instruction to jupiter swapTransaction

I using Jupiter v4 for swapping. To SwapInstruction from Jupiter, I add some of my instruction and try to execute the transaction, but receive sometimes error: encoded solana_sdk::transaction::...
  • 341
1 vote
0 answers
44 views

How can I check the particular account which has insufficient funds for rent from transaction error

I am getting the "Transaction simulation failed: Transaction results in an account (2) without insufficient funds for rent" error while executing the transaction, So how can I check the ...
  • 353
3 votes
1 answer
32 views

How can I get the transaction instructions from VerisonedTransaction object

I need to get all the transaction instructions from the Versioned transaction object. Any idea about this?
  • 353
2 votes
2 answers
34 views

How to dynamically import clusterApiUrl in next js

I want to dynamically import clusterApiUrl from "@solana/web3.js" using next/dynamic, but I get an error "clusterApiUrl is not a function". This is how I import it: const ...
3 votes
1 answer
30 views

Getting transaction info on account changes using JS

Using JS, how would I go about getting transaction information on transactions that affect the balance of a specific account? I've been able to listen for account changes with the following code, but ...
  • 133
1 vote
1 answer
23 views

How to get "feeCalculator` since "getRecentBlockhash()" deprecated?

This is how feeCalculator is received before: const { feeCalculator } = await connection.getRecentBlockhash(); getRecentBlockhash() is deprecated. Instead we use connection.getLatestBlockhash() I ...
  • 810
2 votes
1 answer
35 views

Sending USDC dev token not working until recepient wallet has >0 value of said token

I am trying to send usdc dev token using code to a wallet address but it kept on showing "Unable to simulate. Make sure you trust this website since approving can lead to loss of funds." And ...
1 vote
1 answer
11 views

Recreate SPL Transfer from a `CompiledInstruction`

i wanted to ask if i can decode an existing SPL token transfer from transaction hash only. const transaction = await client.getTransaction(transactionHash!); Returns a TransactionReponse from @solana/...
0 votes
0 answers
16 views

Buying / Selling tokens through the JSON RPC API

Just started developing in Solana and have been playing around with the solana/web3.js package. My current goal is to buy / sell live tokens. Does anyone know if this is possible to do through the ...
  • 1
0 votes
1 answer
33 views

Transaction working locally and with ngrok (https), but not working when deploying to aws amplify

const lamports = 0.001 * 10 ** 9; const fromPubKey = new PublicKey( 'Wallet sending here' ); const toPubKey = new PublicKey( 'Wallet receiving here' ); const transaction = new ...
3 votes
2 answers
107 views

Get NFTs by collection address and owner

I'm trying to get all the NFTs in a collection that a wallet owns, but I only achieved get all the NFTs of a collection, or all the NFTs of a wallet (multi collections). import { useConnection, ...
0 votes
1 answer
23 views

Parsing data from getTransacion

I using getTransaction for getting information about transaction. In response exists data, for example "instructions": [ { "accounts"...
  • 341
1 vote
1 answer
24 views

With recent updates on web3.js, is Transaction deprecated. Is MessageV0 in VersionedTransactions the new norm for interacting with on-chain programs?

As Solana developer, web3.js and CPIs are bread and butter. A recent update on web3.js caught my attention. "Transaction" is deprecated and "VersionedTransactions" with "...
1 vote
0 answers
18 views

Transaction taking too long (Don't mint)

I'm having a problem in transaction mint time. Sometimes I send a transaction and it never mints. The transactionHash is created and nothing happens. My code is: const lastBlockHash = await connection....
1 vote
0 answers
29 views

How to get AmmId of a pair of tokens with Raydium pool [closed]

I'm trying to make a swap transaction between USDC and another token. The instruction take the AmmId as a parameter. How can I get that value if I only have the addresses of the tokens?
  • 11
2 votes
1 answer
23 views

How do your retrieve nested CPI/Inner Instructions from web3.js?

From solana web3.js, it looks like it only shows 1 level deep of CPI. How would I get inner ix 2 in this example: tx: ix1: inner ix1: inner ix2: ix2: ... type ...
  • 73
0 votes
0 answers
20 views

Solana-test-validator rejecting airdrop

I am running local instance of solana-test-validator and testing it with Solana CLI. Solana CLI was configured to use localhost cluster. I generated wallet, set it as default and am trying to airdrop ...
  • 23
2 votes
1 answer
74 views

How do I add priority fees to a transaction using web3.js?

In @solana/web3.js you'd normally make a Sol transaction with: const transferTransaction = new Transaction().add( SystemProgram.transfer({ fromPubkey: fromKeypair.publicKey, toPubkey: ...
2 votes
0 answers
59 views

Websocket programSubscribe and signatureSubscribe crash intermittent (WebSocket is not open: readyState 0 (CONNECTING))

I'm having intermittent issues with a Node.js app where websockets listening to program or signature changes completely stop working and not recover. I'm using @solana/web3.js onProgramAccountChange/...
  • 702
1 vote
1 answer
51 views

execute swap instruction using VersionedTransaction

i am trying to execute swap instruction using VersionedTransaction and i'm getting this error. const messageV0 = new TransactionMessage({ payerKey: payer.publicKey, recentBlockhash: blockhash, ...
1 vote
1 answer
60 views

Transaction simulation failed: Error processing Instruction 0: insufficient account keys for instruction

I cloned this repo: solana-movie-program and deployed it on Solana Playground. I also cloned solana-movie-client and tried it but I get the error: "Transaction simulation failed: Error processing ...
2 votes
0 answers
120 views

Getting SyntaxError: Unexpected token (45:10) in app/node_modules/@solana/web3.js/lib/index.browser.esm.js [closed]

Good day! When trying to run my frontend code with yarn dev, I recently encountered an error that goes: I suspect this error to be due to some package dependency issues but I am unable to understand ...
  • 107
1 vote
1 answer
23 views

No mobile support with svelte-on-solana/wallet-adapter should I switch?

I'm currently working on a website in Svelte, I just spent 1 day adding mobile support for the website. The only wallet adapter for Solana for Svelte currently is svelte-on-solana/wallet-adapter. ...
  • 31
1 vote
1 answer
49 views

Connect Phantom Wallet on Page Load with solana-wallet-adaper

I am using @solana/wallet-adapter with Next js And on a particular wallet, I need the autoConnect on page load. I would've gone with window.solana.connect() but it doesn't detect when the user ...
2 votes
1 answer
35 views

How to create token for unit test on Solana

I'm trying to create token/nft for testing my transfer method in unit test. Here is my code: const connection = new web3.Connection(web3.clusterApiUrl("devnet")); const myKeypair = ...
  • 161
5 votes
3 answers
106 views

Partial-Sign Transaction from Front-end

Is it anyhow possible to apartial sign a transaction from client side and send it back to server side for final sign and sending to blockchain?
2 votes
1 answer
133 views

How to properly serialize and deserialize versioned transaction

I am trying to add an instruction to a versioned transaction , After adding it i want that to be serialized and passed to the client for signing but while deserializing it thows an error mentioning ...
  • 73
3 votes
1 answer
53 views

How can I get the discriminator of an instruction in an Anchor Solana IDL?

First of all can someone explain to me what a discriminator is, in the context of Solana instructions, in simple terms? Second, how can I get the discriminator of an instruction in an Anchor Solana ...
  • 31
2 votes
1 answer
36 views

In which version of "@solana/spl-token" the "getOrCreateAssociatedTokenAccount" method is available

I want to transfer the spl token but cannot get getOrCreateAssociatedTokenAccount method even in the latest version of @solana/spl-token.
  • 353
3 votes
1 answer
101 views

Getting error of "Provided owner is not allowed"

I have to send multiple transactions simultaneously so, if there is no token account in the sender or receiver wallet then it first creates the token account and then signs other single transaction ...
  • 353
3 votes
1 answer
56 views

Just using the Browser bundle, how can I send a transaction (ReferenceError: Buffer is not defined)?

I've been messing around for a while with the @solana/web3.js browser bundle (https://docs.solana.com/developing/clients/javascript-api#bundle) and I'm having some difficulty sending a transaction. My ...
6 votes
1 answer
194 views

When and why to use Boxed accounts

The documentation regarding Boxed accounts is a bit scarce: "Box type to save stack space. Sometimes accounts are too large for the stack, leading to stack violations. Boxing the account can ...
  • 548
1 vote
0 answers
40 views

connection.confirmTransaction() doesn't wait for confirmation

I am trying to freeze an NFT with the Metaplex SDK. It all goes well and fine and waits for the transaction to be confirmed, then ends the function. I don't know what happened but now it's not waiting ...
  • 515

1
2 3 4 5
8