Questions tagged [spl-token-program]
The spl-token-program tag has no usage guidance.
194 questions
19
votes
2
answers
3k
views
What is the difference between Transfer and TransferChecked instruction from the SPL Token Program?
I'm curious what the practical difference is between the Transfer and TransferChecked instructions, and when should we use one over the other.
In this question, I'm using Transfer/TransferChecked as ...
6
votes
2
answers
9k
views
"Invalid account data for instruction" when trying to transfer USDC tokens
I want to transfer tokens from one account to another using Solana-py library. Here's what I have now:
sender_address = '7FdZ8Rv5QZ8zLzGhDpyGYB95uXEK5BaxpKKCjqmBZJnL'
sender_secret_key = '...'
...
5
votes
2
answers
1k
views
Is it possible to make an ATA in one instruction, then use that created ATA in the next instruction, in a single transaction?
This is similar to Can I Create an Account and Transfer Tokens in the same Transaction? but the 'answer' to that question doesn't actually show how to use the token account created in the first ...
5
votes
1
answer
71
views
({"err":{"InstructionError":[2,"PrivilegeEscalation"]}})
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token, TokenAccount, Transfer};
declare_id!("5L3ky71YgB1rRMbJMxw9iH2vw9A59wZ2krWW7vdwfn61");
#[program]
pub mod hodl_token_lock {
...
4
votes
1
answer
2k
views
Parse transactions in human readable format
How can I convert the data to the same form as it is done on the solana explorer for better readability?
4
votes
2
answers
531
views
Check mint to create either Token or Token2022 on demand
Solana's Token 22 tutorial tells you how to upgrade to 2022, but most deployed programs need to support existing accounts that were made with the Token program.
Let's say we have an ix that makes a ...
4
votes
4
answers
3k
views
TokenAccountNotFoundError when sending SPL tokens in React
When I try to send my SPL tokens I get this error:
OrderRow.js:72 TokenAccountNotFoundError
at unpackAccount (account.ts:170:1)
at getAccount (account.ts:103:1)
at async ...
4
votes
1
answer
744
views
Why is one of the transactions for my token account missing from my wallet in Solana Explorer?
I have a wallet 5FHwkrdxntdK24hgQU8qgBjn35Y1zwhz1GZwCkP2UJnM that has a token account Tig6ugKWyQqyRgs8CeDCuC3AaenQzRJ5eVpmT5bboDc.
I can see the transaction ...
3
votes
2
answers
407
views
How to get the Collection's public key out of certain NFT in Anchor
How can I find out the Collection's public key of some NFT in Anchor? I know it was easy to do with the Solana SDK, but as far as I know it is not compatible with Anchor.
More specifically, how can I ...
3
votes
1
answer
494
views
What is the best way to get all token holders and their balances by mint address?
There is a way to get token accounts by mint address using
https://spl.solana.com/token#finding-all-token-accounts-for-a-specific-mint
But unfortunately it only returns token accounts without balances,...
3
votes
1
answer
128
views
Observing a contract's behavior and withdrawing tokens from it
I recently encountered an error while trying to withdraw stSOL from the Tulip Protocol's "Lending" section:
Program Error: "Instruction #3 Failed - null"
At first, I thought it ...
3
votes
1
answer
482
views
How to get Mint Address of of SPL token using associated token account? without rpc call
I can get an associated token account knowing the mint address and wallet address with spl_associated_token_account::get_associated_token_address function
But is it possible to get a mint address, ...
3
votes
1
answer
150
views
Confidential Transfer Solana Setup script failing
I am trying to understand Solana Confidential Transfers, so I ran this script from the official Solana repository for a simple demonstration
https://github.com/solana-labs/solana-program-library/blob/...
3
votes
1
answer
185
views
Is executing `SystemProgram.createAccount` and `Token. InitializeAccount` in different transactions considered safe?
Solana Docs for the Token program state that:
It's important to note that the InitializeAccount instruction does not require the Solana
account being initialized also be a signer. The ...
3
votes
1
answer
394
views
How to take a snapshot of Token2022 holders?
How to take a snapshot of all holders of a Token2022? I get an output of 0
require('dotenv').config();
const fs = require('fs');
const path = require('path');
const {PublicKey, Connection} = require('@...
3
votes
1
answer
188
views
Token Rewards Calculation and Distribution
I'm doing a script to calculate rewards for a handful of addresses (from sensors). The script runs weekly where it takes a bunch of addresses from our DB, cleans the data and calculates the associated ...
3
votes
1
answer
408
views
Transfer Hook: Not backwards compatible with common wallets
As far as I understand from documentation all the Token-2022 extensions should be backwards compatible with normal transfers from spl-token standard. However when testing Transfer Hooks I was only ...
3
votes
1
answer
114
views
Metaplex Transfer pNFT failing
I am trying to transfer a pNFT via an anchor program, but it is failing at the TokenProgram.
Logs below
3
votes
1
answer
118
views
spl-token 2.2.0 at solana 1.13.5 getting multisig error: Client(PresignerError(VerificationFailure))
I've been using spl-token multisig for quite a while, but recently it stopped working and I'm getting this error:
Client(PresignerError(VerificationFailure))
We checked everything 10 times, rotated ...
3
votes
1
answer
523
views
signer privilege escalated when trying to transfer tokens out of a PDA owned escrow wallet
Here is the list of accounts I passed in (the ... is extra constraints and stuff I removed for readability)
#[derive(Accounts)]
pub struct SendTokens<'info> {
#[account(mut, seeds = ...
3
votes
0
answers
302
views
How to Bridge ERC-20 Tokens to a Similar Contract on Solana Using Wormhole or Equivalent Platform?
I am currently working on a blockchain project where I’ve encountered a challenge that I hope to get some insights on.
Background:
I have an existing ERC-20 token contract on Ethereum, which includes ...
2
votes
4
answers
6k
views
how to decode data instructions with javascript
upd:
https://docs.solana.com/developing/programming-model/transactions#instruction-data
here, my task is to decode this data using js
I tried to solve the issue with this post How to get Solana ...
2
votes
1
answer
46
views
Why is token_program needed when initiating an associated token account?
In the code below if I don't have token_program defined, I get compile time error. However, I am only initializing the ATA but not minting, transferring, approving, or burning the token mint which is ...
2
votes
1
answer
23
views
Can I simulateTransaction with arbitrary token balance amounts?
Is it prossible to pretent having infinite arbitrary token balances during simulateTransaction so that I could go through tests for swaps?
2
votes
1
answer
61
views
Spl Tokens deployed with Token 2022 program giving error during ATA creation with Solana/Web3.js
When i try to use methods like createAssociatedTokenAccount, getAssociatedTokenAddress i get error as "incorrect program id for instruction". The token address used her was my spl tokens ...
2
votes
1
answer
34
views
Why we cannot enable transferfee config or enable metadata after minting on token 2022?
We were trying to enable transfer fee config after minting a token22 token using realloc instruction, but it was not working!
We then tried to enable the transferfee config on minting and later tried ...
2
votes
1
answer
154
views
Transfer specific token to and from a known account
Given that I have the following program
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Mint, Token, TokenAccount, Transfer as SplTransfer};
declare_id!("...
2
votes
1
answer
199
views
how to transfer spl token with transfer-hook extension
I used the Solana Playground wallet to deploy a program and obtained the program ID. The ID is 6baxXgMr7HypeTBhN64rbrt31UwbSeRtsQQxGw1KBi5b. Then, I used the following script to create an SPL token.
//...
2
votes
2
answers
458
views
InterfaceAccount<'_, TokenAccount> fails to create Associated Token Account
I have basic instruction, all it does is create an ATA for a user (mint is already initialized), this is what my context looks like
// lib.rs
use {
crate::constants::*,
crate::states::*,
...
2
votes
1
answer
6k
views
How to set token tax fee?
In certain tokens on others blockchains, people who are selling/buying/transferring the tokens will be hit by a 10% or more penalty tax fee on the transactions set by token creator. Some of the ...
2
votes
1
answer
820
views
SendTransactionError: failed to send transaction: Transaction simulation failed: Attempt to debit an account but found no record of a prior credit
SOL token has been airdropped successfully on the generated payer address. Still I am getting the above error.
Here's the code:
import * as spl from "@solana/spl-token";
import * as web3 ...
2
votes
1
answer
195
views
How to i derive the owner account of an ATA (given the ATA)
One example will be the SyncNative instruction in Token Program - it gives the ATA but I want to retrieve the owner.
2
votes
1
answer
182
views
Why is AssociatedToken Program not needed when using associated_token constraint in anchor?
I wrote a piece of code that uses associated_token::mint and associated_token::authority and I passed the Token Program but did not pass the Associated Token Program. Considering All Accounts must be ...
2
votes
1
answer
336
views
Can I Create an Account and Transfer Tokens in the same Transaction?
Is it possible to create associated token account and transfer token to that token account at the same time in one transaction?
2
votes
1
answer
27
views
What does it mean for a Solana program to not be associated with a ProgramData Address?
From the Solana docs on Program Accounts, when a new program is deployed, a Program Account and an associated Program Executable Data Account is created and the Program Account stores the address of ...
2
votes
1
answer
51
views
Understanding uses of on-curve token accounts
I'm trying to understand the specific differences between token account creation methods, and the differing implementation details between apps. Specifically, why a token account in a transaction ...
2
votes
2
answers
538
views
Why do we close WSOL Token Program accounts?
Background:
If I understand correctly: During transactions where we transfer SOL to/from wallets, we need to wrap the SOL in a temporarily created WSOL Token Program account. Then use that to transfer ...
2
votes
2
answers
2k
views
Error: unable to confirm transaction. This can happen in situations such as transaction expiration and insufficient fee-payer funds
1. Description of my context on api.mainnet-beta.solana.com
Token machine made with Windows 11 remote PC
Connected to Sol network by api.mainnet-beta.solana.com
1.1 Detailed description coming from ...
2
votes
1
answer
96
views
Transfer Hook vulnerabilities
I can't tell how safe it is to arbitrarily support transfers on "transfer hook" enabled tokens via CPI from my program.
At the moment i am setting is_signer and is_writable to false on all ...
2
votes
2
answers
3k
views
How to swap SPL token using Raydium Liquidity Pool V4
Please let me know how to swap SPL token using Raydium Liquidity Pool V4.
I need sample code.
Please help me.
2
votes
2
answers
731
views
Making existing token immutable
How can I change an existing token I created from mutable to immutable? I want to change this on an SPL token would appreciate any help!
2
votes
1
answer
744
views
"Program log: Instruction: GetAccountDataSize", "Program log: Error: IncorrectProgramId", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Based on reading [https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/instruction.rs#L426][1]
It looks like the Token program does in fact have GetAccountDataSize so I ...
2
votes
1
answer
665
views
JSON RPC get all SPL token holders during specific time
I am trying to get all the holders of a specific SPL token during a specific time. I get the Error: {'code': -32010, 'message': 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA excluded from account ...
2
votes
1
answer
334
views
Sending USDC dev token not working until recepient wallet has >0 value of said token
I am trying to send usdc dev token using code to a wallet address but it kept on showing "Unable to simulate. Make sure you trust this website since approving can lead to loss of funds."
And ...
2
votes
1
answer
178
views
Does one have to generate a special token address for USDT, USDC... when one generates a new address?
In my application I need to generate new addresses from time to time. I need them for SOL as well as for the stable coins on Solana. A new address will be assigned to a new user.
Since Solana has ...
2
votes
1
answer
333
views
how to change authority of mint account?
i'm trying to change the authority of token mint to a pda so only the program can mint
pub fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>>...
2
votes
1
answer
211
views
What are the potential pitfalls of making the mint authority and freeze authority the same as the mint address?
For the TOKEN_2022_PROGRAM_ID spl-token program, it seems like it would be a best practice to make the mint authority and freeze authority different from the mint address, perhaps best to make them ...
2
votes
1
answer
139
views
How does one read a confirmed spl-transfer transaction's instructions?
Creating an spl-transfer transaction:
const transaction = new Transaction().add(
createTransferInstruction(
// Pretend this is filled in
)
)
const signature = await ...
2
votes
1
answer
27
views
How to resolve error code":-32010,"message":"2UR.... excluded from account secondary indexes; this RPC method unavailable for key
I have set up a Solana full node with a configuration of 1TB memory for eypc 64 core.
At the same time, I also opened the account index program id spl token mint spl token owner
But when using ...
2
votes
1
answer
36
views
SNS - Retrieve all Domains+Subdomains of an User
The following code is used to retrieve all Sub-Domains of a Public-Key.
const getAllSNSProgramAccounts = async () => {
const accounts = await connection.getProgramAccounts(new PublicKey('...