Questions tagged [anchor-client]
The anchor-client tag has no usage guidance.
65
questions
0
votes
1
answer
11
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 ...
1
vote
2
answers
35
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?
0
votes
1
answer
55
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-...
2
votes
1
answer
43
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 ...
0
votes
1
answer
76
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::...
2
votes
1
answer
67
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("...
2
votes
2
answers
103
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 ...
0
votes
1
answer
49
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 = (...
3
votes
1
answer
80
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 ...
1
vote
3
answers
189
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/...
0
votes
0
answers
548
views
Error 0xbc4 / 3012 Failed to send transaction
I am getting this error when trying to connect to a Solana program that i've already deployed. I am using Node and Anchor, and I am using Phantom to sign the transaction. Everything works up until ...
3
votes
1
answer
178
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:
...
3
votes
1
answer
115
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 ...
3
votes
1
answer
326
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 ...
1
vote
0
answers
57
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(&...
1
vote
1
answer
140
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 ...
1
vote
1
answer
1k
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 ...
1
vote
1
answer
62
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, "...
1
vote
0
answers
28
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 ...
2
votes
1
answer
45
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 ...
6
votes
1
answer
68
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.
1
vote
1
answer
42
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 ...
3
votes
1
answer
39
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 ...
1
vote
1
answer
51
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 ...
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.
...
4
votes
1
answer
112
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 ...
0
votes
1
answer
43
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?
1
vote
1
answer
31
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 ...
0
votes
1
answer
61
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, ...
3
votes
1
answer
33
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 ...
1
vote
2
answers
62
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
0
votes
2
answers
470
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 ...
1
vote
1
answer
242
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 ...
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())...
1
vote
1
answer
912
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(...
2
votes
1
answer
386
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, ...
1
vote
2
answers
82
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');
0
votes
1
answer
23
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 ...
0
votes
1
answer
477
views
how to get all accounts owned by a program deserialized?
I am using the JS sdk and I am trying to get all accounts owned by a program already deserialized.
I can do it without Anchor but the result is not deserialized:
const accounts = await connection....
9
votes
2
answers
337
views
Anchor Events -- What, Why, How?
https://book.anchor-lang.com/ has no article on these yet, but I see many programs using them.
What is the problem that they are solving? What are the common code patterns and best practices for ...
0
votes
1
answer
369
views
Initializing a vault: AccountDidNotDeserialize
I'm trying to make a simple vault program. When testing the program, I receive the following error.
Error: AnchorError caused by account: vault. Error Code: AccountDidNotDeserialize. Error Number: ...
3
votes
1
answer
74
views
Using Fs to fetch idl error: "Module not found: Can't resolve 'fs'"
I keep getting this error when trying to import fs to get my idl: Module not found: Can't resolve 'fs'
Code:
const { readFileSync } = require("fs");
export class BigBazaar {
constructor(
...
0
votes
2
answers
105
views
createAccount with pda gives Error: signature verification failed
I am doing something similar to this issue..
here are the two ix:
let tx = new anchor.web3.Transaction();
tx.add(
anchor.web3.SystemProgram.createAccount({
fromPubkey: ...
1
vote
1
answer
35
views
Any method to get NFTs minted by a particular smart contract?
My question is similar to this one Link.
I don't see any satisfactory answer on that question?.
Is there a method to fetch all the nfts minted by a particular smart contract?
5
votes
3
answers
195
views
how to fetch list of all pda accounts in frontend? like sale account instance to display in the market? or should i be fetching from token account?
i have a sale order account defined like this..
#[account]
pub struct Order {
pub creator: Pubkey,
pub mint_key: Pubkey,
pub memo: String,
pub price: u64,
pub bump: u8,
}
And this ...
2
votes
1
answer
50
views
handling error in the client side
How do we handle the custom errors returned from calling a function in the client side?
here is my function:
pub fn create_resume(ctx: Context<CreateResume>, name: String, age: u8, skills: Vec&...
1
vote
2
answers
81
views
'Program log: AnchorError caused by account: refund_receiver. Error Code: ConstraintMut. Error Number: 2000. Error: A mut constraint was violated.'
lib.rs code
pub fn bid(ctx: Context<Bid>, price: u64) -> Result<()> {
let auction = &mut ctx.accounts.auction;
//
// Check bidder's balance against auction's price.
...
0
votes
1
answer
39
views
Anchor Testing Workflow? [closed]
How do you guys go about testing?
Seems like program unit tests should be standard rust tests with cargo test.
There are some program tests that are run with cargo test-bpf.
Then test deployment, ...
5
votes
2
answers
134
views
PDA Anchor Test: Transaction simulation failed: Error processing Instruction 0: Cross-program invocation with unauthorized signer or writable account
I was playing around with PDA's in anchor, but I'm having problems writing tests for it.
When I try to use anchor's worspace to create a transaction I get the error:
Error: failed to send transaction: ...
1
vote
2
answers
53
views
Communication between front end and smart contract [closed]
Apologies if this is an obvious question, I'm very new to this! I have a webapp built in js where a user can input information, and a backend built in Rust. I want to pass that user-input information ...