Developer Resources
  • Overview
    • Introduction
    • TBCs on Solana
  • Get started
    • Quick Start Guide
    • TBC on Solana
      • Step 1: Create token
      • Step 2: Initialize Token Bonding Curve (TBC)
        • TBC Guides
        • TBC Examples
        • FAQs
      • Step 3: Swap Tokens
    • Grants
  • Tools
    • Swap for sRLY
  • Resources
    • FAQ
    • Solana Docs
    • Discord
    • Github
    • Anchor
    • Example React App
  • Archived
    • RLY Rewards
      • Bootstrap phase
      • Mature phase
Powered by GitBook
On this page
  • Swapping Tokens
  • Step 3.1: Swap tokens
  • That's it!
  1. Get started
  2. TBC on Solana

Step 3: Swap Tokens

Learn how to swap between your app token and sRLY. This will be the main method your users will use obtain your app token through the token swap.

PreviousFAQsNextGrants

Last updated 3 years ago

Swapping Tokens

Step 3.1: Swap tokens

Enter the two tokens to swap from / to and enter the amount.

Usage: rly-cli tbc-swap [options] <swap> <token_a> <token_b> <amount>

Arguments:
  swap                  swap
  token_a               token A
  token_b               token B
  amount                amount of token a to swap

Options:
  -e, --env <string>    Solana cluster env name (default: "devnet")
  -k, --keypair <path>  Solana wallet location (default: "--keypair not provided")
  -h, --help            display help for command
// token bonding curve

import { Provider } from "@project-serum/anchor"
import { Keypair, Connection, clusterApiUrl } from 'solana/web3js`;
import { tokenSwapProgram } from 'rly-js';

const walletKeyPair = Keypair.generate();
const provider = new Provider(new Connection(clusterApiUrl("devnet")), new NodeWallet(walletKeyPair), {});

const tokenSwap = await tokenSwapProgram(provider);

// 

Examples:

Usetbc-swap-estimate to see estimate outputs.

That's it!

In this section you should have:

  • Swapped between two tokens in both directions

  • Verified balance changes in both token swap token accounts

  • Verified balance changes in the user token accounts

https://github.com/rally-dfs/dfs-ts/tree/main/ts/tests