web3-polymarket by polymarket/agent-skills
npx skills add https://github.com/polymarket/agent-skills --skill web3-polymarket当用户询问或需要构建以下内容时,请使用此技能:
| API | 基础 URL | 身份验证 | 用途 |
|---|---|---|---|
| CLOB | https://clob.polymarket.com | 交易端点需 L2 | 订单簿、价格、订单提交 |
| Gamma / 数据 | https://gamma-api.polymarket.com |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 无 |
| 事件、市场、搜索 |
| 数据 API | https://data-api.polymarket.com | 无 | 交易、头寸、用户数据 |
| WebSocket (市场) | wss://ws-subscriptions-clob.polymarket.com/ws/market | 无 | 实时订单簿 |
| WebSocket (用户) | wss://ws-subscriptions-clob.polymarket.com/ws/user | 消息中包含 API 凭据 | 交易/订单更新 |
| WebSocket (体育) | wss://sports-api.polymarket.com/ws | 无 | 实时比分 |
| 中继器 | https://relayer-v2.polymarket.com/ | 构建者头部 | 无 Gas 交易 |
| 桥接 | https://bridge.polymarket.com | 无 | 存款/取款 |
| 合约 | 地址 |
|---|---|
| USDC (USDC.e) | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
| CTF (条件代币) | 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 |
| CTF 交易所 | 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E |
| 负风险 CTF 交易所 | 0xC5d563A36AE78145C45a50134d48A1215220f80a |
| 负风险适配器 | 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296 |
import { ClobClient, Side, OrderType } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0
const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137;
const signer = new Wallet(process.env.PRIVATE_KEY);
// 步骤 1: L1 — 派生 API 凭据
const tempClient = new ClobClient(HOST, CHAIN_ID, signer);
const apiCreds = await tempClient.createOrDeriveApiKey();
// 步骤 2: L2 — 初始化交易客户端
const client = new ClobClient(
HOST,
CHAIN_ID,
signer,
apiCreds,
2, // signatureType: 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
"FUNDER_ADDRESS" // 来自 polymarket.com/settings 的代理钱包地址
);
from py_clob_client.client import ClobClient
import os
host = "https://clob.polymarket.com"
chain_id = 137
pk = os.getenv("PRIVATE_KEY")
# 步骤 1: L1 — 派生 API 凭据
temp_client = ClobClient(host, key=pk, chain_id=chain_id)
api_creds = temp_client.create_or_derive_api_creds()
# 步骤 2: L2 — 初始化交易客户端
client = ClobClient(
host,
key=pk,
chain_id=chain_id,
creds=api_creds,
signature_type=2, # 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
funder="FUNDER_ADDRESS",
)
| 类型 | 行为 | 使用场景 |
|---|---|---|
| GTC | 在订单簿上保持有效,直到成交或取消 | 默认限价订单 |
| GTD | 在到期时间(UTC 秒)前有效。最小值 = now + 60 + N | 事件前自动过期 |
| FOK | 立即全部成交,否则取消 | 全部或零市价订单 |
| FAK | 成交可成交部分,取消剩余部分 | 部分成交市价订单 |
amount = 要花费的美元金额amount = 要卖出的份额数量| 类型 | 值 | 描述 |
|---|---|---|
| EOA | 0 | 标准以太坊钱包(MetaMask)。Funder 是 EOA 地址,需要 POL 支付 Gas。 |
| POLY_PROXY | 1 | 为从 Polymarket.com 导出私钥的 Magic Link 电子邮件/Google 用户定制的代理钱包。 |
| GNOSIS_SAFE | 2 | Gnosis Safe 多签代理钱包(最常见)。用于任何新用户或回归用户。 |
const response = await client.createAndPostOrder(
{
tokenID: "TOKEN_ID",
price: 0.50,
size: 10,
side: Side.BUY,
},
{
tickSize: "0.01", // 来自 client.getTickSize(tokenID) 或市场对象
negRisk: false, // 来自 client.getNegRisk(tokenID) 或市场对象
},
OrderType.GTC
);
console.log(response.orderID, response.status);
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
response = client.create_and_post_order(
OrderArgs(token_id="TOKEN_ID", price=0.50, size=10, side=BUY),
options={"tick_size": "0.01", "neg_risk": False},
order_type=OrderType.GTC,
)
print(response["orderID"], response["status"])
// 无需身份验证
const readClient = new ClobClient("https://clob.polymarket.com", 137);
const book = await readClient.getOrderBook("TOKEN_ID");
console.log("最佳买价:", book.bids[0], "最佳卖价:", book.asks[0]);
const mid = await readClient.getMidpoint("TOKEN_ID");
const spread = await readClient.getSpread("TOKEN_ID");
read_client = ClobClient("https://clob.polymarket.com", chain_id=137)
book = read_client.get_order_book("TOKEN_ID")
mid = read_client.get_midpoint("TOKEN_ID")
spread = read_client.get_spread("TOKEN_ID")
const ws = new WebSocket("wss://ws-subscriptions-clob.polymarket.com/ws/market");
ws.onopen = () => {
ws.send(JSON.stringify({
type: "market",
assets_ids: ["TOKEN_ID"],
custom_feature_enabled: true,
}));
// 每 10 秒发送 PING 以保持连接
setInterval(() => ws.send("PING"), 10_000);
};
ws.onmessage = (event) => {
if (event.data === "PONG") return;
const msg = JSON.parse(event.data);
// msg.event_type: "book" | "price_change" | "last_trade_price" | "tick_size_change" | "best_bid_ask" | "new_market" | "market_resolved"
};
仅当任务需要对特定主题进行更深入了解时才阅读这些文件:
每周安装量
182
代码仓库
GitHub 星标数
58
首次出现
2026年2月19日
安全审计
安装于
codex174
kimi-cli171
github-copilot171
opencode171
cursor171
gemini-cli170
Use this skill when the user asks about or needs to build:
| API | Base URL | Auth | Purpose |
|---|---|---|---|
| CLOB | https://clob.polymarket.com | L2 for trade endpoints | Orderbook, prices, order submission |
| Gamma / Data | https://gamma-api.polymarket.com | None | Events, markets, search |
| Data API | https://data-api.polymarket.com | None | Trades, positions, user data |
| WebSocket (Market) | wss://ws-subscriptions-clob.polymarket.com/ws/market | None | Real-time orderbook |
| WebSocket (User) | wss://ws-subscriptions-clob.polymarket.com/ws/user | API creds in message | Trade/order updates |
| WebSocket (Sports) | wss://sports-api.polymarket.com/ws | None | Live scores |
| Relayer | https://relayer-v2.polymarket.com/ | Builder headers | Gasless transactions |
| Bridge | https://bridge.polymarket.com | None | Deposits/withdrawals |
| Contract | Address |
|---|---|
| USDC (USDC.e) | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
| CTF (Conditional Tokens) | 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 |
| CTF Exchange | 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E |
| Neg Risk CTF Exchange | 0xC5d563A36AE78145C45a50134d48A1215220f80a |
| Neg Risk Adapter | 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296 |
import { ClobClient, Side, OrderType } from "@polymarket/clob-client";
import { Wallet } from "ethers"; // v5.8.0
const HOST = "https://clob.polymarket.com";
const CHAIN_ID = 137;
const signer = new Wallet(process.env.PRIVATE_KEY);
// Step 1: L1 — derive API credentials
const tempClient = new ClobClient(HOST, CHAIN_ID, signer);
const apiCreds = await tempClient.createOrDeriveApiKey();
// Step 2: L2 — init trading client
const client = new ClobClient(
HOST,
CHAIN_ID,
signer,
apiCreds,
2, // signatureType: 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
"FUNDER_ADDRESS" // proxy wallet address from polymarket.com/settings
);
from py_clob_client.client import ClobClient
import os
host = "https://clob.polymarket.com"
chain_id = 137
pk = os.getenv("PRIVATE_KEY")
# Step 1: L1 — derive API credentials
temp_client = ClobClient(host, key=pk, chain_id=chain_id)
api_creds = temp_client.create_or_derive_api_creds()
# Step 2: L2 — init trading client
client = ClobClient(
host,
key=pk,
chain_id=chain_id,
creds=api_creds,
signature_type=2, # 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE
funder="FUNDER_ADDRESS",
)
| Type | Behavior | Use Case |
|---|---|---|
| GTC | Rests on book until filled or cancelled | Default limit orders |
| GTD | Active until expiration (UTC seconds). Min = now + 60 + N | Auto-expire before events |
| FOK | Fill entirely immediately or cancel | All-or-nothing market orders |
| FAK | Fill what's available, cancel rest | Partial-fill market orders |
amount = dollar amount to spendamount = number of shares to sell| Type | Value | Description |
|---|---|---|
| EOA | 0 | Standard Ethereum wallet (MetaMask). Funder is the EOA address and will need POL for gas. |
| POLY_PROXY | 1 | Custom proxy wallet for Magic Link email/Google users who exported PK from Polymarket.com. |
| GNOSIS_SAFE | 2 | Gnosis Safe multisig proxy wallet (most common). Use for any new or returning user. |
const response = await client.createAndPostOrder(
{
tokenID: "TOKEN_ID",
price: 0.50,
size: 10,
side: Side.BUY,
},
{
tickSize: "0.01", // from client.getTickSize(tokenID) or market object
negRisk: false, // from client.getNegRisk(tokenID) or market object
},
OrderType.GTC
);
console.log(response.orderID, response.status);
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
response = client.create_and_post_order(
OrderArgs(token_id="TOKEN_ID", price=0.50, size=10, side=BUY),
options={"tick_size": "0.01", "neg_risk": False},
order_type=OrderType.GTC,
)
print(response["orderID"], response["status"])
// No auth needed
const readClient = new ClobClient("https://clob.polymarket.com", 137);
const book = await readClient.getOrderBook("TOKEN_ID");
console.log("Best bid:", book.bids[0], "Best ask:", book.asks[0]);
const mid = await readClient.getMidpoint("TOKEN_ID");
const spread = await readClient.getSpread("TOKEN_ID");
read_client = ClobClient("https://clob.polymarket.com", chain_id=137)
book = read_client.get_order_book("TOKEN_ID")
mid = read_client.get_midpoint("TOKEN_ID")
spread = read_client.get_spread("TOKEN_ID")
const ws = new WebSocket("wss://ws-subscriptions-clob.polymarket.com/ws/market");
ws.onopen = () => {
ws.send(JSON.stringify({
type: "market",
assets_ids: ["TOKEN_ID"],
custom_feature_enabled: true,
}));
// Send PING every 10s to keep alive
setInterval(() => ws.send("PING"), 10_000);
};
ws.onmessage = (event) => {
if (event.data === "PONG") return;
const msg = JSON.parse(event.data);
// msg.event_type: "book" | "price_change" | "last_trade_price" | "tick_size_change" | "best_bid_ask" | "new_market" | "market_resolved"
};
Only read these when the task requires deeper detail on a specific topic:
Weekly Installs
182
Repository
GitHub Stars
58
First Seen
Feb 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex174
kimi-cli171
github-copilot171
opencode171
cursor171
gemini-cli170
lark-cli 共享规则:飞书资源操作指南与权限配置详解
31,600 周安装