Skip to main content

Questions tagged [anchor-client]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
0 answers
33 views

How to send a solana/web3.js transaction to a anchor program?

I want to send a transaction to a anchor program, I have found the function discriminator const dis = [125,112,23,1,23,45,24,12] I have checked ,that this is the right function, Now i want pass a vec&...
Abhishek Faliya's user avatar
1 vote
1 answer
45 views

Problems deploying and testing with Anchor on Devnet

I am getting this error when trying to test and deploy my program using Anchor. Error: Deploying program failed: RPC response error -32002: Transaction simulation failed: Error processing Instruction ...
gconnect's user avatar
0 votes
0 answers
44 views

How do I resolve the anchor build error: Failed to obtain package metadata

I created a project with the command: anchor init solanasc and I receive this error when I run anchor build ERROR cargo_build_sbf] Failed to obtain package metadata: `cargo metadata` exited with an ...
DreadedHippy's user avatar
1 vote
1 answer
43 views

thread 'main' panicked at 'Not in workspace, cli/src/lib.rs note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The version of anchor i'm using is 0.29.0 I tried to set RUST_BACKTRACE=1 in the terminal by export RUST_BACKTRACE=1. I got the following error
Jaydeep Dey's user avatar
4 votes
1 answer
81 views

how can I get the return value of an instruction upon sent the Tx from JS client?

Having a instruction that return a number: pub fn get_value(ctx: Context<DataGet>) -> Result<u64> { let ret = 0; // ... Ok(ret) } then, how can I get ...
breeze wang's user avatar
0 votes
2 answers
51 views

How do I get a connection from Anchor?

I'm used to the Solana web3.js library, but have recently started using Anchor. I can see Anchor's TS client connects to my local cluster when I run my transaction, but how do I get the normal web3.js ...
mikemaccana's user avatar
  • 1,845
1 vote
1 answer
42 views

NFTs on anchor tests

I'm trying to use this guide to create an NFT to test with my anchor program. When I attempt to mint the NFT, I am met with the following error. FailedToSendTransactionError: The transaction could not ...
Morgandril's user avatar
2 votes
1 answer
43 views

Signer issues with anchor tests

i'm getting a weird signer error when running my tests; Error: Signature verification failed. Missing signature for public key [`6jAudYFBbfQS59oPNjYcMkqr9MqBf312T7oP6WSYRjsg`]. In this case, ...
Morgandril's user avatar
0 votes
1 answer
119 views

Localnet transaction stuck finalizing

I attempted to run my test using anchor on Localnet but got my test stuck like this ⠤ [0/1] Finalizing transaction ...
Kombi's user avatar
  • 1
2 votes
1 answer
46 views

How can I fix Error Code: InstructionFallbackNotFound?

Today I had this error that took me a while to determine what was happening. 1) Create suscription Is initialized!: Error: AnchorError occurred. Error Code: InstructionFallbackNotFound. ...
Mateo Lafalce's user avatar
1 vote
1 answer
70 views

How to convert Vec<u8> to typescript bytes?

In my rust solana smart contact, build with anchor framework, there is one of my variable that is of type in below format struct X { a: Vec<u8> } while building the contract with anchor ...
blackhorse's user avatar
1 vote
2 answers
119 views

You cannot/should not initialize the payer account as a program account

I'm creating a basic staking contract and just trying to initialize the pool where the reward tokens will be held. I'm receiving the following error: TryingToInitPayerAsProgramAccount. Error Number: ...
blockchief's user avatar
0 votes
1 answer
130 views

Unable to use remaining accounts in anchor program sent from anchor-js?

if i use remaining accounts that are sent from anchor js client in rust anchor program I am getting this error lifetime may not live long enough requirement occurs because of the type anchor_lang::...
Aravind Makam's user avatar
0 votes
1 answer
122 views

How can i get the events emitted from a transaction ID in rust client?

I am trying to fetch the events emitted in a transaction so that i can parse the data and use it on the client. But wondering on how i can fetch it on the anchor client in rust since i couldnt find ...
Dhruv D Jain's user avatar
1 vote
2 answers
121 views

Is there a go package to create clients for anchor programs?

Like typescript package do we have go package that generates clients for solana anchor programs?
Aravind Makam's user avatar
0 votes
1 answer
96 views

Transaction failing while calling a Solana program with PDA

I'm calling a function of anchor_movie_review_program program on devnet CLA5Pk8tpcsA3RPmCYPaRNBdU6xBknRnqshsT1bKT7if. I cloned the following GitHub https://github.com/Unboxed-Software/anchor-movie-...
kc.sol's user avatar
  • 3
