Environment Settings#
The following guide uses TypeScript as a reference.
Install the Following Libraries#
npm install @okx-dex/okx-dex-sdk
npm install dotenv
Create .env#
-
You will always need your OKX API credentials. Put those in the .env file
OKX_API_KEY=
OKX_SECRET_KEY=
OKX_API_PASSPHRASE=
Explanation
Parameter values need to be obtained from the OKX developer platform
- Network dependencies
Import the required variables into the .env file based on the network you're interacting with. For example:
# Solana
SOLANA_WALLET_ADDRESS=
SOLANA_PRIVATE_KEY=
SOLANA_RPC_URL=
Explanation
- SOLANA_RPC_URL: Paid RPC service is recommended to ensure stability.
- It is recommended to manage private parameters (such as SOLANA_PRIVATE_KEY) through encryption.
Tip
- Use process.env to read environment variables
- Add .env to .gitignore to prevent sensitive information leakage
- When developing multiple chains, you can create environment configuration files such as .env.solana and .env.evm
Table of contents