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
  • Repository: v4-web
  • Prerequisites
  • Part 1: Setting up your local environment
  • Part 2: Running the project locally
  • Part 3: Configuring environment
  • Part 4: Set Enviornment variables
  • Deployments
  • Deploying with Vercel
  • Deploying to IPFS
  • Cloudflare Settings
  1. Front End & Wallets

Web Front End

PreviousArchitecture OverviewNextFAQ & Resources

Last updated 1 year ago

Repository:

Prerequisites

  • Node.js version 18 and pnpm installed on your system

  • Wallet Connect account

For deploying with Vercel, create an account with if you don't have one already.

For deploying to IPFS, choose one of the following:

  • Option 1: A free account

  • Option 2: An IPFS client such as

For web3.storage, sign up for an account and generate an API token on the . web3.storage offers an easy-to-use interface for storing and retrieving content on IPFS.

Alternatively, follow the to download the IPFS command-line tool.

Part 1: Setting up your local environment

1. Clone the repo

Clone the repository and navigate to its directory:

git clone https://github.com/dydxprotocol/v4-web.git
cd v4-web

2. Install pnpm and dependencies

Install pnpm and the project dependencies:

npm i -g pnpm
pnpm i

Part 2: Running the project locally

Run the following command in the project directory to start the development server:

pnpm dev

The development server will be running at http://localhost:5173 (or the port number displayed in the terminal). Visit this URL to interact with the web app and see your changes in real-time.

To view component stories:

pnpm ladle

This will automatically open your default browser at http://localhost:61000.

Part 3: Configuring environment

Add or modify the relevant endpoints, links and options in /public/configs/env.json. You'll need to provide a Wallet Connect project id to enable onboarding and wallet connection:

Part 4: Set Enviornment variables

Set environment variables via .env.

  • VITE_BASE_URL (required): The base URL of the deployment (e.g., https://www.example.com).

  • VITE_ALCHEMY_API_KEY (optional): Add an Alchemy API key for EVM interactions; the app will fall back to public RPCs if not provided.

  • VITE_PK_ENCRYPTION_KEY (optional): AES encryption key used for signature obfuscation; necessary for enabling the "Remember Me" feature.

  • VITE_V3_TOKEN_ADDRESS (optional): Address of the V3 $DYDX token.

  • VITE_TOKEN_MIGRATION_URI (optional): The URL of the token migration website.

  • AMPLITUDE_API_KEY (optional): Amplitude API key for enabling Amplitude; used with pnpm run build:inject-amplitude.

  • AMPLITUDE_SERVER_URL (optional): Custom Amplitude server URL

  • BUGSNAG_API_KEY (optional): API key for enabling Bugsnag; used with pnpm run build:inject-bugsnag.

  • IOS_APP_ID (optional): iOS app ID used for enabling deep linking to the iOS app; used with pnpm run build:inject-app-deeplinks.

  • INTERCOM_APP_ID (optional): Used for enabling Intercom; utilized with pnpm run build:inject-intercom.

  • STATUS_PAGE_SCRIPT_URI (optional): Used for enabling the status page; used with pnpm run build:inject-statuspage.

  • SMARTBANNER_APP_NAME, SMARTBANNER_ORG_NAME, SMARTBANNER_ICON_URL, SMARTBANNER_APPSTORE_URL (optional): Used for enabling the smart app banner; used with pnpm run build:inject-smartbanner.

Deployments

Deploying with Vercel

Step 1: Connect your repository to Vercel

Select "Import Git Repository" from your dashboard, and provide the URL of this repository or your forked repository.

Step 2: Configure your project

For the "Build & Development Settings", we recommend the following:

  • Framework Preset: Vite

  • Build Command (override): pnpm run build

By default, the dev server runs in development mode and the build command runs in production mode. To override the default mode, you can pass in the --mode option flag. For example, if you want to build your app for testnet:

pnpm run build --mode testnet

If you wish to incorporate analytics via Amplitude and Bugsnag, you can use our scripts: pnpm run build:inject-amplitude and pnpm run build:inject-bugsnag. You will need to provide your own API keys for these services. In the Environment Variables section, name the variables as AMPLITUDE_API_KEY and BUGSNAG_API_KEY and provide the respective keys as their values.

If you wish to incorporate smart banner for iOS and/or Android apps, you can use our scripts: pnpm run build:inject-smartbanner. You will need to provide your own app configurations for these services. In the Environment Variables section, name the variables as SMARTBANNER_APP_NAME, SMARTBANNER_ORG_NAME, SMARTBANNER_ICON_URL and SMARTBANNER_APPSTORE_URL or SMARTBANNER_GOOGLEPLAY_URL and provide the respective values.

Deploying to IPFS

web3.storage: deploy to IPFS via web3.storage using the provided script

Export the API token as an environment variable (replace your_token with the generated token), and run the script to build and deploy to IPFS:

export WEB3_STORAGE_TOKEN=your_token
pnpm run deploy:ipfs

Save the URL provided in the output, as it is the link to your deployed content on IPFS.

IPFS client: deploy with the command-line tool

To use the IPFS command-line tool, run:

ipfs add -r dist

Save the CID provided in the output.

Accessing your content on IPFS

To access your content on IPFS:

  1. Native IPFS support in a browser: Use a browser with native IPFS support, such as Brave or Opera. Enable a local IPFS node and visit the URL directly using the IPNS protocol, like ipfs://your_cid.

Replace your_cid with the actual CID.

Cloudflare Settings

We recommend that you add your website to Cloudflare for additional security settings.

To block OFAC Sanctioned countries:

  1. Navigate Websites > Domain > Security > WAF

  2. Create Rule with the following settings:

  • If incoming requests match (ip.geoip.country eq "CU") or (ip.geoip.country eq "IR") or (ip.geoip.country eq "KP") or (ip.geoip.country eq "SY") or (ip.geoip.country eq "MM") or (ip.geoip.subdivision_1_iso_code eq "UA-09") or (ip.geoip.subdivision_1_iso_code eq "UA-14") or (ip.geoip.subdivision_1_iso_code eq "UA-43")

  • This rule will bring up a Cloudflare page when a restricted geography tries to access your site. You will have the option to display:

    1. Custom Text

    2. (e.g. Because you appear to be a resident of, or trading from, a jurisdiction that violates our terms of use, or have engaged in activity that violates our terms of use, you have been blocked. You may withdraw your funds from the protocol at any time.)

Create a project on

Copy over the project ID into this

For more details, check out Vercel's .

Public IPFS gateway: Access your content via a public IPFS gateway, such as or . Use the gateway URL with your CID appended, like https://dweb.link/ipfs/your_cid.

🌎
v4-web
Vercel
web3.storage
IPFS Kubo
API tokens page
IPFS Kubo installation guide
https://cloud.walletconnect.com/app
field
official documentation
https://dweb.link
https://w3s.link/