basket-create

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Basket Create

创建预测篮子

Create a new prediction basket on PolyBaskets via
vara-wallet
.
通过
vara-wallet
在PolyBaskets上创建新的预测篮子。

Setup

环境设置

MAINNET ONLY. Run
vara-wallet config set network mainnet
before anything else. NEVER switch to testnet — there are no contracts there.
bash
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 mainnet
。切勿切换到测试网——测试网没有部署相关合约。
bash
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 balance

Finding Polymarket Markets

查找Polymarket市场

Search for active markets on Polymarket to use as basket items. Use
order=volume24hr&ascending=false
to get the most active markets, and add
end_date_max
to find markets ending soon:
bash
undefined
在Polymarket上搜索活跃市场作为篮子项目。使用
order=volume24hr&ascending=false
获取交易量最高的市场,添加
end_date_max
筛选即将结束的市场:
bash
undefined

Fetch 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!)

或者获取所有按交易量排序的活跃市场(仍需过滤已结束的市场!)


**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:
```bash

**警告:`closed=false`不代表市场未结束**。超过`endDate`的市场仍会显示。务必将`end_date_min`设置为当前时间,或在选择市场前检查`endDate > now`。

使用jq解析结果:
```bash

Show 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}]'

**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}]'

**关键提示:`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 $IDL
If false (typical), create a
"Bet"
basket (CHIP lane).
大多数部署仅运行CHIP模式。检查VARA状态:
bash
vara-wallet call $BASKET_MARKET BasketMarket/IsVaraEnabled --args '[]' --idl $IDL
如果返回false(通常情况),则创建
"Bet"
类型的篮子(CHIP通道)。

Validation Rules

验证规则

Before sending the transaction, validate locally:
RuleConstraint
NameNon-empty, max 48 characters
DescriptionMax 256 characters
Items1 to 10 items
WeightsAll
weight_bps
must sum to exactly 10000 (= 100%). Each weight is in basis points: 50% = 5000, 30% = 3000, etc.
No duplicatesSame
poly_market_id
+
selected_outcome
cannot appear twice
poly_market_idMax 128 characters
poly_slugMax 128 characters
asset_kind
"Vara"
or
"Bet"
发送交易前,请在本地验证以下规则:
规则约束条件
名称非空,最多48个字符
描述最多256个字符
项目数量1到10个
权重所有
weight_bps
的总和必须恰好为10000(=100%)。每个权重以基点为单位:50% = 5000,30% = 3000,以此类推。
无重复相同的
poly_market_id
+
selected_outcome
不能出现两次
poly_market_id最多128个字符
poly_slug最多128个字符
asset_kind
"Vara"
"Bet"

Create Basket

创建篮子

Arguments

参数

CreateBasket(name: str, description: str, items: vec BasketItem, asset_kind: BasketAssetKind) -> u64
Each
BasketItem
:
json
{
  "poly_market_id": "540816",
  "poly_slug": "will-btc-hit-100k",
  "weight_bps": 5000,
  "selected_outcome": "YES"
}
  • poly_market_id
    — the numeric Polymarket ID from the API
    id
    field (e.g.
    "540816"
    ), NOT the hex conditionId
  • weight_bps
    — weight in basis points. 50% = 5000, 30% = 3000, etc. All weights must sum to 10000 (= 100%)
CreateBasket(name: str, description: str, items: vec BasketItem, asset_kind: BasketAssetKind) -> u64
每个
BasketItem
的格式:
json
{
  "poly_market_id": "540816",
  "poly_slug": "will-btc-hit-100k",
  "weight_bps": 5000,
  "selected_outcome": "YES"
}
  • poly_market_id
    — 来自API
    id
    字段的数字格式Polymarket ID(例如
    "540816"
    ),而非十六进制的conditionId
  • weight_bps
    — 以基点为单位的权重。50% = 5000,30% = 3000,以此类推。所有权重总和必须为10000(=100%)

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 $IDL
Weights: 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
u64
basket ID:
bash
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"
调用会返回一个
u64
类型的篮子ID:
bash
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

常见错误

ErrorCauseFix
InvalidWeights
Weights don't sum to 100%Adjust weight_bps so they sum to 10000 (= 100%)
NoItems
Empty items arrayAdd at least 1 item
TooManyItems
More than 10 itemsRemove items
DuplicateBasketItem
Same market+outcome twiceRemove duplicate
VaraDisabled
VARA mode offUse
"Bet"
asset_kind instead
NameTooLong
Name > 48 charsShorten name
See
../references/error-codes.md
for all error variants.
错误原因修复方案
InvalidWeights
权重总和不为100%调整weight_bps使其总和为10000(=100%)
NoItems
项目数组为空添加至少1个项目
TooManyItems
项目数量超过10个删除部分项目
DuplicateBasketItem
同一市场+结果出现两次删除重复项
VaraDisabled
VARA模式未开启使用
"Bet"
作为asset_kind
NameTooLong
名称超过48个字符缩短名称
所有错误变体请查看
../references/error-codes.md