basket-create
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBasket Create
创建预测篮子
Create a new prediction basket on PolyBaskets via .
vara-wallet通过在PolyBaskets上创建新的预测篮子。
vara-walletSetup
环境设置
MAINNET ONLY. Run before anything else. NEVER switch to testnet — there are no contracts there.
vara-wallet config set network mainnetbash
vara-wallet config set network mainnet
BASKET_MARKET="0x702395d43248eaa5f1fd4d9eadadc75b0fb1c7c5ae9ea20bf31375fd4358f403"
_PB="${POLYBASKETS_SKILLS_DIR:-skills}"
IDL="$_PB/idl/polymarket-mirror.idl"Ensure you have a wallet and VARA for gas:
bash
vara-wallet wallet list
vara-wallet balance仅支持主网。在进行任何操作前,先运行。切勿切换到测试网——测试网没有部署相关合约。
vara-wallet config set network mainnetbash
vara-wallet config set network mainnet
BASKET_MARKET="0x702395d43248eaa5f1fd4d9eadadc75b0fb1c7c5ae9ea20bf31375fd4358f403"
_PB="${POLYBASKETS_SKILLS_DIR:-skills}"
IDL="$_PB/idl/polymarket-mirror.idl"确保你拥有钱包和用于支付Gas费用的VARA:
bash
vara-wallet wallet list
vara-wallet balanceFinding Polymarket Markets
查找Polymarket市场
Search for active markets on Polymarket to use as basket items. Use to get the most active markets, and add to find markets ending soon:
order=volume24hr&ascending=falseend_date_maxbash
undefined在Polymarket上搜索活跃市场作为篮子项目。使用获取交易量最高的市场,添加筛选即将结束的市场:
order=volume24hr&ascending=falseend_date_maxbash
undefinedFetch high-volume markets ending within 48 hours (fastest resolution)
获取48小时内结束的高交易量市场(最快解析)
end_date_min=now filters out markets that already ended (closed=false does NOT filter these!)
end_date_min=now 会过滤掉已结束的市场(closed=false 无法过滤这些市场!)
curl -s "https://gamma-api.polymarket.com/markets?closed=false&order=volume24hr&ascending=false&end_date_min=$(date -u +%Y-%m-%dT%H:%M:%SZ)&end_date_max=$(date -u -v+48H +%Y-%m-%dT%H:%M:%SZ)&limit=20"
curl -s "https://gamma-api.polymarket.com/markets?closed=false&order=volume24hr&ascending=false&end_date_min=$(date -u +%Y-%m-%dT%H:%M:%SZ)&end_date_max=$(date -u -v+48H +%Y-%m-%dT%H:%M:%SZ)&limit=20"
On Linux use: date -u -d '+48 hours' +%Y-%m-%dT%H:%M:%SZ
Linux系统请使用:date -u -d '+48 hours' +%Y-%m-%dT%H:%M:%SZ
Or fetch all active markets sorted by volume (still filter out ended ones!)
或者获取所有按交易量排序的活跃市场(仍需过滤已结束的市场!)
curl -s "https://gamma-api.polymarket.com/markets?closed=false&order=volume24hr&ascending=false&end_date_min=$(date -u +%Y-%m-%dT%H:%M:%SZ)&limit=20"
**WARNING: `closed=false` does NOT mean the market hasn't ended.** Markets past their `endDate` still appear. Always use `end_date_min` set to the current time, or check `endDate > now` before selecting a market.
Parse with jq:
```bashcurl -s "https://gamma-api.polymarket.com/markets?closed=false&order=volume24hr&ascending=false&end_date_min=$(date -u +%Y-%m-%dT%H:%M:%SZ)&limit=20"
**警告:`closed=false`不代表市场未结束**。超过`endDate`的市场仍会显示。务必将`end_date_min`设置为当前时间,或在选择市场前检查`endDate > now`。
使用jq解析结果:
```bashShow market id, question, YES/NO prices, and hours remaining
显示市场ID、问题、YES/NO价格以及剩余时长
curl -s "https://gamma-api.polymarket.com/markets?closed=false&order=volume24hr&ascending=false&end_date_min=$(date -u +%Y-%m-%dT%H:%M:%SZ)&limit=20"
| jq '[.[] | {id, question, yes: (.outcomePrices | fromjson | .[0]), no: (.outcomePrices | fromjson | .[1]), endDate, liquidity}]'
| jq '[.[] | {id, question, yes: (.outcomePrices | fromjson | .[0]), no: (.outcomePrices | fromjson | .[1]), endDate, liquidity}]'
**CRITICAL: `outcomePrices` is a JSON-encoded string**, not an array. The API returns `"[\"0.52\", \"0.48\"]"` (a string), not `["0.52", "0.48"]` (an array).
- jq: `.outcomePrices | fromjson | .[0]` for YES price
- Python: `json.loads(m['outcomePrices'])[0]`
- Node.js: `JSON.parse(m.outcomePrices)[0]`
- **Wrong:** `m['outcomePrices'][0]` gives `[` (first character of the string), NOT the price!
**Important:** `poly_market_id` is the **numeric Polymarket ID** (e.g. `"540816"`), not the hex `conditionId`. Use the `id` field from the API response.
**The `slug` field is already included in every market response.** Do NOT re-fetch markets to look up slugs — use the `slug` from the same response where you got the `id`. If you need details for a specific market ID, fetch it directly:
```bash
curl -s "https://gamma-api.polymarket.com/markets/540816"curl -s "https://gamma-api.polymarket.com/markets?closed=false&order=volume24hr&ascending=false&end_date_min=$(date -u +%Y-%m-%dT%H:%M:%SZ)&limit=20"
| jq '[.[] | {id, question, yes: (.outcomePrices | fromjson | .[0]), no: (.outcomePrices | fromjson | .[1]), endDate, liquidity}]'
| jq '[.[] | {id, question, yes: (.outcomePrices | fromjson | .[0]), no: (.outcomePrices | fromjson | .[1]), endDate, liquidity}]'
**关键提示:`outcomePrices`是JSON编码的字符串**,而非数组。API返回的是`"[\"0.52\", \"0.48\"]"`(字符串),而非`["0.52", "0.48"]`(数组)。
- jq方式:`.outcomePrices | fromjson | .[0]` 获取YES价格
- Python方式:`json.loads(m['outcomePrices'])[0]`
- Node.js方式:`JSON.parse(m.outcomePrices)[0]`
- **错误用法:** `m['outcomePrices'][0]` 会返回`[`(字符串的第一个字符),而非价格!
**重要说明:** `poly_market_id`是**数字格式的Polymarket ID**(例如`"540816"`),而非十六进制的`conditionId`。请使用API响应中的`id`字段。
**每个市场响应中已包含`slug`字段**。请勿重新获取市场信息以查找slug——直接使用获取`id`的同一响应中的`slug`。如果需要特定市场ID的详细信息,可直接获取:
```bash
curl -s "https://gamma-api.polymarket.com/markets/540816"Pre-Check
预检查
Most deployments run in CHIP-only mode. Check VARA status:
bash
vara-wallet call $BASKET_MARKET BasketMarket/IsVaraEnabled --args '[]' --idl $IDLIf false (typical), create a basket (CHIP lane).
"Bet"大多数部署仅运行CHIP模式。检查VARA状态:
bash
vara-wallet call $BASKET_MARKET BasketMarket/IsVaraEnabled --args '[]' --idl $IDL如果返回false(通常情况),则创建类型的篮子(CHIP通道)。
"Bet"Validation Rules
验证规则
Before sending the transaction, validate locally:
| Rule | Constraint |
|---|---|
| Name | Non-empty, max 48 characters |
| Description | Max 256 characters |
| Items | 1 to 10 items |
| Weights | All |
| No duplicates | Same |
| poly_market_id | Max 128 characters |
| poly_slug | Max 128 characters |
| asset_kind | |
发送交易前,请在本地验证以下规则:
| 规则 | 约束条件 |
|---|---|
| 名称 | 非空,最多48个字符 |
| 描述 | 最多256个字符 |
| 项目数量 | 1到10个 |
| 权重 | 所有 |
| 无重复 | 相同的 |
| poly_market_id | 最多128个字符 |
| poly_slug | 最多128个字符 |
| asset_kind | |
Create Basket
创建篮子
Arguments
参数
CreateBasket(name: str, description: str, items: vec BasketItem, asset_kind: BasketAssetKind) -> u64Each :
BasketItemjson
{
"poly_market_id": "540816",
"poly_slug": "will-btc-hit-100k",
"weight_bps": 5000,
"selected_outcome": "YES"
}- — the numeric Polymarket ID from the API
poly_market_idfield (e.g.id), NOT the hex conditionId"540816" - — weight in basis points. 50% = 5000, 30% = 3000, etc. All weights must sum to 10000 (= 100%)
weight_bps
CreateBasket(name: str, description: str, items: vec BasketItem, asset_kind: BasketAssetKind) -> u64每个的格式:
BasketItemjson
{
"poly_market_id": "540816",
"poly_slug": "will-btc-hit-100k",
"weight_bps": 5000,
"selected_outcome": "YES"
}- — 来自API
poly_market_id字段的数字格式Polymarket ID(例如id),而非十六进制的conditionId"540816" - — 以基点为单位的权重。50% = 5000,30% = 3000,以此类推。所有权重总和必须为10000(=100%)
weight_bps
Example: 3-item basket
示例:3个项目的篮子
bash
vara-wallet --account agent call $BASKET_MARKET BasketMarket/CreateBasket --voucher $VOUCHER_ID \
--args '[
"AI Regulation Bundle",
"Outcomes related to AI policy",
[
{
"poly_market_id": "540816",
"poly_slug": "ai-regulation-2025",
"weight_bps": 4000,
"selected_outcome": "YES"
},
{
"poly_market_id": "540817",
"poly_slug": "openai-ipo-2025",
"weight_bps": 3500,
"selected_outcome": "YES"
},
{
"poly_market_id": "540818",
"poly_slug": "eu-ai-act-enforcement",
"weight_bps": 2500,
"selected_outcome": "NO"
}
],
"Bet"
]' \
--idl $IDLWeights: 40% + 35% + 25% = 100% (4000 + 3500 + 2500 = 10000 bps).
bash
vara-wallet --account agent call $BASKET_MARKET BasketMarket/CreateBasket --voucher $VOUCHER_ID \
--args '[
"AI Regulation Bundle",
"Outcomes related to AI policy",
[
{
"poly_market_id": "540816",
"poly_slug": "ai-regulation-2025",
"weight_bps": 4000,
"selected_outcome": "YES"
},
{
"poly_market_id": "540817",
"poly_slug": "openai-ipo-2025",
"weight_bps": 3500,
"selected_outcome": "YES"
},
{
"poly_market_id": "540818",
"poly_slug": "eu-ai-act-enforcement",
"weight_bps": 2500,
"selected_outcome": "NO"
}
],
"Bet"
]' \
--idl $IDL权重:40% + 35% + 25% = 100%(4000 + 3500 + 2500 = 10000基点)。
Parse Result
解析结果
The call returns a basket ID:
u64bash
RESULT=$(vara-wallet --account agent call $BASKET_MARKET BasketMarket/CreateBasket --voucher $VOUCHER_ID \
--args '[...]' --idl $IDL)
BASKET_ID=$(echo $RESULT | jq -r '.result // .ok // .')
echo "Created basket: $BASKET_ID"调用会返回一个类型的篮子ID:
u64bash
RESULT=$(vara-wallet --account agent call $BASKET_MARKET BasketMarket/CreateBasket --voucher $VOUCHER_ID \
--args '[...]' --idl $IDL)
BASKET_ID=$(echo $RESULT | jq -r '.result // .ok // .')
echo "Created basket: $BASKET_ID"After Creation
创建完成后
- Verify:
vara-wallet call $BASKET_MARKET BasketMarket/GetBasket --args "[$BASKET_ID]" --idl $IDL - Place a bet: see
../basket-bet/SKILL.md - Share the basket ID for others to bet on
- 验证:
vara-wallet call $BASKET_MARKET BasketMarket/GetBasket --args "[$BASKET_ID]" --idl $IDL - 投注:查看
../basket-bet/SKILL.md - 分享篮子ID供他人投注
Common Errors
常见错误
| Error | Cause | Fix |
|---|---|---|
| Weights don't sum to 100% | Adjust weight_bps so they sum to 10000 (= 100%) |
| Empty items array | Add at least 1 item |
| More than 10 items | Remove items |
| Same market+outcome twice | Remove duplicate |
| VARA mode off | Use |
| Name > 48 chars | Shorten name |
See for all error variants.
../references/error-codes.md| 错误 | 原因 | 修复方案 |
|---|---|---|
| 权重总和不为100% | 调整weight_bps使其总和为10000(=100%) |
| 项目数组为空 | 添加至少1个项目 |
| 项目数量超过10个 | 删除部分项目 |
| 同一市场+结果出现两次 | 删除重复项 |
| VARA模式未开启 | 使用 |
| 名称超过48个字符 | 缩短名称 |
所有错误变体请查看。
../references/error-codes.md