Skip to content

koushikmaturi/swapper-cli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swapper CLI

Swapper CLI is a simple example of how to build a command-line interface tool using the Garden SDK. This tool lets you swap between WBTC (Wrapped Bitcoin) and BTC (Bitcoin) directly from your terminal. For a step-by-step guide on how this CLI was built, refer to the CLI tool with Garden SDK guide.

Disclaimer: This example is meant to help you get started with the Garden SDK. It is not a complete or optimized tool and does not follow all best practices.

Getting Started

Cloning the Repository

git clone https://github.com/gardenfi/swapper-cli
cd swapper-cli

Installing Dependencies

bun install
bun link
bun link swapper

Getting the API_KEY

The API_KEY is used for initializing the ETHEREUM_PROVIDER.

// File: src/index.ts

// Part of the code that does the initialization
const API_KEY = readFileSync(join(homedir(), ".swapper_api_key"),"utf-8");
const RPC_PROVIDER_URL = `https://sepolia.gateway.tenderly.co/${API_KEY}`;
const ETHEREUM_PROVIDER = new JsonRpcProvider(RPC_PROVIDER_URL);

Note: Here we are using Tenderly as an RPC Provider.

Obtaining the API_KEY from Tenderly

  1. Go to the Tenderly Dashboard.
  2. Navigate to Node RPCs.
  3. Click Create Node & Sepolia as your network.

Setting up the API_KEY

chmod +x setup_key.sh
./setup_key.sh <API_KEY>

Running the CLI

Creating Wallets

Creating an evm wallet

swapper createevmwallet --privatekey=<PRIVATE_KEY>

createevmwallet

Creating a bitcoin wallet

swapper createbitcoinwallet --privatekey=<PRIVATE_KEY>

createbitcoinwallet

Swapping

To swap between WBTC to BTC, you can use swapwbtctobtc

swapper swapwbtctobtc --amount=0.0001

swapwbtctobtc

To swap between BTC to WBTC, you can use swapbtctowbtc

Getting details

swapper getdetails

A utility command useful for looking up the $HOME/.swapper_config.json file.

carbon(5)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.0%
  • Shell 1.0%