Comments (5)
-
Transactions on solana are made of one or more instructions.
-
Each instruction specifies a set of accounts, and data encoded as a binary blob.
-
That binary blob can be anything and is entirely depended on how the program works and what it expects.
-
In the case of SOL transfers from one wallet to another, the
system
program is used. -
You cans see here an example of how to send SOL here: https://github.com/gagliardetto/solana-go#transfer-sol-from-one-wallet-to-another-wallet
-
How to decode a raw transaction into its elemental instructions? See here: https://github.com/gagliardetto/solana-go#parsedecode-an-instruction-from-a-transaction
-
The
preBalances
andpostBalances
(andpreTokenBalances
,postTokenBalances
) are metadata that's added after the instruction has been executed.
from solana-go.
Wow, thank you for replying to me so seriously. Based on your reply, I learned some relevant knowledge points, but I'm sorry I encountered new problems again.
Suppose I have a Solana account. When I want to receive a token transfer, I must first create an associated account. Does that mean that the transferor must do this for the receiver? From the perspective of programming, do I have to judge whether this address is a token address? Then it depends on whether I want to create an associated account or not?
I noticed that Solana cli has a parameter --allow unfunded recipient
--fund recipient
. If the target address is a token address that has been created, this parameter will be ignored
I look forward to your valuable reply.
from solana-go.
I'm no expert on this topic (and you're better off asking/searching that question in the solana documentation, discord, or even better on solana stackoverflow).
The Sollet solana wallet is opensource, and you can see the code implementation of this and other dynamics: https://github.com/project-serum/spl-token-wallet
They are fairly easily portable to solana-go (often).
- From my limited knowledge on the topic, yes the sender must create the associated-token-account for the recipient if the associated-token-account doesn't exist.
- What is an "associated token account"? It's an account derived from the owner of the parent wallet (in your case the recipient) and the mint of the token.
- Something like this:
(wallet + mint) => associated_token_account
(because it's an inextricably associated token account with the wallet it's for.) - Knowing the wallet and the mint, you can find the atok account.
- Knowing the atok account, you can find the owner wallet and the mint.
- AFAIK anyone can create an associate token account for anyone else, but the owner is always the wallet it was created for.
- The
--allow unfunded recipient --fund recipient
flags (I think) are there because if the atok account doesn't exist, you need to create it. To create an account on solana, you need to fund it with enough SOL so that it can pay rent and won't get deleted (evicted). (or even better, be funded enough so that it becomesrent-exempt
so it can exist forever.)
Anyway, you're better off going to look into the documentation and the source code:
- https://spl.solana.com/associated-token-account
- https://github.com/solana-labs/solana-program-library/blob/master/associated-token-account/program/src/instruction.rs
from solana-go.
You need an atok for storing and transfering for anything that's a token (which means everything, except for SOL).
- NFTs are tokens.
- USDC is a token.
- Your meme coin is a token.
- Wrapped SOL is a token.
Basically everything is a token (also called "SPL token").
from solana-go.
Thank you for your serious reply. With your help, I have a new understanding of Solana access transaction. Thank you again
from solana-go.
Related Issues (20)
- panic: runtime error: makeslice: len out of range HOT 6
- unable to decode instruction: no known type for type [12 0 225 245 0 0 0 0] HOT 3
- Pls help me, how to get token metadata? HOT 1
- UiTokenAmount data type HOT 1
- "AccountSubscribe method is invalid" HOT 5
- Priority Fee during this congested period. HOT 4
- Create associated token account idempotent instruction
- BlockSubscribe no data output. HOT 1
- Transaction failed to sanitize accounts offsets correctly HOT 2
- Send SPL Token using this Library HOT 2
- do you suport Raydium dex interface?
- how to get token owner of a token account HOT 4
- panic while decoding Instruction in spl transfer transaction HOT 3
- ws blocksubscribe - does extract rewords
- How to parse Program data from log?
- Versioned transaction HOT 3
- send transaction success,but can not locate transaction on blockchain HOT 3
- How to make transaction extra fees use NewTransaction() on transaction.go files ?
- How can we obtain the real token receiving address?
- Create tx with LUT
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solana-go.