Skip to main content
21 votes
Accepted

What is the difference between Transfer and TransferChecked instruction from the SPL Token Program?

I looked into this a bit myself a while ago, definitely not an expert but this is what I figured out: I think it's basically that the _checked variant requires you to pass the mint account and the ...
Callum M's user avatar
  • 3,130
11 votes
Accepted

How do I transfer an SPL token using web3.js?

If you're just using web3.js: const web3 = require("@solana/web3.js"); const { Token } = require("@solana/spl-token"); (async () => { // Connect to cluster const connection ...
Jacob Creech's user avatar
  • 3,874
8 votes

How to create a PDA and enable data storage?

Coin flip would be really difficult to implement as a smart contract because it traditionally requires a source of entropy in order to create a random(-ish) result. The problem is that introducing ...
Nate's user avatar
  • 411
8 votes

What is the difference between Transfer and TransferChecked instruction from the SPL Token Program?

@callum-m nailed it. There's an added benefit that's less obvious in that hardware wallets can display the transfer amount and asset safely and correctly with TransferChecked whereas they cannot with ...
trent.sol's user avatar
  • 4,415
6 votes

Transaction simulation failed: failed to send transaction: Transaction simulation…ocessing Instruction 0: custom program error: 0x1

Custom program error: 0x1 implies that you have insufficient funds to execute the transaction. You are trying to transfer LAMPORTS_PER_SOL * 10 lamports between two accounts. You mentioned that you ...
steveluscher's user avatar
  • 2,445
6 votes
Accepted

How to efficiently transfer NATIVE SOL to a program accepting WRAPPED SOL?

Each transaction will require the wallet to sign the transaction. Rather than three separate transactions, create one transaction with the three instructions. This is the only way to have the user ...
C.OG's user avatar
  • 2,827
6 votes

What is lamports in creating transactions?

Lamports are like the "satoshi" or "cents" of Solana. The smallest unit of value. 1 USD = 100 cents 1 BTC = 100 million satoshi 1 SOL = 1 billion lamports https://docs.solana.com/...
HelmetFace's user avatar
  • 1,757
6 votes
Accepted

failed: exceeded CUs meter at BPF instruction

You can add a setComputeUnitLimit() instruction to the transaction: import { Transaction, ComputeBudgetProgram, } from "@solana/web3.js"; let tx = new Transaction(); // needs to be the ...
Kartik Soneji's user avatar
5 votes

Sending SOL from account to PDA (or any other account) results in Error: Transaction simulation failed

Transferring SOL requires the sender and receiver to be a SystemAccount. vault should be a SystemAccount. change #[account(mut, seeds = [b"vault"], bump)] pub vault: Account<'info,...
vicyyn's user avatar
  • 4,095
5 votes

How do I transfer an SPL token using web3.js?

A good code example using web3 is here: https://solanacookbook.com/references/basic-transactions.html#how-to-send-spl-tokens
Kanitelk's user avatar
5 votes
Accepted

Why we cannot transfer sol to the program address, but we can transfer the token created by spl-token to the program address

SOL is not an SPL token. When you try to send an SPL token to a program account, it sends it to the associated token account of the program by default. Furthermore, the program account does not hold ...
acheron's user avatar
  • 2,581
5 votes
Accepted

Anchor Realloc PDA

i think what you are looking for is this: #[derive(Accounts)] #[instruction(len: u16)] pub struct IncreaseAccoutSize<'info> { #[account(mut, realloc = len as usize, realloc::zero = ...
Jonas H.'s user avatar
  • 5,777
4 votes
Accepted

How to Efficiently Subscribe to NFT Transfers of All NFTs in Collection ( The N+1 Problem )

I think the 'inefficiency' that you're trying to avoid is not as bad as you think it is, as long as you don't use individual account subscriptions. A simple and reasonably efficient solution: Build a ...
yamen's user avatar
  • 678
4 votes
Accepted

How do I prevent a user from transferring a token in their wallet originating from a token mint I own or have authority on?

Token program allows you to create tokens with --enable-freeze flag and then you use spl-token freeze command to freeze any token account and then spl-token thaw to thaw an account. If you don't care ...
Tufan Barış Yıldırım's user avatar
4 votes
Accepted

What are effective fail-safes to prevent accidental transfer of coins/tokens/nfts to a non-existing wallet?

