Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/docongminh/token-swap-program
Swap SOL / Token program
https://github.com/docongminh/token-swap-program
solana-program swap-token
Last synced: 8 days ago
JSON representation
Swap SOL / Token program
- Host: GitHub
- URL: https://github.com/docongminh/token-swap-program
- Owner: docongminh
- Created: 2023-04-03T02:57:07.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-22T10:17:02.000Z (8 months ago)
- Last Synced: 2024-05-22T11:33:31.208Z (8 months ago)
- Topics: solana-program, swap-token
- Language: TypeScript
- Homepage:
- Size: 246 KB
- Stars: 12
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# solana program swap token
## Overview
## Install
```bash
npm install
```
## Run unitest
Run solana vadidator local:
```bash
solana-test-validator --reset
```Run Unit test
```bash
anchor test --skip-local-validator
```Result example:
## Run test Swap SOL -> Token
- The program deployed on [devnet](https://explorer.solana.com/address/swapEsYJ7iLDbYeg9154yR1dsUjumanS7LF9KEiJQae?cluster=devnet).[Program ID](https://explorer.solana.com/address/swapEsYJ7iLDbYeg9154yR1dsUjumanS7LF9KEiJQae?cluster=devnet):
```ts
const programId = swapEsYJ7iLDbYeg9154yR1dsUjumanS7LF9KEiJQae
```
[Token mint address](https://explorer.solana.com/address/HVTEudbUMJaMRzCnQ2fo1cq6vL9gqHD9mYbvYhfkmQuh?cluster=devnet):
```ts
const mintAddress = HVTEudbUMJaMRzCnQ2fo1cq6vL9gqHD9mYbvYhfkmQuh
```Run swap:
```bash
npx ts-node client/swap.ts
```
## Notes:
- Currently, I have set default SOL value for swap: 0.5 SOL -> receive 5 Token. use specified value at [here](https://github.com/docongminh/token-swap-program/blob/master/client/swap.ts#L26-L41)
- I made public `authority`, `master authority`, and `user` [private key](https://github.com/docongminh/token-swap-program/tree/master/client/keys) for convenient testing. All wallet have already been airdrop SOL for network fees.