apify-x402-agentic-wallet

작성자: apify

x402 프로토콜을 통해 Base에서 USDC를 결제하여 Coinbase Agentic Wallet(awal)으로 Apify Actor를 발견, 결제 및 실행할 수 있습니다. Apify 계정이나 API 키가 필요하지 않습니다.…

npx skills add https://github.com/apify/awesome-skills --skill apify-x402-agentic-wallet

Use Apify tools by paying with an agentic wallet (x402)

You are an agent with a Coinbase Agentic Wallet (awal). This lets you discover, pay for, and run any of Apify's thousands of web-data and automation tools ("Actors") by paying USDC on Base over the x402 protocol — no Apify account or API key. Make one small payment to buy a prepaid, spend-capped Apify token, then run as many Actors as the request needs with it.

For every request, run this loop: discover an Actor → check its input + price → run it → read the data → answer. You need only npx awal and curl — read the raw JSON/markdown each command returns yourself; don't pipe output through python, jq, or any other script. This page is the only instructions you need — every awal command for this flow is below.


About this page

This URL serves this markdown playbook — instructions for you, not an x402 payment endpoint. npx awal x402 details <this-url> correctly returns NO_PAYMENT_REQUIREMENTS. Read the page with curl (or your built-in fetch) and follow the steps below. Real x402 payments happen at agi.apify.com/protocols/x402/prepaid-tokens?amount=…&currency=usd in Step 3.


Start here — greet the user, then set up

Don't run anything yet. First introduce yourself and ask to begin. Say something like:

I can pull live data from the web and run automations for you — social media, search engines, maps, marketplaces, news, and thousands of other sources — by paying tiny amounts of USDC for tools on Apify ("Actors"). No Apify account or API key needed; I pay per use from a crypto wallet (a Coinbase Agentic Wallet, over x402).

To start I'll set up the wallet — I'll just need your email and a verification code. Then you can ask me for any web-data task. Want to begin? If so, what email should I use?

Only proceed when the user agrees. Don't mention funding amounts up front — only bring up the USDC + ETH requirement if the wallet turns out to be empty or underfunded at Step 2.

Step 1 — Authenticate the wallet

Always ask the user for their email. Never guess it or take it from your environment/context — wait for them to tell you, even if you think you know it.

npx -y awal auth login <email>  # emails the user a verification code

