Skip to main content

DyDx API Setup

Connecting Gunbot to dYdx is different than connecting to centralized exchanges.

By connecting your MetaMask wallet, API credentials are automatically generated and stored in your browser. You will need to use a MetaMask wallet that is not tied to a hardware wallet. This is because the private key of the wallet is needed for signing messages, and the private key of a hardware wallet does not leave the device by design.

In order to ensure the security of your credentials, Gunbot stores them using encryption in the config file. Once you have finished configuring Gunbot, be sure to delete the plain text credentials that you collected during the setup process.

You don't need to use the same wallet as your Gunthy Wallet Address

You can create an entirely new Metamask wallet separate from your Gunbot License Wallet and use this one for dYdX.

Step 1: connect wallet

Go to https://trade.dydx.exchange/. Select 'Connect wallet' to start connecting a wallet.

Step 2: choose MetaMask

Select 'MetaMask' to proceed.

Step 3: choose connect

Select 'Connect' to proceed.

Step 4: enter MetaMask password

Enter your password to login to MetaMask.

Step 5: select remember me and give permissions

Select the 'Remember me' option before clicking 'Send requests'. This is important.

MetaMask will now show various prompts to allow the connection with dYdX. After you have successfully connected, log out and then log back in with the same MetaMask wallet address. If the wallet remembers the account, you can proceed. If not, repeat the process and make sure the wallet remembers the account.

Step 6: export private key

The first credential to save is the wallet private key. To do this, open MetaMask and follow the following three steps:

Select the three dots icon.

Go to 'Account details'.

Select 'Export private key'. Save the key.

Step 7: open local storage manager

To get the rest of the needed credentials, open the browser developer tools while you are on the logged in page of the dYdX.

Depending on the browser, developer tools can usually be opened with the keyboard shortcut F12, or alternatively Ctrl-Shift-i.

Now locate the local storage. In Google Chrome that is in 'Application' > 'Local Storage'. In Firefox it's 'Storage' > 'Local Storage'.

Step 8: Stark private key

Save the value for 'privateKey' (selected in screenshot) in 'STARK_KEY_PAIRS', to use as 'Stark private key'.

Step 9: Wallet address

Save the value for 'walletAddress' (selected in screenshot) in 'STARK_KEY_PAIRS', to use as 'Wallet address'.

Step 10: API key

Save the value for 'key' (selected in screenshot) in 'API_KEY_PAIRS', to use as 'API key'.

Step 11: API secret

Save the value for 'secret' (selected in screenshot) in 'API_KEY_PAIRS', to use as 'API secret'.

Step 12: Passphrase

Save the value for 'passphrase' (selected in screenshot) in 'API_KEY_PAIRS', to use as 'Passphrase'.

Step 13: Add dYdX to Gunbot

With the previously collected information, you can add the exchange to your Gunbot License and then connect to the exchange.