Questions tagged [anchor-solana]
195 questions
10
votes
3 answers
Error loading workspace IDL for Solana Anchor Testing
For some reason, my mocha test is unable to find my IDL. I am getting the error below:
name@Mabels-MacBook-Pro solana-anchor-reactjs-payment % anchor test
BPF SDK:…

Mabel Oza
- 557
- 8
- 22
10
votes
4 answers
I can not deploy the program to dev net with anchor
I get this error where I run anchor deploy:
Deploying workspace: http://127.0.0.1:8899
Upgrade authority: /home//.config/solana/id.json
Deploying program "faucet"...
Program path:…

Noldorin Zhang
- 181
- 1
- 2
- 7
7
votes
4 answers
What does "invalid account discriminator" mean in Anchor?
I'm trying to fetch an account from a public key:
await program.account.myAccountType.fetch(somePubkey);
But then Anchor throws an error saying:
Invalid account discriminator
What is an account discriminator?

Evan Conrad
- 3,993
- 4
- 28
- 46
6
votes
2 answers
Solana token transfer using Anchor
I'm having problems doing what I thought would be a straightforward token transfer.
First some code:
#[derive(Accounts)]
#[instruction(amount: u64)]
pub struct TransferTokens<'info> {
#[account(mut)]
pub sender: Signer<'info>,
…

Erik Strömberg
- 322
- 4
- 12
4
votes
1 answer
Conceptual difference between Token, Account and Associated account in Solana
I'm coming from an Ethereum environment and the Solana concepts are a bit confusing. I found various tutorials that guide thru the code steps, but don't really explain the concept behind the logic.
I understand that in Solana we've got Programs,…

Milkncookiez
- 6,817
- 10
- 57
- 96
4
votes
1 answer
Linking Solana PDAs with each other
I'm using Solana PDAs to build a hashmap-like structure, using users' wallet addresses as one of the seeds. The PDA is called MyNodes, and contains some data specific to the user, including accrued rewards.
Now I'm trying to build a referral system.…

AllBlooming
- 190
- 7
4
votes
0 answers
How to use @solana/spl-token in vanilla JS after importing in HTML using CDN?
I am trying to use @solana/spl-token(https://www.npmjs.com/package/@solana/spl-token) npm module with the below react implementation and convert it to vanilla js accessing it via CDN(https://www.jsdelivr.com/package/npm/@solana/spl-token) link after…

Aman Prakash
- 340
- 4
- 15
4
votes
3 answers
How to transfer SOL from a PDA which created a token associate account to a normal account in Anchor?
If once a PDA is created as an associate token address, it can not transfer SOL from the PDA to another account?
I'd like to transfer both SOL and SPL-Token using a single PDA account.
I tried both solana_program::program::invoke_signed with…

Kenneth Heo
- 91
- 4
4
votes
2 answers
error[E0412]: cannot find type `ProgramResult` in this scope
use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod myepicproject {
use super::*;
pub fn start_stuff_off(ctx: Context) -> ProgramResult {
Ok(())
…

yeshealer
- 93
- 1
- 2
- 8
3
votes
0 answers
Having a Solana program mint tokens while a user pays the fee
I'm trying to have a Solana Anchor program mint tokens to a user's token account (so the program or its PDA should be the authority for the mint), while the owner of the token account that's receiving the tokens should pay the fee.
This is what I…

Depa
- 53
- 5
3
votes
2 answers
Estimate gas cost for transaction to custom Solana Program written with Anchor
How can I get a gasFee estimate for a transaction of my custom contract?
For a normal transaction execution from the SPL library I can do so like this:
import { Transaction } from '@solana/web3.js';
const transaction = new Transaction({
…

Milkncookiez
- 6,817
- 10
- 57
- 96
3
votes
2 answers
Cannot deploy the program to devnet with anchor
First, I tried with deploying on localhost with anchor deploy it works fine. But then I changed the cluster to devnet, changed Anchor.toml and lib.rs file with the address I got after anchor build. Then tried with anchor deploy --provider.cluster…

Satyaban Sahoo
- 117
- 8
3
votes
3 answers
AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported
I am trying to call the mintNft function on the front end but it throws an error and I can't fix it
the error is:
"Program log: AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are…

0x00gc
- 31
- 2
3
votes
2 answers
Why is "anchor build" and "Cargo build-bpf" showing wrong rustc version?
I'm trying to build the (https://github.com/betterclever/solend-anchor) package using anchor build, however I get the following error
error: package `uint v0.9.3` cannot be built because it requires rustc 1.56.1 or newer, while the currently active…

Highness
- 333
- 4
- 11
3
votes
2 answers
Airdropping Solana to a Specific Account
I would like to airdrop sols into a specific account to get my smart contract to fire an anchor test. Whenever I run my test I come across the error Error: Account BdFchxtKbEaWtsbuFX2nbKyZCjhz5LN8vyPukQzJQrME has insufficient funds for spend…

Mabel Oza
- 557
- 8
- 22