Skip to main content
17 votes
Accepted

How to close SPL token accounts to redeem SOL

The other answers are Rust implementations. Here's a Typescript one for browsers/Node applications using @solana/web3.js and @solana/spl-token (v0.2.0): NOTE: Solana enforces transaction size limits, ...
Quellen's user avatar
  • 186
5 votes

What is the Solana idiomatic way of logging/accessing information about who sent tokens via a program?

A way to do this would be to create a separate account for each wallet that contributes. That account would be a PDA to prevent duplicity, and would store contribution details such as the amount ...
Ademola's user avatar
  • 3,853
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,679
5 votes

How to close SPL token accounts to redeem SOL

I get the feeling this isn't what you mean by programmatic but I'll leave this here anyway in case someone else comes here looking for this. If you're asking how to do this inside an on-chain Anchor ...
zfedoran's user avatar
  • 761
4 votes
Accepted

Get Solana SPL Address from base 58 string

You can get the correct key by calling new PublicKey(string). The constructor for PublicKey takes a number of different types: number | string | Buffer | Uint8Array | number[] https://solana-labs....
C.OG's user avatar
  • 2,837
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 you convert the byte array returned as "Data" for a given instruction into a human-readable form?

Background This is a bit of a broad question, as there are several cases to consider, but the basic fact to understand is: the data field in an instruction is the arbitrary, serialized input given to ...
man0s's user avatar
  • 690
4 votes

How to close SPL token accounts to redeem SOL

If the accounts are "ancillary" token accounts, meaning not associated token accounts, you can use the spl-token CLI's gc command, which cleans up extra accounts. You can simply run: $ spl-...
Jon C's user avatar
  • 16.1k
4 votes

How to fetch updateAuthority of the NFTs without using metaplex js library?

Try getAssetsByAuthority from DAS API through Helius https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-authority
john's user avatar
  • 7,487
4 votes
Accepted

Send SPL per lamport for msg.sender solana alternative

Let's quickly get into why there isn't necessarily a msg.sender like you're used to on Ethereum. On Solana, you cannot guarantee that the person who paid the fee on the transaction is the traditional ...
Jacob Creech's user avatar
  • 3,874
4 votes

Does the BURN instruction decrease the SUPPLY total in the MINT ACCOUNT?

Yes, the SPL BURN instruction does decrease the total supply number stored in the Mint Account. Here's how it works: Token Account: This is an account that holds a specific amount of a particular ...
Glen's user avatar
  • 61
3 votes

Circulating Supply of an SPL Token

You can easily get the supply of an SPL token with getTokenSupply RPC method. curl <RPC_ENDPOINT> -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0"...
acheron's user avatar
  • 2,679
3 votes

How to close SPL token accounts to redeem SOL

SPL has a closeAccount instruction. Here's the anchor_spl docs. I don't think there's any way to mass-close accounts, you will just have to close them one by one (or several per transaction).
Ellie High's user avatar
  • 1,074
3 votes

What is a SPL Token "Approve" instruction?

The purpose of the approve instruction is to delegate the right to transfer or burn up to delegated_amount to the delegate Pubkey. If this Pubkey signs a token transfer it is allowed to transfer up to ...
Arowana's user avatar
  • 2,263
3 votes

Funding of wallets

Without having to send SOL to your customers, you can use a relayer to solve this problem. Imagine a person who wants to participate in a transaction involving an SPL token that they hold but who has ...
steveluscher's user avatar
  • 2,455
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,263
3 votes
Accepted

How to import METADATA_PROGRAM_ID. (Buildspace Solana Staking Anchor course)

You can install @metaplex-foundation/mpl-token-metadata from here and import it like import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata" Else you can ...
Swaroop Maddu's user avatar
3 votes

Transferring tokens to another user, with sender-funding, via JS

You can create the token account first, which you can do in JS like this: const toTokenAccount = await getOrCreateAssociatedTokenAccount( connection, payer, // this is the funder (a signer) mint,...
Callum M's user avatar
  • 3,170
3 votes

Can I use the meta plex js SDK to update SPL token meta data?

Ok, I gave up. Now im just using the createSFT function from metaplex instead: Here is the solution: import { keypairIdentity, token, Metaplex } from "@metaplex-foundation/js"; const ...
Jonas H.'s user avatar
  • 5,787
3 votes
Accepted

How to fetch updateAuthority of the NFTs without using metaplex js library?

you could also look at using metaboss to decode the specific nft mint youre looking to work with and from there recover the update auth. have a look at metaboss here: https://metaboss.rs/decode.html ...
bill_papas_12's user avatar
3 votes
Accepted

Mint Token as a PDA via SPL

It sounds like you're trying to create a mint account using PDA from your program as the address. Try just using anchor constaints to create the mint account. #[derive(Accounts)] pub struct ...
john's user avatar
  • 7,487
3 votes

change the mintAuthority

The current authority has to be included as a signer. You're specifying that the mintPubkey is also the current mint authority on the mint account. This means you would need to have the keypair that ...
john's user avatar
  • 7,487
3 votes
Accepted

Where does the initial supply of an SPL token go if no mint authority is present?

There is no actual supply until you mint it. You would need to first create a token account and the mint to that account: spl-token create-account EBF22st7gRqvKtEYW2WomsHUsNrjtPcZvpDAnh6W7Ugu spl-...
Jonas H.'s user avatar
  • 5,787
3 votes
Accepted

Transfer_hook in spl-2022: Only deduct tax from swap transaction

This is up to your own design in the end, but if you want to detect that a particular transfer is being called from a swap program, there's a few options: include the "instructions" sysvar ...
Jon C's user avatar
  • 16.1k
3 votes

Confidential Transfer Solana Setup script failing

I think the token proof program for confidential transfers is not yet deployed to mainnet. It will come with Solana version 1.18.x. https://github.com/anza-xyz/agave/wiki/v1.18-Release-Schedule They ...
Jonas H.'s user avatar
  • 5,787
3 votes
Accepted

How to transfer tokens using transfer hook in Anchor

There might not be Anchor helpers yet to create the proper transfer with all the transfer hook accounts. In the meantime, you can use the onchain helpers that come with token-2022 at https://github....
Jon C's user avatar
  • 16.1k
2 votes

how to fetch SPL by owner without NFT tokens

A better way would be to look into the decimals and supply of the Token Mint Account. If the decimals are 0 and the supply is 1 then its an NFT
Pratik.js's user avatar
  • 1,632
2 votes

Funding of wallets

I can think of 2 options that might work, but it's a bit hard to know exactly what you're trying to achieve. You could create a transaction that sends both SOL and SPL tokens to the wallet you want ...
Callum M's user avatar
  • 3,170
2 votes
Accepted

Why is AssociatedToken Program not needed when using associated_token constraint in anchor?

You need the Associated Token Program when creating an ATA on the Rust end, but don't need it just to validate an ATA. So if the ATA was created earlier, or you create your ATAs on the client side, ...
Whiteseal's user avatar
  • 3,204
2 votes

how to get owner of token account

Try largestAccountInfo.value.data.parsed.info.owner sorry it's not in py, but TS example: const tokenMint = "9ARngHhVaCtH5JFieRdSS5Y8cdZk2TMF4tfGSWFB9iSK"; const largestAccounts = await ...
OneFishTaco's user avatar

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