Skip to main content
4 votes
Accepted

Can I make an onchain program using JavaScript/TypeScript?

Not yet. There is no way you can use javascript at the moment that I'm aware of and I would recommend Rust/Anchor. However if you prefer a different language you can: Wait for something called ...
McBain's user avatar
  • 5,384
4 votes

React Native build error when installing @solana/wallet-adapter "Module parse failed"

Your build problems stem from the fact that the version of React Native you're using runs code in a JavaScript environment that doesn't support BigInt, and BigInt is required by versions of @solana/...
steveluscher's user avatar
  • 3,153
4 votes

React Native build error when installing @solana/wallet-adapter "Module parse failed"

Two problems here: Your compiler looks like it's using a transform that turns 2n ** 64n into Math.pow(2n, 64n). This is actually illegal because Math.pow() does not support BigInt – only number. An ...
steveluscher's user avatar
  • 3,153
3 votes
Accepted

web3js@2 How can i call getFeeForMessage?

The getFeeForMessage() method requires the transaction message as a base64 string representation of the message bytes themselves. You can use the following transforms to produce that. const ...
steveluscher's user avatar
  • 3,153
3 votes

How to submit a transaction on ui side?

You can see you got the custom error 0xbbf, or in decimal, 3007. Since this was not defined by you, it must have come from Anchor itself. You can find a reference of the meaning behind all Anchor ...
McBain's user avatar
  • 5,384
2 votes
Accepted

How to add confirmationStrategy in JS

You're forgetting the await keywords as they're used in the example you're borrowing from. Failing to include them will make Javascript return a promise rather than waiting to receive the actual value ...
Ademola's user avatar
  • 3,944
2 votes

Is there a better way to use onLogs and getTransaction to be able to receive data real-time?

You've done the best thing. The only other option is to subscribe to all block updates and pick out the transactions that interest you, but I think your solution is better.
Jon C's user avatar
  • 19.6k
2 votes
Accepted

How to submit a transaction on ui side?

I found the answer: CPI with unauth’d signer error typically happens because of three reasons: One of the accounts you’re mutating does not have the mut attribute you’re passing in an address derived ...
Taylor Lee's user avatar
2 votes

How to submit a transaction on ui side?

In your transaction, you're using the publickey of the connected wallet as the helloQueue account. const { publicKey, sendTransaction } = useWallet(); <--- using the publicKey of the connected ...
john's user avatar
  • 7,794
2 votes

RangeError: encoding overruns Uint8Array

Perhaps you are exceeding the transaction size limit which is 1232 bytes for the data
Jimii's user avatar
  • 7,682
2 votes

Can I make an onchain program using JavaScript/TypeScript?

Yes. Poseidon allows you to create Solana Smart Contracts in TypeScript. In September 2024 Poseidon was announced. Poseidon allows you to create Solana smart contracts / programs using TypeScript. As ...
mikemaccana's user avatar
  • 2,754
2 votes

RPC CALL WITHOUT HAVING LAMPORTS

Most RPC calls are read hence you don't even sign them, so the RPC doesn't even know if you have lamports or not. I think it's only relevant for: https://solana-labs.github.io/solana-web3.js/classes/...
Ohad Dahan's user avatar
2 votes
Accepted

Fetch list of addresses of token holders

const { Connection, PublicKey } = require('@solana/web3.js'); const { TOKEN_PROGRAM_ID } = require('@solana/spl-token'); const connection = new Connection('https://api.mainnet-beta.solana.com'); ...
Dominic's user avatar
  • 135
1 vote

How to give up metadata update permission for spl token via solana api?

The mint you provided 9KXyn1GGcefXHX5yLg1GVH4NdWAeLSXJW4oEjrmdYpY8 indicates that the Token Program owns the token, and you aren't using the Metadata pointer. You are setting the Metadata using the ...
Jimii's user avatar
  • 7,682
1 vote

TypeError: Cannot read properties of undefined (reading 'toBase58')

The Connection object doesn't have a publicKey field, which is why you're getting an undefined address. You can see all its fields/methods here: https://solana-labs.github.io/solana-web3.js/classes/...
Callum M's user avatar
  • 3,775
1 vote

Is it possible to burn tokens on transfer?

Yes, you can create a token with a burning mechanism in JavaScript: Develop a token contract with a burn function that deducts a percentage of tokens from the sender's balance and reduces the total ...
SolNoob's user avatar
  • 51
1 vote

Is it possible to burn tokens on transfer?

Either build you own token extension, of just use transfer tax, and manually collect the transfer tax from user accounts at some interval of time and perform burn operation.
ashish0411's user avatar
1 vote

How do I get lamports sent from a parsed transaction

I think you can use getParsedTransaction function to get preBalance and postBalance of accounts in a transaction. From that you can calculate lamports sent. const connection = new Connection(...
Lê Văn Anh Tú's user avatar
1 vote

Sender can send but the receiver not receing amount, and also I can't make it work for USDC

After your last explanation, this is how you should do it : var transaction = new web3.Transaction().add( web3.SystemProgram.transfer({ fromPubkey: from.publicKey, // <= get the ...
Effe2's user avatar
  • 1,607
1 vote

Sender can send but the receiver not receing amount, and also I can't make it work for USDC

first of all, never show your private key to anyone, i'm able to import your wallet in my phantom with what you showed. I could drain everything in it. So, create a new wallet and never use this one ...
Effe2's user avatar
  • 1,607
1 vote

Clear JS - Metaplex is not a constructor

You'll have to compile your code to an ES module or CJS for compatibility. I found out recently that I have to do this to make Metaplex work in the browser. Check out tsup for a tool that helps with ...
Ademola's user avatar
  • 3,944
1 vote
Accepted

@metaplex-foundation/js .findByMint() getting TypeError: Cannot read properties of undefined (reading 'toBuffer')

https://github.com/metaplex-foundation/js/blob/7feaad60f3f0dd9a3afc39f02dba1eba5f4fe5e4/packages/js/src/plugins/nftModule/NftClient.ts#L123-L126 https://github.com/metaplex-foundation/js/blob/...
James's user avatar
  • 309
1 vote

RPC CALL WITHOUT HAVING LAMPORTS

Client-side is inherently unsafe. For this reason the check will always happen on the validator side. On the client side it can only happen as convenience to avoid sending a transaction to the ...
Dmitry R's user avatar
1 vote

Get staking rewards for a specific account

Yes, this iterating is the Right Way :tm: to get rewards for multiple epochs. Inflation rewards are stored in the first block produced in each epoch. It will be much lighter to make the ...
trent.sol's user avatar
  • 4,585

Only top scored, non community-wiki answers of a minimum length are eligible