Skip to main content

Questions tagged [anchor]

Should be used for all things relating to the Anchor Framework.

Filter by
Sorted by
Tagged with
0 votes
1 answer
7 views

How to use lifetime on Context correctly?

I want to iterate over the accounts passed in ctx.remaining_accounts as in: pub fn do_something(ctx: Context<DoSomething>) -> Result<()> { for acc in ctx.remaining_accounts.iter() { ...
Matheus Baptistella's user avatar
0 votes
0 answers
6 views

Can't run local validator on MAC

Hello I'm getting the following error: Error: failed to start validator: Failed to create ledger at test-ledger: io error: Error checking to unpack genesis archive: Archive error: extra entry found: &...
Soldevrookie's user avatar
1 vote
0 answers
6 views

Pubkey to std::vec::Vec<u8> error when running anchor build v0.30.0

Error here when running anchor build on version 0.30.0. It turns out I was simply using <generic_program>::ID.key() and i just needed to remove .key(), so <generic_program>::ID
Burger Bob's user avatar
  • 1,406
1 vote
0 answers
11 views

Error: missing field `discriminator` at line 28 column 5

Hello im trying to build simple smart contract using anchor and solang but when im trying "anchor build" command im getting this error: info: Solang version v0.3.3 help: found contract '...
dustinioxyz's user avatar
1 vote
0 answers
7 views

Compressed NFT with attributes

Is there a way to add attributes in metadata to compressed NFT?
Nutinaguti's user avatar
0 votes
1 answer
18 views

How to validate the accounts passed on remaining_accounts in Anchor?

I'm wondering what would be the correct way to deal with multiple accounts in Anchor. For example, lets say that we have a program with User PDA accounts and multiple Data PDA associated to each user. ...
Matheus Baptistella's user avatar
0 votes
1 answer
17 views

anchor build fails with 'no such command: `build-sbf`', but I can see build-sbf is installed

I've installed Rust, Solana 1.18 (currently in beta) and Anchor 0.30. On a new project: anchor init project cd project anchor build fails with: error: no such command: `build-sbf` View all ...
mikemaccana's user avatar
  • 1,845
0 votes
1 answer
9 views

I got an issue when interact with anchor project using coral-xyz/anchor

I try to run this function in client, but I got an issue with it. try { const provider = getProvider(); const program = new Program(idl, provider); const accounts = { ...
RichardPhan's user avatar
1 vote
0 answers
6 views

Try to create mint and ATAaccount shows Error:Transaction simulation failed:Error processing Instruction 0:Program failed to complete

Try to create mint and ATA account, When I run anchor test, it shows Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete here ...
papi's user avatar
  • 51
1 vote
2 answers
74 views

How to use timestamp as seed for my PDA?

I'm wondering what are the best practices when using timestamps as a seed to calculate a PDA (or if using a timestamp is recommended at all). I should generate the timestamp from within my program: ...
Matheus Baptistella's user avatar
0 votes
1 answer
22 views

Default program won't build on Anchor 0.30, ahash 0.84 no longer builds

I am attempting to build a default program on Anchor 0.30. anchor init test-project cd test-project anchor build Similar to this question, this error still occurs in Anchor 0.30: error[E0658]: use of ...
mikemaccana's user avatar
  • 1,845
1 vote
1 answer
32 views

Error: target/idl/sol_404.json doesn't exist. Did you run `anchor build`?

I run anchor build , and it indeeded generate a sol404.json , but when I run the anchor test it shows /Users/brooke/Desktop/sol404/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*....
papi's user avatar
  • 51
1 vote
0 answers
9 views

Error: AnchorError caused by account: token_metadata_program. Error Code: InvalidProgramExecutable. Error Number: 3009

I run anchor test and then it shows Error: AnchorError caused by account: token_metadata_program. Error Code: InvalidProgramExecutable. Error Number: 3009. Error Message: Program account is not ...
papi's user avatar
  • 51
0 votes
1 answer
19 views

What is the 'info type in Anchor?

In this code snippet: #[derive(Accounts)] pub struct AddToWhitelist<'info> { //etc... Regarding 'info I understand that the ' is a Rust lifetime elision (I think...), but what is the info type. ...
Gunnar Karlsson's user avatar
2 votes
1 answer
89 views

error[E0599]: no associated item named `__anchor_private_full_path` found for struct `anchor_spl::token::TokenAccount` in the current scope

I run my code, and it shows, looks like I need to intro pub token_program: Program<'info, Token>, but I did, you can get more information from my code below error[E0599]: no associated item ...
papi's user avatar
  • 51
1 vote
0 answers
14 views

Invalid arguments error when calling program method via anchor

I am trying to call a program method using anchor. I have the idl.json, I initialize the program and then i call the method. I do it through this: const program = new Program(idl as Idl, programId, ...
Captain Jack sparrow's user avatar
1 vote
1 answer
11 views

Anchor build fail due to no platform tools rust lib

I am using Mac, and installed rust, solana cli, anchor which works before. Recently after I did some version upgrade. I have installed all three stuffs: > rustc --version rustc 1.77.2 (25ef9e3d8 ...
Eric's user avatar
  • 11
2 votes
1 answer
28 views

How to use realloc to increase account space in Anchor?

Lets say that I have the following account struct for my instruction: #[derive(Accounts)] pub struct IncreaseDataSize<'info> { #[account( mut, seeds = [signer.key().as_ref()],...
Matheus Baptistella's user avatar
0 votes
0 answers
16 views

blacklist token

I would like to know how I can create a black list on Solana, with solidity I do: function updateBlacklist(address _address, bool _isBlacklisted) public { isBlacklisted[_address] = _isBlacklisted; ...
Murilo de Souza Lopes's user avatar
0 votes
0 answers
24 views

WalletSendTransactionError: Non-base58 character

I am facing issue with the minting of the NFT. This is the code inside my react component. const { connection } = useConnection(); const { publicKey, sendTransaction } = useWalletSol(); const ...
niishaaant's user avatar
0 votes
0 answers
24 views

Phantom Wallet: Issue with transaction, failed to send transaction: Transaction precompile verification failure InvalidAccountIndex

We're utilizing React version 16 and Node.js version 16. While creating an anchor provider to retrieve the program, we're encountering an error: "Failed to send transaction: Transaction ...
Sajjad Akhtar's user avatar
0 votes
1 answer
19 views

How does max_len attribute work?

I have this field on the data account of my pda: #[max_len(0)] pub users: Vec<Pubkey>, But I'm still able to push a value to it, even though it should have 0 space allocated. Why is that so?...
Matheus Baptistella's user avatar
1 vote
1 answer
15 views

anchor deploy: Account 123 has insufficient funds for spend

I am new to anchor/solana/rust and I have built and deployed an anchor program on I believe devnet, because solana config get is showing: RPC URL: https://api.devnet.solana.com. I've made some edits ...
user12678's user avatar
2 votes
1 answer
75 views

Anchor IDL different (incorrect?) from Solana Playground IDL generated

I was following this guide to learn anchor: https://www.quicknode.com/guides/solana-development/anchor/transfer-tokens When deploying the program via Solana Playground (as instructed), everything runs ...
Crypto Actuary's user avatar
0 votes
1 answer
22 views

What is the typescript equivalent of Option<T> in anchor?

The title says it all: If my anchor instruction expects an Option<T> to be passed what do I need to send in typescript for None and Some<T> respectively? I checked the docs but couldn't ...
Ahri's user avatar
  • 3,325
0 votes
1 answer
14 views

Anchor PDA Cross-program invocation with unauthorized signer or writable account token 2022

i'm testing the Token Extension MetaData Pointer NFT using this example: https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/nft-meta-data-pointer/anchor, but, instead of ...
0xNicko's user avatar
  • 31
1 vote
1 answer
12 views

`Event doesnt exist` error when integrating anchor wallet on expo app

When attempting to sign a transaction as anchor.Wallet in a react native expo app for a solana program, the error Property Event doesnt exist is given
brimigs's user avatar
  • 76
0 votes
1 answer
35 views

How can I initialize a second wallet on Anchor tests?

I would like to test that a public key that doesn't own a PDA can't alter its data. I'm doing as follows: Generate a new keypair for user2 (user1 is the pubkey of the local wallet on Anchor's ...
Matheus Baptistella's user avatar
1 vote
1 answer
18 views

Can I initialize a PDA (again) after I deleted it (Anchor)?

I calculated the PDA of an account using the public key of my local wallet, then I initialized it on-chain (using the canonical bump). One of my tests tries deleting the account, which works, but then ...
Matheus Baptistella's user avatar
0 votes
3 answers
20 views

How to solve Unkown Signer error?

I have this simple solana/anchor app written in Rust use anchor_lang::prelude::*; declare_id!("4ahwNyytPQ9cUguDLz9fcjbzEBMM4jsaVfYxTUV4Sf7r"); #[program] mod myanchorapp { use super::*;...
EdelweissPirate's user avatar
1 vote
0 answers
18 views

Core Assets Validations

How to validate that the core asset is from a given collection? Before we would derive the metadata account from the nft to validate the right collection. e.g #[account( seeds = [ b"...
beliveN DAOist.dev's user avatar
0 votes
1 answer
16 views

Is it possible to figure out which instruction is causing the stack access violation

Getting this error which means I'm probably putting too much on the stack. is it possible to find out the exact instruction that is causing this? Or does this error mean that everything on my program ...
Jimii's user avatar
  • 1,478
0 votes
1 answer
23 views

Who gets to create token associated accounts on Solana?

I understand the differences between token mint accounts and token associated accounts. As I'm building a web-app allowing people to mint spl tokens on our website, we are facing a question about who ...
Maxareo's user avatar
  • 101
2 votes
2 answers
37 views

How to determine how much will be paid back/paid extra when reallocing

Say we have the following definition for an instruction and we know that my_acc previously took up 200 bytes and is now being realloced to 100. How can we find out how many lamports will be paid to ...
Ahri's user avatar
  • 3,325
2 votes
1 answer
45 views

"Unable to read keypair file" during 'anchor test', but ~/.config/solana/id.json is there

I have a project that fails with Unable to read keypair file when I run anchor test: anchor test Finished release [optimized] target(s) in 0.09s Found a 'test' script in the Anchor.toml. Running ...
mikemaccana's user avatar
  • 1,845
3 votes
0 answers
21 views

Anchor Test fails with version error [duplicate]

Issue: I installed everything needed to start developing on Solana. I am trying to test a simple contract but when i run: anchor test, it errors out the following: error: package `solana-program v1.18....
Dutch's user avatar
  • 31
0 votes
0 answers
18 views

Anchor program test with error: Transaction failed to sanitize accounts offsets correctly

hope someone can help me. i modity the project which called AMM https://github.com/ironaddicteddog/anchor-amm after update the version of anchor and rewrite test code. but face the problem : Error: ...
imoyaki's user avatar
0 votes
1 answer
8 views

How to pass multiple contexts to a single function?

I'm creating a staking contract and one of the functions that takes in the deposits, I'm using a struct in the context of transferring SPL, however, to keep the records for the same I need to create ...
ProgrammerForFun's user avatar
1 vote
1 answer
22 views

How to get the SHA256 hash of some bytes on chain?

I want to get the SHA256 hash of some bytes in a Solana on-chain program. What's the best practice? Should I use a normal Rust crate like sha256 crate? Or is there any approach that is dedicatedly ...
Yan's user avatar
  • 333
1 vote
1 answer
76 views

how to mint compressed NFT using bubblegum inside solana program (rust)

I'm going to write a solana program (rust, probably anchor) which mints NFTs to a collection using Bubblegum standard. I noticed most guide use JS/TS to mint cNFTs with bubblegum, but I need to do ...
cablespecific's user avatar
0 votes
0 answers
26 views

Problem creating a lending program

I am creating a lending program in anchor (solana) , but i don't understand the depositCollaterial and acceptCollaterial, how would i make the solana program to accept a user usdc (depositCollaterial) ...
Davy King's user avatar
0 votes
0 answers
21 views

Solana websocket listen logs duplicate

I'm writing a script to listen to event emitted on Solana, but when listening, sometime the event is emitted twice at 2 different slots and timestamp. But when I go to solscan.io, I only see ...
Lê Văn Anh Tú's user avatar
0 votes
0 answers
19 views

plateform scams solana

I recently fell victim to an exchange scam. I sent 8000 USDT from my Binance platform to a site called < solsit.com >, believing it was a legitimate exchange. However, after completing the ...
malika rizki's user avatar
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
0 votes
1 answer
27 views

anchor_lang::AccountDeserialize

How to implement correctly try_deserialize and try_deserialize_unchecked for this Example struct? I've been trying, but failing miserably. #[derive(Clone)] pub struct ExampleProgram; declare_id!(&...
beliveN DAOist.dev's user avatar
0 votes
1 answer
45 views

How to transfer SOL to remaining_accounts from the signer account

I am trying to transfer 0.1 SOL from the signer account to all the accounts passed in the remaining_accounts to the function call. Here's a breakdown of the code. anchor pub fn purchase_package(...
Dhruv Godambe's user avatar
3 votes
1 answer
138 views

‘ please minimize large stack variables’ error while running anchor build (Mac air M1)

I have encountered an error when compiling a Solana smart contract using Anchor build on a Mac M1, while it works fine on Linux Ubuntu. ➜ solana-auction git:(master) ✗ solana --version solana-cli 1....
RAN LIU's user avatar
  • 31
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
1 vote
1 answer
29 views

How to calculate size of Option<String> for Anchor accounts

I saw on the docs that the size for Option<T> is 1 + space(T), but considering that T is a String, how can I know the size when initializing an account? #[account] pub struct UserAccount { ...
Matheus Baptistella's user avatar
0 votes
0 answers
38 views

Transaction signature verification failure

I'm coming to you with yet another Transaction signature verification failure. I read few other posts about it but it did not helped me (including adding prio fee ix) Context: I'm using anchor to call ...
Daniel Pavel's user avatar

1
2 3 4 5
23