The recipient wallet might not have a token account to accept tokens of a particular mint, and it should be handled in the app itself. Currently, the flow is Get the associated token address for the ...
Concise Labs's user avatar
  • 1,376
4 votes

How to lock lamports to the game and allow winner to withdraw the winning reward

You can store the total lamports bid by the players in the PDA state. You can store it in the following way: #[account] pub struct Game { pub total_bids: u64, } You can access this state in your ...
frawd's user avatar
  • 391
4 votes
Accepted

How can i transfer sol from PDA to another account

(Answer Relevant for Anchor) You should pass recepient account into your instruction and send lamports via transfer instruction! So what you need to do is: Your instruction context should include ...
Fedoras's user avatar
  • 310
4 votes

How can i transfer sol from PDA to another account

Quote from Anchor 0.29.0 new features: Instead of **ctx.accounts.from.to_account_info().try_borrow_mut_lamports()? -= amount; **ctx.accounts.to.to_account_info().try_borrow_mut_lamports()? += amount; ...
Russo's user avatar
  • 213
4 votes

Solana recovery from wrong transfer

The whole point of blockchain is not to provide option that you are asking for. Transaction can not be reverted and nobody (even solana team) can help you about it. The only way to recover your money ...
Void's user avatar
  • 396
4 votes

SOL Change is wrong

The receiving account had "rent" deducted from it when referenced in that transaction, which is not reflected well in the pre / post SOL balances. You can see the cost of rent using solana ...
Jon C's user avatar
  • 15.8k
4 votes
Accepted

Issues with Solana CLI install & web3.js package

Once you clone the repo used in the video, you should be able to navigate to the directory, and run yarn install or npm i to install all of the needed packages. From there the variables and helpers ...
Joey Meere's user avatar
  • 1,425
3 votes

Transaction simulation failed: failed to send transaction: Transaction simulation…ocessing Instruction 0: custom program error: 0x1

As the others have said the problem is insufficient SOL, here is how to get SOL or lamports in devnet / testnet / mainnet: const airdropSignature = await connection.requestAirdrop( keypair....
Russo's user avatar
  • 213
3 votes

Issue, transfer SOL via CPI call

Your struct PullStrings<'info> needs to list the receiver ("to" account). Then, in the code for pull_strings, you need to add the receiver account to the CPI call, calling set_data. ...
AllBlooming's user avatar
  • 2,269
3 votes
Accepted

Can I give my program an account containing the pubkey of a wallet I want to transfer to, rather than the wallet pubkey itself?

No. A program endpoint must be provided with the addresses of all the accounts it manipulates. If recipient is mutated, you need to pass in recipient's public key.
man0s's user avatar
  • 690
3 votes
Accepted

Are SPL Token Delegates **Exclusive** Transfer Authorities?

The delegate is a pubkey who can transfer up to delegated_amount tokens by signing a transfer instruction, in some way it is an allowance to spend delegated_amount: The delegated_amount reduces of ...
Arowana's user avatar
  • 2,243
3 votes
Accepted

Basic division for token math

Solana tokens are not infinitely divisible. The smallest amount of token is defined by the decimals option. You simply can't divide the token any further. So if you have 10*100,000,000 tokens and you ...
itsfarseen's user avatar
3 votes

SOLVED - Executing a transfer transaction - does Rust need additional data (AccountInfo) compared to JS (Pubkey only) for the receiving wallet?

The answer is no, you cannot make this work for Rust as well. You have to use AccountInfo. However all you need to pass in from the JS client side is a Pubkey. Through Anchor, it'll automatically ...
AllBlooming's user avatar
  • 2,269
3 votes

SOLVED - Executing a transfer transaction - does Rust need additional data (AccountInfo) compared to JS (Pubkey only) for the receiving wallet?

I am not sure you can compare those two scenarios: In Rust one, you are in the middle of an on-going transaction, making a CPI call to another program In JS one, you are composing a new transaction ...
sohrab's user avatar
  • 1,781
3 votes

How to get Solana instruction data from transaction object

We implemented similar logic as part of the Solana Pay SDK The thought process is as follows: get the transaction get the pre and post balances validate the change we expected happened const ...
C.OG's user avatar
  • 2,827
3 votes

Transaction does not show amount

It seems you're transferring from a PDA (i.e. not from the wallet the user has selected in Phantom) to some other account roomEscrow, which also seems to be not the account the user has selected in ...
AllBlooming's user avatar
  • 2,269

Only top scored, non community-wiki answers of a minimum length are eligible