Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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.