Skip to content

Commit

Permalink
Improve environment variable documentation (#346)
Browse files Browse the repository at this point in the history
* docs: improve environment variable documentation

- Add centralized environment variables guide
- Add detailed format descriptions and examples
- Add API key source information
- Add security warnings and best practices
- Update all plugin READMEs with standardized env var docs
- Update example .env.template files with descriptive comments
- Add environment variable validation utilities

Link to Devin run: https://app.devin.ai/sessions/b6892fb4ad9347969f37b0991a89b48b

Co-Authored-By: [email protected] <[email protected]>

* docs: update viem env template with better descriptions

Co-Authored-By: [email protected] <[email protected]>

* fix: use template literal for error message

Co-Authored-By: [email protected] <[email protected]>

* fix: update code formatting in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: fix formatting in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: remove extra newline in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: fix spacing in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: fix indentation in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: fix indentation in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: fix indentation in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: fix indentation in env.ts

Co-Authored-By: [email protected] <[email protected]>

* style: add trailing commas to template literals

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and andreapae authored Feb 18, 2025
1 parent 181a318 commit 2741f3d
Show file tree
Hide file tree
Showing 23 changed files with 450 additions and 18 deletions.
89 changes: 89 additions & 0 deletions docs/environment-variables.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: Environment Variables Guide
---

# Environment Variables Guide

This guide explains all environment variables used across the GOAT SDK, their purposes, and how to properly configure them.

## RPC Endpoints

### Ethereum/EVM
- Format: `https://<network>.<provider>.com/v2/<YOUR_API_KEY>`
- Examples:
- Alchemy: `https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY`
- Infura: `https://mainnet.infura.io/v3/YOUR-API-KEY`
- Mode: `https://mainnet.mode.network`
- Base: `https://mainnet.base.org`

### Solana
- Format: `https://api.mainnet-beta.solana.com` or provider URL
- Examples:
- Public RPC: `https://api.mainnet-beta.solana.com`
- Alchemy: `https://solana-mainnet.g.alchemy.com/v2/YOUR-API-KEY`
- GenesysGo: `https://ssc-dao.genesysgo.net`

## API Keys

### Chain-Specific
- `ETHERSCAN_API_KEY`: Etherscan API access for transaction data
- Get from: https://etherscan.io/apis
- Format: 34-character string

- `SOLSCAN_API_KEY`: Solana explorer access
- Get from: https://public-api.solscan.io
- Format: 32-character string

### Protocol APIs
- `ZEROEX_API_KEY`: 0x Protocol API access
- Get from: https://dashboard.0x.org
- Format: UUID string

- `ONEINCH_API_KEY`: 1inch Protocol API access
- Get from: https://portal.1inch.dev
- Format: 32-character string

- `COINGECKO_API_KEY`: Coingecko market data access
- Get from: https://www.coingecko.com/api/pricing
- Format: 32-character string

- `UNISWAP_API_KEY`: Uniswap API access
- Get from: https://docs.uniswap.org/api/quickstart
- Format: 32-character string

### Wallet Configuration
- `WALLET_PRIVATE_KEY`: EVM wallet private key
- Format: 64-character hex string with '0x' prefix
- Example: `0x1234...5678`
- ⚠️ Never share or commit your private key

- `SOLANA_PRIVATE_KEY`: Solana wallet private key
- Format: Base58 encoded string
- Example: `4vJ9JU1bJJE96FbxRF5ukBwwYHFJ2nWPiCSz4TWxWqbf`
- ⚠️ Never share or commit your private key

- `WALLET_MNEMONICS`: BIP39 mnemonic phrase
- Format: 12 or 24 words separated by spaces
- Example: `word1 word2 word3 ... word12`
- ⚠️ Never share or commit your mnemonic phrase

## Framework Variables
- `OPENAI_API_KEY`: OpenAI API access
- Get from: https://platform.openai.com/api-keys
- Format: "sk-" followed by random characters

- `ELEVEN_LABS_API_KEY`: ElevenLabs API access
- Get from: https://elevenlabs.io/docs/api-reference/authentication
- Format: 32-character string

## Security Best Practices
1. Never commit `.env` files to version control
2. Use `.env.template` files to document required variables without values
3. Store sensitive values securely using environment variables or secrets management
4. Rotate API keys regularly and if accidentally exposed
5. Use separate API keys for development and production

## Validation
The SDK includes built-in validation for environment variables. If required variables are missing or incorrectly formatted, you'll receive helpful error messages directing you to this guide.

For more information about specific plugins and their environment variable requirements, see the README files in the respective plugin directories.
30 changes: 30 additions & 0 deletions typescript/examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Examples

## Environment Setup
Each example project requires specific environment variables to run. Copy the `.env.template` file in each project directory to `.env` and fill in the values:

### Common Variables
- `OPENAI_API_KEY`: Required for AI model interaction
- Get from: https://platform.openai.com/api-keys
- Format: "sk-" followed by random characters

- `RPC_PROVIDER_URL`: Chain-specific RPC endpoint
- Format varies by chain (see [Environment Variables Guide](../../docs/environment-variables.mdx))
- Examples:
- EVM: `https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY`
- Solana: `https://api.mainnet-beta.solana.com`

- `WALLET_PRIVATE_KEY`: Your wallet's private key
- Format varies by chain (see [Environment Variables Guide](../../docs/environment-variables.mdx))
- ⚠️ Never share or commit your private key
- Examples:
- EVM: 64-character hex with '0x' prefix
- Solana: Base58 encoded string

### Project-Specific Variables
Each example project may require additional environment variables specific to the protocols or services it interacts with. See each project's README and `.env.template` for details.

### Security Best Practices
1. Never commit `.env` files to version control
2. Use `.env.template` files to document required variables without values
3. Store sensitive values securely using environment variables or secrets management
4. See the [Environment Variables Guide](../../docs/environment-variables.mdx) for detailed security recommendations

## Vercel AI SDK

### EVM
Expand Down
14 changes: 14 additions & 0 deletions typescript/examples/langchain/viem/.env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Your EVM wallet's private key
# Format: 64-character hex string with '0x' prefix
# ⚠️ Never share or commit your private key
WALLET_PRIVATE_KEY=

# EVM RPC endpoint URL
# Format: Full URL with API key (if using Alchemy/Infura)
# Examples:
# - Base: https://mainnet.base.org
# - Alchemy: https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY
# See: docs/environment-variables.mdx for provider-specific formats
RPC_PROVIDER_URL=
21 changes: 21 additions & 0 deletions typescript/examples/vercel-ai/allora/.env.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Your EVM wallet's private key
# Format: 64-character hex string with '0x' prefix
# ⚠️ Never share or commit your private key
WALLET_PRIVATE_KEY=

# Allora API base URL
# Format: Full URL with protocol and version
# See: docs/environment-variables.mdx for details
ALLORA_API_URL=

# Your Allora API key
# Get from: https://allora.network/api-access
# Format: 32-character string
# Required for: Accessing price predictions and market analysis
ALLORA_API_KEY=

# Your Coingecko API key
# Get from: https://www.coingecko.com/api/pricing
# Format: 32-character string
# Required for: Accessing market data and price information
COINGECKO_API_KEY=
21 changes: 20 additions & 1 deletion typescript/examples/vercel-ai/coingecko/.env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Your EVM wallet's private key
# Format: 64-character hex string with '0x' prefix
# ⚠️ Never share or commit your private key
WALLET_PRIVATE_KEY=

# EVM RPC endpoint URL
# Format: Full URL with API key (if using Alchemy/Infura)
# Examples:
# - Base: https://mainnet.base.org
# - Alchemy: https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY
# See: docs/environment-variables.mdx for provider-specific formats
RPC_PROVIDER_URL=
COINGECKO_API_KEY=

# Your Coingecko API key
# Get from: https://www.coingecko.com/api/pricing
# Format: 32-character string
# Required for: Accessing market data and price information
COINGECKO_API_KEY=
21 changes: 20 additions & 1 deletion typescript/examples/vercel-ai/opensea/.env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Your EVM wallet's private key
# Format: 64-character hex string with '0x' prefix
# ⚠️ Never share or commit your private key
WALLET_PRIVATE_KEY=

# EVM RPC endpoint URL
# Format: Full URL with API key (if using Alchemy/Infura)
# Examples:
# - Base: https://mainnet.base.org
# - Alchemy: https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY
# See: docs/environment-variables.mdx for provider-specific formats
RPC_PROVIDER_URL=
OPENSEA_API_KEY=

# Your OpenSea API key
# Get from: https://docs.opensea.io/reference/api-keys
# Format: 32-character string
# Required for: Accessing NFT collection data and marketplace information
OPENSEA_API_KEY=
24 changes: 20 additions & 4 deletions typescript/examples/vercel-ai/polymarket/.env.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Your EVM wallet's private key
# Format: 64-character hex string with '0x' prefix
# ⚠️ Never share or commit your private key
WALLET_PRIVATE_KEY=

# Polygon RPC endpoint URL
# Format: Full URL with API key (if using Alchemy/Infura)
# Examples:
# - Public: https://polygon-rpc.com
# - Alchemy: https://polygon-mainnet.g.alchemy.com/v2/YOUR-API-KEY
# See: docs/environment-variables.mdx for provider-specific formats
RPC_PROVIDER_URL=

# Polymarket (get an API key by running the `pnpm create-api-key` command)
POLYMARKET_API_KEY=
POLYMARKET_SECRET=
POLYMARKET_PASSPHRASE=
# Polymarket API credentials
# Get these by running: pnpm polymarket:api-key
# ⚠️ Keep these values secure and never share them
POLYMARKET_API_KEY= # Format: UUID string
POLYMARKET_SECRET= # Format: Base64 encoded string
POLYMARKET_PASSPHRASE= # Format: String

19 changes: 14 additions & 5 deletions typescript/examples/vercel-ai/polymarket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ cp .env.template .env

3. Edit your `.env` file with the following values:
- `OPENAI_API_KEY`: Your OpenAI API key
- `WALLET_PRIVATE_KEY`: Your wallet's private key (with 0x prefix)
- Get from: https://platform.openai.com/api-keys
- Format: "sk-" followed by random characters
- `WALLET_PRIVATE_KEY`: Your wallet's private key
- Format: 64-character hex string with '0x' prefix
- ⚠️ Never share or commit your private key
- `RPC_PROVIDER_URL`: Your Polygon RPC URL
- Format: Full URL with API key (if required)
- Example: https://polygon-mainnet.g.alchemy.com/v2/YOUR-API-KEY
- See: [Environment Variables Guide](../../../docs/environment-variables.mdx)

The following values will be populated in the next step:
- `POLYMARKET_API_KEY`
- `POLYMARKET_SECRET`
- `POLYMARKET_PASSPHRASE`
The following values will be populated by the `polymarket:api-key` script:
- `POLYMARKET_API_KEY`: Your Polymarket API key (UUID format)
- `POLYMARKET_SECRET`: Your Polymarket API secret (Base64 encoded)
- `POLYMARKET_PASSPHRASE`: Your Polymarket API passphrase

For detailed information about environment variable formats and how to obtain API keys, see the [Environment Variables Guide](../../../docs/environment-variables.mdx).

4. Create an API key for your wallet using Polymarket's API key creation tool:
```bash
Expand Down
18 changes: 18 additions & 0 deletions typescript/examples/vercel-ai/send-nft-to-twitter/.env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Your EVM wallet's private key
# Format: 64-character hex string with '0x' prefix
# ⚠️ Never share or commit your private key
WALLET_PRIVATE_KEY=

# EVM RPC endpoint URL
# Format: Full URL with API key (if using Alchemy/Infura)
# Examples:
# - Base: https://mainnet.base.org
# - Alchemy: https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY
# See: docs/environment-variables.mdx for provider-specific formats
RPC_PROVIDER_URL=

# Your Crossmint API key
# Get from: https://www.crossmint.com/developers
# Format: 32-character string
CROSSMINT_API_KEY=
13 changes: 12 additions & 1 deletion typescript/examples/vercel-ai/solana/.env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Solana RPC endpoint URL
# Format: Full URL (e.g., https://api.mainnet-beta.solana.com)
# See: docs/environment-variables.mdx for provider-specific formats
SOLANA_RPC_URL=
SOLANA_PRIVATE_KEY=

# Your Solana wallet's private key
# Format: Base58 encoded string
# ⚠️ Never share or commit your private key
SOLANA_PRIVATE_KEY=
12 changes: 11 additions & 1 deletion typescript/examples/vercel-ai/solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@ cp .env.template .env

### Required Environment Variables:
- `OPENAI_API_KEY`: Your OpenAI API key for the AI model
- `SOLANA_PRIVATE_KEY`: Your Solana wallet's private key (Base58 encoded)
- Get from: https://platform.openai.com/api-keys
- Format: "sk-" followed by random characters
- `SOLANA_PRIVATE_KEY`: Your Solana wallet's private key
- Format: Base58 encoded string
- ⚠️ Never share or commit your private key
- `SOLANA_RPC_URL`: Solana RPC endpoint URL
- Format: Full URL (e.g., https://api.mainnet-beta.solana.com)
- See: [Environment Variables Guide](../../../docs/environment-variables.mdx)
- `COINGECKO_API_KEY`: Your Coingecko API key for market data
- Get from: https://www.coingecko.com/api/pricing
- Format: 32-character string

For detailed information about environment variable formats and how to obtain API keys, see the [Environment Variables Guide](../../../docs/environment-variables.mdx).

## Usage

Expand Down
27 changes: 25 additions & 2 deletions typescript/examples/vercel-ai/viem/.env.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# OpenAI API key for AI model interaction
# Get from: https://platform.openai.com/api-keys
# Format: "sk-" followed by random characters
OPENAI_API_KEY=

# Your EVM wallet's private key
# Format: 64-character hex string with '0x' prefix
# ⚠️ Never share or commit your private key
WALLET_PRIVATE_KEY=

# EVM RPC endpoint URL
# Format: Full URL with API key (if using Alchemy/Infura)
# Examples:
# - Base: https://mainnet.base.org
# - Alchemy: https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY
# See: docs/environment-variables.mdx for provider-specific formats
RPC_PROVIDER_URL=
UNISWAP_API_KEY=kHEhfIPvCE3PO5PeT0rNb1CA3JJcnQ8r7kJDXN5X
UNISWAP_BASE_URL=https://trade-api.gateway.uniswap.org/v1

# Your Uniswap API key
# Get from: https://hub.uniswap.org
# Format: 32-character string
# Required for: Accessing Uniswap's API for quotes and swaps
UNISWAP_API_KEY=

# Uniswap API base URL
# Format: Full URL with protocol and version
# Default: https://api.uniswap.org/v1
UNISWAP_BASE_URL=
17 changes: 15 additions & 2 deletions typescript/examples/vercel-ai/viem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@ cp .env.template .env

### Required Environment Variables:
- `OPENAI_API_KEY`: Your OpenAI API key for the AI model
- `WALLET_PRIVATE_KEY`: Your wallet's private key (with 0x prefix)
- `RPC_PROVIDER_URL`: EVM network RPC URL (with Base)
- Get from: https://platform.openai.com/api-keys
- Format: "sk-" followed by random characters
- `WALLET_PRIVATE_KEY`: Your wallet's private key
- Format: 64-character hex string with '0x' prefix
- ⚠️ Never share or commit your private key
- `RPC_PROVIDER_URL`: EVM network RPC URL
- Format: Full URL with API key (if required)
- Example: https://mainnet.base.org
- See: [Environment Variables Guide](../../../docs/environment-variables.mdx)
- `UNISWAP_API_KEY`: Your Uniswap API key
- Get from: https://hub.uniswap.org
- Format: 32-character string
- `UNISWAP_BASE_URL`: Uniswap API base URL
- Format: Full URL with protocol and version
- Default: https://api.uniswap.org/v1

For detailed information about environment variable formats and how to obtain API keys, see the [Environment Variables Guide](../../../docs/environment-variables.mdx).

## Usage

Expand Down
Loading

0 comments on commit 2741f3d

Please sign in to comment.