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
  1. Getting Started
  2. Developer Tools
  3. dYdX Chain Client for Javascript

Example #2: Faucet Endpoints

Simple JS example demonstrating filling subaccount with Faucet API.

import { FaucetApiHost } from '../src/clients/constants';
import { FaucetClient } from '../src/clients/faucet-client';
import { DYDX_TEST_ADDRESS } from './constants';

async function test(): Promise<void> {
  const client = new FaucetClient(FaucetApiHost.TESTNET);
  const address = DYDX_TEST_ADDRESS;

  // Use faucet to fill subaccount
  const faucetResponse = await client?.fill(address, 0, 2000);
  console.log(faucetResponse);
  const status = faucetResponse.status;
  console.log(status);
}

test().then(() => {
}).catch((error) => {
  console.log(error.message);
});
PreviousExample #1: Accessing Subaccount DataNextAdditional Javascript Client Examples

Last updated 1 year ago

💡