Questions tagged [typescript]
The typescript tag has no usage guidance.
57
questions
0
votes
0
answers
19
views
I keep getting error in this typescript code
import { clusterApiUrl, Connection, Keypair, PublicKey, } from "@solana/web3.js"; import { createMint, createAccount, mintTo,getAccount,getMint, getOrCreateAssociatedTokenAccount,...
2
votes
1
answer
17
views
Error Minting NFT to Unsized Collection in Solana Metaplex: "Can't Use This Function on Unsized Collection"
I'm working on a project using Solana's Metaplex protocol where I'm trying to mint NFTs to an unsized collection. However, I keep encountering an error that says "Can't use this function on ...
0
votes
3
answers
77
views
Proper way to integrate Solana's Wallet Adapter with Anchor and further questions
After spending some days battling to implement Phantom + Anchor I found out about Solana's Wallet adapter. I sighed in relief thinking the end was nigh but:
The the wallet adapter for Solana Apps is ...
0
votes
1
answer
35
views
createTransferCheckedInstruction - invalid account data for instruction
I'm trying to write instructions for transferring spl-tokens(not nft):
const transfer = createTransferCheckedInstruction(
account_from.publicKey,
mintId,
account_desc.publicKey,
...
1
vote
2
answers
34
views
How to construct a VersionedTransaction from raw bytes?
For context, this question is in the context of a typescript browser client.
How can I construct a VersionedTransaction from an input of raw bytes of a transaction?
With legacy Transaction, I can just ...
0
votes
1
answer
43
views
Getting different Buffers in Solana transactions. The front-end and back-end transactions are different
I have a Solana dApp that requests tokens from a wallet that I own. When the user try to claim the Tokens, one transaction is created on the frontend and signed by the user; the signature is coded and ...
0
votes
1
answer
21
views
About SystemProgram.assign
While I have a main account A and has its keypair.
Then I use createWithSeed create one account derived account x, and asign it to one program C.
Now the problem is : I want to change the account x's ...
0
votes
1
answer
37
views
How to fetch PDA data on a TS client
I am trying to read the data on an pda account like so
let pdaData = awaitprogram.account.PdaAccount.fetch(pdaAccount);
But I am getting this error
TypeError: Cannot read properties of undefined (...
0
votes
1
answer
395
views
TypeError: Cannot convert a Symbol value to a string error
I'm back with new question.
I'm stucked with this error: TypeError: Cannot convert a Symbol value to a string
Weird thing is, My code is exactly same at both linux and window WSL.
but when I copy and ...
0
votes
0
answers
59
views
Mint Error TypeError: Cannot read properties of undefined (reading 'length')
I'm using @metaplex-foundation/umi version 0.8.2. I upgraded from 0.7.14 because the older version doesn't install correctly anymore(get error missing serializers module) with the new version my mint ...
2
votes
1
answer
61
views
Integrate solana wallet adapter react ui in angular project
i am still new to solana developpement and i found solana/wallet adapter react ui and i was wondering if there is a tool or documentation on how to implement it on my angular appilication ?
2
votes
1
answer
49
views
Alchemy endpoint gives wrong wallet balance
I am doing unit tests and I notice that my alchemy endpoint lags behind mainnet-beta in several situations. Sometimes it doesn't get a websocket account update, but the worst obvious case is after ...
0
votes
1
answer
45
views
TokenAccountNotFoundError with getOrCreateAssociatedTokenAccount Typescript
I am trying to simulate minting 100 tokens to a wallet address and when I start the program, I get thrown this error:
TokenAccountNotFoundError
This is the typescript code for creating the token ...
1
vote
1
answer
89
views
Handle optional accounts when calling methods
Let's say updateAccount instruction accepts following accounts
#[account()]
pub payer: Signer<'info>,
#[account(mut), constraint = optional_ata.mint = treasury_ata.mint]
pub optional_ata: ...
1
vote
0
answers
89
views
How to deserialize Metadata account in Typescript without Anchor IDL?
I managed to deserialize everything with this custom getMetadata() function, except for CollectionDetails and ProgrammableConfig. Does anybody know the solutions?
/**
* This blob of a file is pulled ...
3
votes
1
answer
137
views
How to sign a message using Baclpack?
I want to sign an arbitrary data (eg. a string message) with Backpack and receive the signature as a result. How can I do it with backpack?
0
votes
1
answer
58
views
Passing enum as function argument (TWAMM)
In the program, OracleType enum is defined as
#[derive(Copy, Clone, AnchorSerialize, AnchorDeserialize, Debug)]
pub enum OracleType {
None,
Test,
Pyth,
}
When I use
let tx = await program....
1
vote
1
answer
3k
views
How do I fix error Syntax Error: Unexpected token '.' when running anchor test
I get the following error when I run anchor test to test my smart contract using typescript:
Error snippet
abortSignal: options?.abortSignal,
^
SyntaxError: ...
3
votes
2
answers
50
views
solana pda clarification
Youtube solana pda
I've been watching this tutorial for a while trying to build that muscle memory and replicate the code as I understand the concepts, the rust side is not that difficult, maybe when ...
2
votes
1
answer
71
views
TypeScript production code to mint an NFT vs anchor testing code
How would I go about converting the following testing code (from an anchor project) to something that would interact with my frontend in production (or convert it into a function to be used in react ...
2
votes
1
answer
70
views
Fetch Anchor Discriminator (Typescript)
How to fetch the anchor discriminator in Typescript?
1
vote
1
answer
176
views
Error TS1259 with Metaplex JS SDK
I am receiving all these errors when working with TypeScript and Metaplex SDK? Anyone know why?
2 import BN from 'bn.js';
~~
node_modules/@types/bn.js/index.d.ts:598:1
598 export = ...
1
vote
1
answer
71
views
How to export an Anchor defined enum to Typescript?
I have an enum used in one of my account that looks like this:
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub enum ItemType {
Empty,
Folder { folder_mint: Pubkey },
Reference { ...
0
votes
0
answers
45
views
shadow drive.createStorageAccount returns "Server response status message: Timed out awaiting confirmation on transaction"
I need to upload photos to shadow drive. this is the complete code. all you need is to create a .ts file and run ts-node filename
import { ShdwDrive } from "@shadow-drive/sdk";
import { ...
3
votes
4
answers
837
views
How do I mint an SPL token with custom Metadata without using the Metaplex JS SDK?
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
16
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 ...
3
votes
1
answer
67
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 ...
0
votes
0
answers
27
views
Get typed accounts from account.whatever.fetchMultiple
When fetching a single account with an anchor fetch, you get a typed value back. E.g.:
let acc = await program.account.whatever.fetch(someKey);
will return your IDL type for acc. Here you would get a ...
2
votes
1
answer
170
views
How to import METADATA_PROGRAM_ID. (Buildspace Solana Staking Anchor course)
I'm doing the Anchor Staking part of the solana Buildspace course. I get this error when running the first test:
ReferenceError: METADATA_PROGRAM_ID is not defined
This is the Anchor Smartcontract I ...
2
votes
0
answers
53
views
How does the yaaaw escrow program work for multiple NFTs?
yaaaw is a solana dapp built on the basic escrow program to safely exchange tokens , they upgraded it to work with NFTs and solana and other tokens , you can deposit multiple NFTs in the same ...
3
votes
2
answers
281
views
Confirm a transaction reliably
I need to reliably validate in an API whether a call to the Solana program made by a user has been successful. I use the confirmTransaction function (in devnet) as follows:
import { web3 } from "@...
1
vote
1
answer
92
views
Can not get mint address from NFT metadata response
Using TS and there is the code:
let nftMetadata: any[] = [];
let allMetadata: any[] = [];
const owner = new PublicKey(publicKey);
const allNfts = await metaplex.nfts().findAllByOwner({
owner: ...
1
vote
2
answers
99
views
0x0 error when trying to send NFT into PDA vault
I keep getting this 0x0 error when trying to send an nft from my wallet into a vault from a program. I'm trying to create an NFT auction (bids in sol) with escrow. This is an attempt to initialize ...
2
votes
1
answer
114
views
solana token program 0xc Invalid Instruction
I have recently begun getting the below error when running the createMint instruction from @solana/spl-token. To my knowledge, I have not changed any code or dependencies that would affect this.
...
2
votes
1
answer
3k
views
How to solve Typescript errors TS2307 Cannot find module
I keep getting TS2307 Cannot find module error whenever I run typescript checks on my project. The src/index.ts file has the following imports:
import BigNumber from 'bignumber.js';
import {WebBundlr} ...
0
votes
1
answer
15
views
My variable u64 is not saved and appears as undefined [closed]
When I use the fetch method my variable u64 appears as undefined
2
votes
0
answers
119
views
WalletMultiButton in react/typescript application does not seem to be functioning as a button
I have followed along with a few tutorials at this point, but I pulled code directly from the following website:
https://www.0xdev.co/how-to-connect-to-a-solana-wallet-to-your-react-app/
After ...
0
votes
1
answer
82
views
variable of public key isn't updated in useEffect hook
i have cloned the solana dapp-scaffold repo and i am trying to display the pubkey of the user connected with an alternative way, using web3js. When i try to do it the pubkey is initially set to null ...
0
votes
1
answer
63
views
Avoid 'parsed' type error from getParsedTransaction
As you can see in screenshots, I have a type error. How can I avoid this problem ?
The type of my transaction is 'ParsedTransactionWithMeta' from getParsedTransaction method.
Same problem with '...
0
votes
2
answers
649
views
How to convert string to as_bytes in typescript?
So, I have a PDA seed where I'm hashing a string (which is converted to bytes) and converting the hash result to_string and then as_bytes.
code:
anchor_lang::solana_program::hash::hash(name.as_bytes())...
0
votes
0
answers
46
views
Metaplex JS implementation in React Native: TypeError: Conversion from 'BigInt' to 'number' is not allowed [duplicate]
Trying out this package in React Native
RN Version: 0.69.5
Metaplex js version: 0.15.0
@solana/web3.js: 1.41.6
Error log:
TypeError: Conversion from 'BigInt' to 'number' is not allowed.
App@http://...
1
vote
2
answers
65
views
CandyMachine Metaplex in Javascript?
I'm creating an application to expose an NFT collection.
I already started to make my application using a normal React APP. I made the entire site using .js and .jsx, but now the most important part ...
1
vote
0
answers
45
views
Event Index In Solana
What are the index and non-index properties in the Event (in Solana) and how many indexes are allowed (I know that in EVM Solidity there are three index properties allowed in the Event)
1
vote
1
answer
315
views
Importing '@metaplex-foundation/js' results in 'process is not defined' error
It looks like someone previously asked the question and deleted it - sadly I can see the question in search engines but can't see the answer!
When I import Metaplex:
import { Metaplex } from "@...
0
votes
1
answer
23
views
TS warning when dependency using different Anchor version
What is the canonical way to deal with a dependency using an older Anchor version? Basic example:
import { SomeDependency } from "deps/blahblah/packages/some-dependency/src";
export const ...
3
votes
1
answer
489
views
Solana Wallet adapter with different react UI
I am a newbie to React/Typescript and I am trying to build a DeFi project using the Solana Wallet adapter. From what I can see the wallet adapter comes with a React UI look and feel based on the ...
0
votes
1
answer
186
views
Anchor event type on typescript
How do I declare a variable to be of a certain Anchor event type? In general, I am not sure how to extract a subtype within the program idl
1
vote
1
answer
403
views
Error: Signature verification failed
I am writing a Solana Program using Anchor framework.
I can't seem to get rid of a signing error I'm having while testing.
Instruction Accounts validation:
#[derive(Accounts)]
pub struct ...
1
vote
0
answers
234
views
How do I prevent 'open handles' issues when using the Solana 'Connection' object?
I am using Solana and Solana SPL in TypeScript with Jest, running integration tests with solana-test-validator running.
Whenever I do await connection.getTokenAccountsByOwner() or await connection....
1
vote
1
answer
80
views
How to generate new wallets in anchor typescript tests
I'm writing some unit tests and want to test that a user cannot update data on a PDA created by another user. How can I get "another user?" I'm creating the first user:
const provider = ...