Skip to content

This repo will contain code of Token swap smart contract, technology used is Rust

Notifications You must be signed in to change notification settings

wiredweb3/soldex-tokens-swap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pre Requisites

Install required library:

sudo apt-get install libudev-dev cargo

Install Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Install solana cli tool (See solana-cli usage)

sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

Install spl-token-cli

cargo install spl-token-cli

Next, create new keypair

solana-keygen new --outfile ~/.config/solana/devnet.json

You will get:

  • path to ID: ~/.config/solana/devnet.json
  • pubkey: A8wk...Xu [you can see it by typing solana-keygen pubkey]
  • passphrase to recover your new keypair: throw board ... lawn response. Store it!

Next, say solana to use generated key and set network to devnet

solana config set --keypair ~/.config/solana/devnet.json --url https://api.devnet.solana.com

Next, add balance (run in additional window, it will take long time):

for i in {1..25}; do solana airdrop 1; sleep 1; done
cd js; npm install; cd -

Token Swap Program

Full documentation is available at https://spl.solana.com/token-swap

Smart Contract is in the ./program directory. JavaScript bindings are available in the ./js directory.

Build

cd js; npm run build:program; cd -

Deploy the smart contract

Need to have at least 4 SOL.

cd js; npm run deploy:program; cd -

Create pools

To get wallet address run

solana address

Create pools (devnet)

Provide Roman address and ask to send you coins To confirm you have enough tokens run

spl-token accounts

To get SOL (Wrapped) run:

spl-token wrap 25

Create js/.env by running the following command

cd js; npm run cluster:devnet; cd -

Devnet token address mapping:

  • SOLX: 3Wm65cRmFAbiC52YXjw1dZkJLsYA75kvNFBdaZVjVQwD
  • USDC: CB74zeEZk138FikM4W7b71eshsFttLq3LRFWqpAwXFXi
  • USDT: CWgY911b1UszYmKiGYAoEbWrTNNgY1KuybJufzhsTxKx
  • SOL(WRAP): So11111111111111111111111111111111111111112

!!! IMPORTANT: make sure you prepared .env before every pool creation

Fullfill js/.env and run:

cd js; npm run create-pool; cd -

About

This repo will contain code of Token swap smart contract, technology used is Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 79.4%
  • TypeScript 17.8%
  • Other 2.8%