Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction with different tokens #7

Closed
Qweder93 opened this issue Jun 1, 2021 · 5 comments
Closed

Transaction with different tokens #7

Qweder93 opened this issue Jun 1, 2021 · 5 comments

Comments

@Qweder93
Copy link

Qweder93 commented Jun 1, 2021

Hello, is there a way in current SDK version to send different tokens (besides SOL) by sending transactions?

@yihau
Copy link
Collaborator

yihau commented Jun 1, 2021

yes. I think you can compose it by the current SDK.

@Qweder93
Copy link
Author

Qweder93 commented Jun 1, 2021

could you please explain a bit what parameters should be changed in Create Raw Transaction so amount would be in different currency, in examples it looks like I can't configure it.

@yihau
Copy link
Collaborator

yihau commented Jun 1, 2021

you need to change the instructions in the transaction.
If you are new in Solana, I think you could take look for the account model.
It will help you to build the concept quickly.
The idea of account in Solana is totally different from Ethereum.

The instruction step will like below:

  1. use sysprog.CreateAccount instruction twice to create three accounts, one for mint and the others for token account.
  2. use tokenprog.InitializeMint and tokenprog.InitializeAccount to init mint and token account (token holder)
  3. use tokenprog.MintTo or tokenprog.MintToChecked to mint some test token to your token account.
  4. now you can use tokenprog.Transfer or tokenprog.TransferChecked to transfer token

@Qweder93
Copy link
Author

Qweder93 commented Jun 2, 2021

thanks, now it's a bit more clear, still there's 4-5 methods to call with lot of values, which I'm not sure what some of them should mean, there's no comments about what should it be in methods. Maybe you have some sort of example? Would appreciate much :)

@yihau
Copy link
Collaborator

yihau commented Jun 2, 2021

I write some example in the gitbook.
feel free to open another issue for question. 💪💪💪

@yihau yihau closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants