Repository navigation
docs: Full x402 usage example (Apify via AGI prepaid token) #486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4676481
docs: Turn the Apify x402 section into a full x402 usage example
claude 275b7bc
docs: Say what Apify is in the full x402 usage example
claude c4a2cb3
docs: Buy a $1 token in the full x402 usage example
claude 0a2afc0
Add VHS tape for the full x402 usage example
claude a62e1f9
docs: Explain why the x402 example runs mcpc x402 after init
claude cdbe39c
Add VHS recording of the full x402 usage example
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # mcpc x402 — pay for an MCP server with x402: wallet → challenge → sign → prepaid token → connect → call | ||
| # | ||
| # X402_DEMO_HOME=<mcpc home with a funded wallet> vhs x402.tape | ||
| # | ||
| # Follows the "Full x402 usage example" in README.md against agi.apify.com and | ||
| # mcp.apify.com. Each render makes a REAL payment of 1 USDC on Base mainnet, so | ||
| # the wallet in $X402_DEMO_HOME must hold at least 1 USDC (no ETH needed: the | ||
| # exact scheme is a gasless EIP-3009 signature). The minted token is written to | ||
| # $X402_DEMO_HOME/token (never shown on screen) so it can be reused or checked. | ||
|
|
||
| Output x402.gif | ||
|
|
||
| Require mcpc | ||
| Require jq | ||
| Require curl | ||
|
|
||
| Set Shell "bash" | ||
| Set FontFamily "JetBrains Mono" | ||
| Set FontSize 16 | ||
| Set Width 1280 | ||
| Set Height 760 | ||
| Set Padding 20 | ||
| Set TypingSpeed 30ms | ||
| Set Theme "Catppuccin Mocha" | ||
| Set WindowBar Colorful | ||
| Set WindowBarSize 32 | ||
| Set BorderRadius 8 | ||
| Set CursorBlink true | ||
| Set Framerate 24 | ||
|
|
||
| # Hidden setup: the funded wallet's home, prompt styling, and a PROMPT_COMMAND | ||
| # that saves the token off-screen once it exists. | ||
| Hide | ||
| Type 'export MCPC_HOME_DIR="$X402_DEMO_HOME"' | ||
| Enter | ||
| Type `export PROMPT_COMMAND='[ -n "$TOKEN" ] && printf %s "$TOKEN" > "$MCPC_HOME_DIR/token"'` | ||
| Enter | ||
| Type 'export PS1="\[\e[1;38;2;25;230;77m\]$\[\e[0m\] \[\e[1;97m\]"' | ||
| Enter | ||
| Type "trap 'tput sgr0' DEBUG" | ||
| Enter | ||
| Type "clear" | ||
| Enter | ||
| Sleep 1000ms | ||
| Show | ||
|
|
||
| Type "mcpc x402" | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 5000ms | ||
|
|
||
| Enter | ||
| Type "URL='https://agi.apify.com/protocols/x402/prepaid-tokens?amount=1¤cy=usd'" | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 500ms | ||
|
|
||
| Type `REQ=$(curl -s -D - -o /dev/null "$URL" | awk -F': ' 'tolower($1)=="payment-required"{print $2}' | tr -d '\r\n')` | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 2000ms | ||
|
|
||
| Enter | ||
| Type `echo "$REQ" | base64 -d | jq '.accepts[0]'` | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 4000ms | ||
|
|
||
| Enter | ||
| Type `SIG=$(mcpc x402 sign "$REQ" --scheme exact --json | jq -r .paymentSignature)` | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 2000ms | ||
|
|
||
| Type `TOKEN=$(curl -s -H "PAYMENT-SIGNATURE: $SIG" "$URL" | jq -r .token)` | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 8000ms | ||
|
|
||
| Enter | ||
| Type `mcpc connect mcp.apify.com @apify --header "Authorization: Bearer $TOKEN"` | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 9000ms | ||
|
|
||
| Enter | ||
| Type `mcpc @apify tools-call search-actors keywords:="Google Maps" limit:=3` | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 9000ms | ||
|
|
||
| Enter | ||
| Type 'curl -s -H "Authorization: Bearer $TOKEN" https://agi.apify.com/prepaid-tokens/balance | jq' | ||
| Sleep 300ms | ||
| Enter | ||
| Sleep 5000ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.