Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/DEPLOYMENT_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Agent deployment guide

This document walks through deploying a Polymarket agent in a production environment.

1. **Clone the repository** and create a virtual environment.
2. **Set environment variables** (`POLYGON_WALLET_PRIVATE_KEY`, `OPENAI_API_KEY`, etc.).
3. **Install dependencies** with `pip install -r requirements.txt`.
4. **Run the agent**: `python agents/main.py`.

For Docker deployments, build the image with `docker build -t polymarket-agent .` and configure secrets via environment variables.
53 changes: 53 additions & 0 deletions scripts/bash/check_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail

# Simple sanity check for the Polymarket Agents .env file.
#
# Usage:
# ./scripts/bash/check_env.sh
#
# The script checks that the .env file exists and that key variables
# required by the README are present and non-empty.

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
ENV_FILE="${ROOT_DIR}/.env"

REQUIRED_VARS=(
"POLYGON_WALLET_PRIVATE_KEY"
"OPENAI_API_KEY"
)

if [ ! -f "${ENV_FILE}" ]; then
echo "[env-check] .env file not found at: ${ENV_FILE}"
echo "[env-check] Run: cp .env.example .env and fill in your values."
exit 1
fi

echo "[env-check] Using env file: ${ENV_FILE}"

missing=0

while IFS='=' read -r key value; do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last line silently ignored if file lacks newline

The while IFS='=' read -r key value loop doesn't process the last line of the .env file if it lacks a trailing newline. When read hits EOF without a newline, it returns non-zero even though it successfully read data, causing the loop to exit before processing that line. This could silently ignore a required variable like OPENAI_API_KEY if it happens to be on the final line, with no error message indicating why the check fails.

Fix in Cursor Fix in Web

case "${key}" in
''|\#*)
continue
;;
*)
export "${key}=${value}"
;;
esac
done < "${ENV_FILE}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoted empty values incorrectly pass validation check

The .env.example template uses quoted empty values like POLYGON_WALLET_PRIVATE_KEY="". When parsing with IFS='=', the literal quote characters are preserved in the value. The -z check then incorrectly considers "" (two quote characters) as non-empty, so the sanity check passes for unfilled placeholder values. Users who copy the template without filling in real values would not be warned.

Fix in Cursor Fix in Web


for var in "${REQUIRED_VARS[@]}"; do
if [ -z "${!var:-}" ]; then
echo "[env-check] Missing or empty variable: ${var}"
missing=1
fi
done

if [ "${missing}" -ne 0 ]; then
echo "[env-check] One or more required variables are not set correctly."
exit 1
fi

echo "[env-check] All required variables are present."