dYdX Chain Technical Docs
  • 👋dYdX Chain Technical Documentation
  • Getting Started
    • 💡Developer Tools
      • dYdX Chain Client for Javascript
        • Example #1: Accessing Subaccount Data
        • Example #2: Faucet Endpoints
        • Additional Javascript Client Examples
      • dYdX Chain Client for Python
        • Example #1: Placing, Replacing, and Canceling Orders
        • Exmaple #2: Trading with HRN
        • Additional Python Client Examples
      • dYdX CLI
        • Setup the dYdX CLI
        • EOA Wallets
        • Multisig wallet
        • Submit a governance proposal
    • ✨Developer Guides
    • 🦊User Guides
      • How to use Squid UI for cross-chain deposits to dYdX V4
      • How to use CCTP UI for cross-chain deposits to dYdX V4
      • How to withdraw and transfer funds from a subaccount using Command Line
    • ❓FAQ & Resources
    • 🖥️Open Source Repositories
  • Validators
    • 🛠️Getting set up
      • Hardware Requirements
      • Required Node Configs
      • Running a Validator
      • Running a Full Node
      • Snapshots
      • Validator Upgrades
    • ❓FAQ & Resources
    • 🧑Active Validator Slack
  • Front End & Wallets
    • 📚Architecture Overview
    • 🌎Web Front End
    • ❓FAQ & Resources
  • Data Dashboards & Open APIs
    • 📊Public Dashboards
    • ❓FAQ & Resources
  • Disclaimers
    • 📄Disclaimer
    • 🔓Privacy Policy
Powered by GitBook
On this page
  • Prerequisites
  • 1. Install tools (MacOS)
  • How to initiate a withdrawal from subaccount
  1. Getting Started
  2. User Guides

How to withdraw and transfer funds from a subaccount using Command Line

Prerequisites

1. Install tools (MacOS)

Make sure you have Homebrew installed

brew --version

If not, execute

/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/in

Make sure everything is up to date

brew update && brew upgrade 

You need git

 brew install git

v4-client-js uses node v18 for development. You can use nvm to manage different versions of node.

nvm install
nvm use
nvm alias default $(nvm version) # optional

You can run the following commands to ensure that you are running the correct node and npm versions.

node -v # expected: v18.x.x (should match .nvmrc)
npm -v  # expected: 10.x.x (e.g. we use 10.2.4 here)

How to initiate a withdrawal from subaccount

1. Clone or fork the public dYdX solutions repo

Open a Terminal and run the following command:

git clone [email protected]:dydxfoundation/solutions-public.git

2. Setup the environment

  • Copy the .env.example and rename as a .env file.

  • Now make sure to fill in the following parameters, MNEMONIC, NETWORK_TYPE and RECIPIENT_ADDRESS (Address to withdraw funds to)

# General
ADDRESS=your_dydx_address_here
MNEMONIC=your_mnemonic_here
NETWORK_TYPE=testnet # Use "mainnet" for main network

# withdrawOtherExample
RECIPIENT_ADDRESS=your_recipient_dydx_address_here
WITHDRAWAL_AMOUNT=1000000 #remember usdc has 6 decimals, so this represents 1 USDC
  • For testnet and testing purposes, feel free to use the mnemonic from the TS client library under v4-client-js/examples/constants.

3. Run the scripts with node

npm install
npm run build

You should now see a /build dir generated with JS files. We will use node to run these scripts

  • Open a terminal to run the example orders.

node build/withrawOtherExample.js
  • (OPTIONAL) Run the websocket to check orders for a given subaccount.

node build/websocketExample.js

PreviousHow to use CCTP UI for cross-chain deposits to dYdX V4NextFAQ & Resources

Last updated 1 year ago

🦊