2 votes
2 answers
131 views

How to view logs on anchor rust client

I am trying to send a transaction to my program through rust client. But i am running into an issue and i would like to see the logs so that i can trace it. I am using the anchor rust client and ...
Dhruv D Jain's user avatar
0 votes
1 answer
165 views

Getting error when I'm going to mint NFT on testnet using Metaplex

Here is my mint contract use anchor_lang::prelude::*; use anchor_lang::solana_program::program::invoke; use anchor_spl::token::mint_to; use anchor_spl::token::{MintTo, Token}; use mpl_token_metadata::...
Isha Padalia's user avatar
2 votes
1 answer
225 views

How to deserialized Anchor accounts in Rust

In JS/TS I can decode an account from bytes using the coder: const program = new Program(IDL, new PublicKey(""), anchorProvider) const decoded = program.coder.accounts.decode("...
lameren's user avatar
  • 153
2 votes
2 answers
185 views

ERR_INVALID_URL for project-serum/anchor node package

When trying to deploy website I get get the error invalid url error from @project-serum/anchor. Is there an alternative anchor package I could use? TypeError [ERR_INVALID_URL]: Invalid URL at new ...
Miles Donald's user avatar
0 votes
1 answer
88 views

program return data to client error

I'm returning a Result<u64> from my program and want to get that value in the typescript client. I'm using anchor, and attempting to use the functions below: const getReturnLog = (...
joebuild's user avatar
  • 455
3 votes
1 answer
241 views

How to use Anchor's `.view()` in frontend without prompting wallet to sign?

Solang currently uses Anchor's .view() to fetch account state from the client. The issue is that when using .view() in a frontend, it also prompts the wallet to sign a transaction. Is there a way to ...
john's user avatar
  • 7,185
1 vote
3 answers
568 views

Getting insufficient balance error while trying 'anchor deploy' , but I have enough fund in my wallet. How to solve this?

Deploying workspace: http://localhost:8899 Upgrade authority: /home/dev_roy/.config/solana/id.json Deploying program "basic-1"... Program path: /home/dev_roy/User/solana-wallet-setup/anchor/...
soumyadeep.eth's user avatar
3 votes
1 answer
282 views

Fetch all() isn't working in Anchor Client

I am trying to fetch all accounts owned by my program using all() method but it is giving me this nasty error: Uncaught (in promise) ReferenceError: Buffer is not defined at AccountClient.all Code: ...
CryptoSar's user avatar
  • 399
3 votes
1 answer
269 views

What is first 8 bytes of anchor generated instruction data? [duplicate]

I am passing two u32 argument to the instruction. They are appearing at the end but not sure about the first 8 bytes of the instruction data.Another question maybe similar to this how anchor ...
Imran Sheikh's user avatar
3 votes
1 answer
1k views

Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete

I get this error when I am calling an instruction of a program from a client. I am using Seahorse library to write smart contract. The library transpiles python code to anchor rust program. Here's the ...
denimcodes's user avatar
1 vote
0 answers
73 views

When using Event listener the rpc call to program function does nothing and eventualy time limit will exceed and test fails

This block of code is giving the trouble.. let listener = null; //@ts-ignore let [event, slot] = await new Promise((resolve, _reject) => { listener = program.addEventListener(&...
Lobo1897's user avatar
  • 153
1 vote
1 answer
176 views

How to verify data on chain with Solana

I am currently facing a big problem with Solana. I will start with a very simple example for the explanation: In fact I want to create a smart contract, in this smart contract there will be the name ...
RevOneX9's user avatar
1 vote
1 answer
2k views

Stuck at Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0

I want to call a method of solana smartcontract. I have an IDL. While I'm calling it I'm getting the following error (when I'm calling await this.program.methods.initialize() method): Error: failed ...
Bakhrom Achilov's user avatar
1 vote
1 answer
83 views

How to read an account state without needing Phantom wallet provider?

I create an instance of a Program in the following way and try to read accounts from the program instance. const network = clusterApiUrl('devnet'); const connection = new Connection(network, "...
Sasha Shpota's user avatar
1 vote
0 answers
44 views

Calling anchor function in the background

How do I call a anchor function without having the end user approve/sign in their wallet? During development in my anchor project, I was able to create tests where I can call anchor functions without ...
ZeroNine's user avatar
  • 473
2 votes
1 answer
55 views

What is a smart contract and what do they do?

I’ve been interested in smart contract’s lately and I was wondering what separates them from just normal scripts that track transactions or something. Can they control NFTs and wallets? Like what ...
Pixeled's user avatar
  • 476
6 votes
1 answer
114 views

Add max Whitelist mint check per user

I need to put a check on Max whitelisted NFTs. Like each user can mint 10 NFTs. Any rust code snippet or reference would be helpful.
Abdullah Qureshi's user avatar
1 vote
1 answer
95 views

Serum dex swap error: Error settling funds

i'm trying to make a serum dex token swap in my program. But the problem is, it only works halfway here's what I mean: when I do orderbook.sell(sell_proceeds, None)?; the swap works and the token I'm ...
iMEF's user avatar
  • 326
3 votes
1 answer
57 views

Uncaught TypeError in React Client

I want to create an account that will hold data for my program on the client side. I've imported the dependencies I need for that: import web3 from '@project-serum/anchor'; and I go ahead to create ...
Kirima's user avatar
  • 155
1 vote
1 answer
104 views

Trouble initializing solana contract on front-end client

I have a very simple program which stores GIFs in a solana contract. Before I can get the gifs, however, I believe I need to call the "initialize" function in my front-end. I have created ...
user2487's user avatar
2 votes
1 answer
326 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. ...
austinmilt's user avatar
5 votes
1 answer
183 views

how to deploy a program using clients like @solana/web3.js, @project-serum/anchor

I dont want to deploy a program using cli or solana playground ide I want to deploy a program using clients packages of solana/web3.js, @project-serum/anchor, or any other packages can anyone please ...
Mojo's user avatar
  • 149
0 votes
1 answer
108 views

Is there a way to calculate number of spl-tokens per solana block?

I am new to solana. Can someone suggests ways to: calculate number of spl-tokens per solana block? Is there any rpc methods to do so? How to get solana block height in solana?
blackhorse's user avatar
1 vote
1 answer
36 views

Solana Application Account Initalization

how would you go about creating a permanent account on Solana blockchain that represents a pool that holds all the funds. I created an application in which people can fund the pool and get back ...
r_hribar's user avatar
0 votes
1 answer
85 views

How to implement Rust Struct in TS tests?

Hi guys I have a struct in my Rust code that is used in a struct that is a account, my code : #[account] pub struct TournamentTwoPlayers { pub games: [Game; 1], } #[derive(AnchorSerialize, ...
Reza Aslejeddian's user avatar
4 votes
1 answer
41 views

Solana keeps showing "baseAccount not provided error" Whats missing?

I'm trying to call my solana contract from my frontend app. Even though I added the baseAccount. Solana complains it's not added. Whats going on? const baseAccount = Keypair.generate() async ...
notElonMusk's user avatar
1 vote
2 answers
92 views

How can i return any Data from solana smart contract to client side?

I want data from return smart contract so that i can use it in client side
vipin saini's user avatar
0 votes
2 answers
635 views

Anchor init macro initialise PDA and token account

I am trying to anchor init an PDA with a vault account, however accounts are not getting created. Rust Code: pub struct Initialize<'info> { /// CHECK: This is not dangerous because we don't ...
Piyush Chittara's user avatar
1 vote
1 answer
339 views

How to decode anchor zero copy account with idl?

The zero copy version of the following struct adds 4 bytes of padding between arg_1 and arg_2. This makes the idl not able to decode the struct correctly as arg_2 is being decoded based on the 4 bytes ...
escargo's user avatar
  • 15
0 votes
2 answers
1k 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())...
Gajesh S Naik's user avatar
1 vote
1 answer
2k views

signTransaction() wallet adapter

const {signTransaction} = useWallet() const transaction = new Transaction() const tx = .... //arbitrary anchor program method as transaction transaction.add(tx) const signature = signTransaction(...
user2892730's user avatar
2 votes
1 answer
648 views

How to use Enum types as function argument in anchor test

I was trying pass Enum type as argument in test function, but I am getting undefined error. Here's the program enum and function: #[derive(AnchorSerialize, AnchorDeserialize, Copy, Clone, PartialEq, ...
Void's user avatar
  • 396
1 vote
2 answers
120 views

What's the best way to use a u16 as a seed for a PDA?

Does something like this work? Rust: &x.to_be_bytes() JavaScript: new anchor.BN(x, 'be');
user1947's user avatar
0 votes
1 answer
32 views

Why am I recieving an garbage value

// This is your program's public key and it will update // automatically when you build the project. declare_id!("CEUKfCKpDNgk6sqNwnQWZ1Xdjb6ujYyrJkrh3HpNn489"); #[program] mod hello_anchor ...
Killerthief's user avatar