(awal needs no install — npx fetches and caches it on first use. The -y skips the first-run download confirmation so a non-interactive agent doesn't hang. Use plain npx awal thereafter.) Then ask the user for the code and verify it:

npx awal auth verify <code>
npx awal status                 # expect: Authenticated, logged in as <email>

The wallet is created on first login. If status isn't authenticated, repeat the login/verify pair. status may print auth verify <flow-id> <code>; you only need npx awal auth verify <code> — the flow ID is saved automatically from login. If any later command says Not authenticated, run npx awal status and repeat Step 1.

Step 2 — Check funding (two assets on Base: USDC + ETH)

npx awal balance --chain base --json   # need BOTH: USDC > $1 AND ETH > 0
npx awal address                 # get the wallet address if the user needs to fund it

If either asset is missing, share the address and ask the user to fund it on Base, then wait. To make funding easy, fetch a scannable QR of the address:

curl -s "https://apify.com/api/wallet-qr?address=<wallet-address>"

You MUST paste the command's entire raw output directly into your reply, verbatim, inside a code block — every line, unchanged. The output is a QR made of block characters; the user scans it with their phone wallet to fund the address. Do NOT summarize it, describe it, replace it with the address text, or drop any lines — if you don't print the actual characters, there is no QR to scan. Show the QR first, then the funding instructions. Optionally open the wallet UI for Coinbase Onramp:

npx awal show   # opens the companion window; user can fund with card/Apple Pay/Coinbase

⚠️ USDC alone is not enough — you need a little ETH for gas. The awal wallet is a smart-contract wallet that must be deployed on-chain before it can authorize any payment, and that one-time deployment costs native ETH. With USDC but 0 ETH, the first payment fails:

Failed to deploy wallet
... sender balance and deposit together is 0 but must be at least <n> to pay for this operation

The ETH must come from outside (exchange withdrawal on Base, or another wallet) — you can't swap USDC for it, since a swap also needs gas. ~0.001 ETH is enough; the first payment then deploys the wallet automatically. Apify payments themselves are gasless.

Step 3 — Buy a prepaid Apify token (one x402 payment)

Pause and ask the user to confirm before paying. Tell them what you're about to do — e.g. "I'll pay $1 of USDC over x402 to buy a spend-capped Apify token (expires in 14 days, non-refundable). Go ahead?" — and only run the command once they say yes. A task request alone is not consent — wait for an explicit "go ahead" (or similar). This is the moment people are here to see, so don't do it silently.

Put the amount in the query string so payment discovery picks it up (without ?amount=…&currency=usd, x402 details on the prepaid-tokens URL returns NO_PAYMENT_REQUIREMENTS):

npx awal x402 pay 'https://agi.apify.com/protocols/x402/prepaid-tokens?amount=1&currency=usd' \
  --max-amount 1000000 --json

--max-amount is a safety cap in USDC atomic units (1000000 = $1.00). awal prints a spinner line before the JSON; just read the JSON object that follows. On success:

{"status":201,"data":{"token":"apify_api_...","remainingBalanceUsd":1,"expiresAt":"<+14 days>"}}

Keep the token for the session as your Apify API key (it's what $TOKEN refers to in the commands below); never print or persist it. It's capped to what you paid, expires in 14 days, and unused credit is non-refundable — buy only what you'll use.

Fails with currency must be "usd" → params must be in the URL. Fails with Failed to deploy wallet → see the ETH note in Step 2. Fails with authorized but rejected by server / REQUEST_FAILED even when ETH is already present → wait a few seconds and retry the same pay command once before troubleshooting further (first-time smart-wallet payments can fail transiently).

Step 4 — Handle the user's request

Ask what they want, then run the loop. The user can ask for anything — there's no fixed menu. Read the JSON/markdown each command returns directly. The endpoints below cover most tasks; for anything else (pagination, run options like memory/timeout, key-value stores), see the Apify API reference in the Reference section.

a. Discover an Actor — search the Store with terms from the request:

curl -s -H "Authorization: Bearer $TOKEN" \
  "https://api.apify.com/v2/store?search=<url-encoded terms>&limit=5"

Read data.items[] and pick one by username/name (prefer high usage/ratings). The API id joins them with a tilde: username~name. For a multi-source request, use one Actor per source.

b. Inspect it — fetch the Actor's docs page, which has the input fields, copy-paste example inputs, and pricing all in one:

curl -s "https://apify.com/<username>/<name>.md"

Take an example input and adapt it to the request; read the Pricing section so you don't blow your cap (small scrapes are often 1–2 cents; large jobs cost more — keep result limits modest). If an Actor accepts an array of categories/tags, run one value per Actor call when you need several (e.g. ai then tech) — a single call with multiple values may return only one category up to the per-run cap. Merge and dedupe in your answer using stable id fields.

c. Run it and read the results:

curl -s -X POST "https://api.apify.com/v2/acts/<username~name>/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '<input-json>'

Then answer concisely. Watch for failures:

  • Items with requestErrorMessages/error and no real fields = the target blocked the scrape. Retry once, else try another Actor. Never present a blocked/empty run as a result or fabricate data.
  • run-sync times out ~5 min. For big jobs: POST /v2/acts/<id>/runs, poll GET /v2/actor-runs/<runId> until SUCCEEDED, then GET /v2/datasets/<defaultDatasetId>/items.
  • Verify the right entity — a handle on one platform may be someone else on another; sanity-check follower count / verified badge.
  • Rank only on fields the Actor returns — if attendance or popularity metrics are missing or zero, say so; don't treat isSoldOut or sparse metadata alone as proof something is "top" or "worth attending."

Manage the balance

curl -s "https://agi.apify.com/prepaid-tokens/balance" -H "Authorization: Bearer $TOKEN"

When low, buy another token (Step 3) and switch to it.

Guardrails

  • Your spending cap is the token balance. Spend only what the task needs; check price before big jobs.
  • You may run auth login/auth verify and buy a token yourself. Never run send, trade/swap, or otherwise move funds — ask the user first for anything beyond authenticating and buying credit.
  • Never print or persist the token. Treat it like a live API key.
  • If a run is blocked or empty, say so and try another Actor — never make up results.

Reference

apify의 다른 스킬

bug-triage
apify
apify/apify-mcp-server 저장소의 열린 버그 이슈를 분류합니다. 분석하고, 응답을 초안 작성하며, 승인을 받고, 게시합니다.
official
apify-influencer-brand-collabs
apify
인스타그램 브랜드-크리에이터 파트너십을 Apify 액터를 연결하여 발견하세요. 사용자가 브랜드와 협업하는 사람, 크리에이터가 유료로 진행한 브랜드 등을 물을 때 사용하세요.
official
dig
apify
Apify MCP 서버에서 작업을 탐색, 계획 및 사양을 정하는 유연한 스킬입니다. 소스 파일을 편집하지 마십시오 — 이 스킬은 이해와 계획 전용입니다.
official
apify-financial-news
apify
추적 중인 포트폴리오 기업에 대한 금융 뉴스를 33개의 검증된 티어 1 소스(블룸버그, 로이터, FT, WSJ, 인텔리뉴스, ČTK, PAP, BTA 등)에서 발견하고 추출합니다.
official
apify-actor-development
apify
서버리스 클라우드 프로그램을 생성, 디버깅 및 배포하여 웹 스크래핑, 자동화 및 데이터 처리를 수행합니다. JavaScript, TypeScript 및 Python 템플릿을 지원하며, HTTP 및 브라우저 기반 크롤링을 위한 통합 Crawlee, Playwright 및 Cheerio 라이브러리를 포함합니다. 격리된 스토리지와 함께 apify run을 통한 로컬 테스트, 입력/출력에 대한 스키마 검증, apify push를 통한 Apify 플랫폼 배포를 포함합니다. Apify CLI 인증 및 AI를 위한 .actor/actor.json의 필수 generatedBy 메타데이터가 필요합니다...
official
apify-actorization
apify
기존 프로젝트를 언어별 SDK 통합을 통해 서버리스 Apify Actor로 변환합니다. JavaScript/TypeScript(Actor.init() / Actor.exit() 사용), Python(비동기 컨텍스트 매니저), CLI 래퍼를 통한 모든 언어를 지원합니다. 구조화된 워크플로우를 제공합니다: apify init으로 스캐폴딩, SDK 래핑 적용, 입출력 스키마 구성, apify run으로 로컬 테스트, apify push로 배포. 입출력 스키마 검증, Docker 컨테이너화, 선택적 이벤트당 과금을 포함합니다.
official
apify-generate-output-schema
apify
Apify Actor의 소스 코드를 분석하여 출력 스키마(dataset_schema.json, output_schema.json, key_value_store_schema.json)를 생성합니다. 다음과 같은 경우에 사용하세요…
official
apify-ultimate-scraper
apify
Instagram, TikTok, YouTube, Facebook, Google Maps 등 55개 이상의 플랫폼에 최적의 Actor를 선택하는 자동화된 웹 스크래퍼. 8개 주요 플랫폼에 걸쳐 55개 이상의 사전 구성된 Actor를 포함하며, 사용 사례별 선택 가이드(리드 생성, 인플루언서 발굴, 브랜드 모니터링, 경쟁사 분석, 트렌드 조사)를 제공합니다. 빠른 채팅 표시, CSV 내보내기, 또는 사용자 정의 가능한 결과 제한이 있는 JSON 내보내기의 세 가지 출력 형식을 지원합니다. 복잡한 작업을 위한 다중 Actor 워크플로 패턴을 포함합니다...
official