Questions tagged [typescript]
The typescript tag has no usage guidance.
47
questions
0
votes
1
answer
18
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
67
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: ...
2
votes
2
answers
34
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 ...
1
vote
1
answer
28
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
22
views
Fetch Anchor Discriminator (Typescript)
How to fetch the anchor discriminator in Typescript?
0
votes
0
answers
42
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
22
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
19
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 { ...
2
votes
3
answers
288
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
14
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
42
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
20
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
85
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
30
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
154
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
62
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
66
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
66
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
408
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
0
answers
16
views
Python and Javascript returning different public keys in HD Wallet path derivation
So I have been trying to figure out HD Wallet derivation in Python and I recently found a way using the bip-utils module. Btw I am using a 12 word mnemonic phrase
from mnemonic import Mnemonic
from ...
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
1
vote
0
answers
45
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
0
answers
28
views
How to externally invoke transaction signed by user
I am just trying to sign a transaction on a front-end using a user wallet and then pass the signature to the server, where the transaction is invoked. The transaction pass seemingly, but when I ...
0
votes
0
answers
9
views
How to autogenerate typescript types for the spl-governance package?
Basically, I'm trying to see how feasible is to generate and keep it up to date generated
types from a smart contract. In my case, the SPL governance package.
Even simpler, how can I get this enum ...
0
votes
1
answer
50
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
0
answers
20
views
Locking an NFT for an upcoming NFT merge
I am very new to Solana development and I had a question about locking an NFT for {x} time to merge into a mega NFT.
Two NFTs will be locked. One will be returned and one will be burnt.
I just need ...
0
votes
1
answer
45
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
148
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
43
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
58
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
29
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
178
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
0
answers
26
views
borsh deserializeUnchecked TypeError: reader[capitalizeFirstLetter(...)] is not a function
I have the following schema:
export class StakeData {
timestamp: number
staker: PublicKey
mint: PublicKey
active: Boolean
withdrawn: number
harvested: number
static schema: Schema = new ...
0
votes
1
answer
20
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 ...
2
votes
1
answer
310
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
0
answers
10
views
Cannot assign to read only property '_nextClientSubscriptionId' of object '#<Connection>' at Connection._makeSubscription [duplicate]
When I use Anchor rpc to sell NFT, TS gets an error, but tx sends successfully.
0
votes
1
answer
99
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
236
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
25
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
46
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 = ...
3
votes
2
answers
67
views
How to test a function that is expected to return error?
I got two questions :
First :
I have some custom error type declared in the smart contract and I want to check the appropriate error to be returned from the function call , I wonder how can I get the ...
0
votes
1
answer
65
views
How to identify a swap transaction and get details
I am trying to list the history of a token in my wallet. So, I am dealing with different scenarios right now, and I am stucked with a swap transaction and I am wondering the best way to identify a ...
4
votes
2
answers
114
views
How do I solve this: `Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0`
I have this in my lib.rs file:
#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(
init,
payer = authority,
space = 8 + Config::SIZE,
seeds = ["config"....
0
votes
4
answers
92
views
Checking to see if a token account exists using anchor-ts
I have a workflow such that an ATA needs to be passed into an instruction in a contract but I would like to check to see whether or not i need to initialize it first on the client (there may be ...
4
votes
2
answers
296
views
Support of Anchor IDL for enums
Currently I am writing smart contract code in anchor. When i declare a pub struct in smart contract I can access it in type script easily using IdlType example:
#[derive(AnchorSerialize, ...
0
votes
1
answer
166
views
Failed to serialize or deserialize account data: Unknown
I am trying to write data to an account that is the account of the created bet. My smart contract should send reports from the user's account to the bet account. then write down some data (the amount ...
4
votes
2
answers
171
views
"Signature verification failed" error while creating an account
I am trying to create an account but I get an error while creating it.
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
const newAccountKeypair = anchor.web3.Keypair....