-
Notifications
You must be signed in to change notification settings - Fork 7
Add pulsenetwork-data template: agent buys live data mid-task via x402 #13
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
Open
GTCC777
wants to merge
4
commits into
browser-use:main
Choose a base branch
from
GTCC777:add-pulsenetwork-data-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
17a1dce
Add pulsenetwork-data template: agent buys live data mid-task via x402
GTCC777 099e06c
pulsenetwork-data: complex template, catalog API, payment bound to th…
GTCC777 1bee395
pulsenetwork-data: pin the asset, extend the allowlist to the free to…
GTCC777 010b412
pulse_price: quote only what pulse_buy would actually pay
GTCC777 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Wallet the agent pays from. Use a THROWAWAY key holding a few USDC on Base, | ||
| # never a wallet you keep funds in. This is the only credential you need: | ||
| # PulseNetwork has no accounts, no signup and no API keys. | ||
| PULSE_WALLET_KEY=0xyour-throwaway-private-key | ||
|
|
||
| # Model for the agent (any browser-use supported provider works) | ||
| OPENAI_API_KEY=sk-your-key-here | ||
|
|
||
| # Optional spending limits, enforced in code on every paid call. | ||
| # Defaults: 0.50 per call, 2.00 per session. | ||
| PULSE_MAX_PER_CALL_USD=0.50 | ||
| PULSE_SESSION_BUDGET_USD=2.00 | ||
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,126 @@ | ||
| # Agent Buys Live Data Mid-Task (x402) | ||
|
|
||
| A browser-use agent that pays for the data it needs, per call, while it works. | ||
|
|
||
| Most agents are stuck with whatever the model already knows plus whatever a page | ||
| happens to show. This template gives the agent a wallet and three tools, so when | ||
| a task needs a fact the model cannot know (is this token a honeypot, is this | ||
| flight owed compensation, has this product been recalled) the agent finds the | ||
| right endpoint, checks the price, pays a few cents in USDC on Base, and keeps | ||
| going. | ||
|
|
||
| There is no signup, no API key and no account. The wallet is the identity. | ||
|
|
||
| ## The Tools | ||
|
|
||
| | Tool | Cost | What it does | | ||
| | --- | --- | --- | | ||
| | `pulse_catalog` | free | Searches 950+ pay-per-call endpoints. Returns each match as a complete URL with its price and its query parameters. | | ||
| | `pulse_price` | free | Reads the exact price of one endpoint from its 402 challenge. Settles nothing. | | ||
| | `pulse_buy` | the endpoint price | Pays one call with USDC on Base and returns the JSON. | | ||
|
|
||
| Typical prices run from $0.005 to $0.35 per call. The demo task costs about | ||
| $0.015. | ||
|
|
||
| ## Spending Controls | ||
|
|
||
| The limits are in the code, not in the prompt, so the agent cannot be talked | ||
| past them by a web page or by its own reasoning: | ||
|
|
||
| - **Host allowlist.** Every tool that makes an outbound request refuses any URL | ||
| that is not an https PulseNetwork endpoint, the free ones included. The agent | ||
| reads live web pages while it works, so a page must not be able to talk it | ||
| into fetching an internal address on the agent's behalf. | ||
| - **Per-call cap and session budget.** Enforced as an x402 payment policy, which | ||
| inspects the 402 challenge that is actually being signed. A price that changes | ||
| between the quote and the payment cannot slip through, because the quote is | ||
| not what authorizes the spend. | ||
| - **USDC on Base only.** The caps are counted in USDC's six decimals, so the | ||
| policy pins the asset as well as the network. The same number of atomic units | ||
| in a token with different decimals would be a different amount of money, and | ||
| an unpinned cap would not notice. | ||
| - **A lock around the buy path**, so two concurrent tool calls cannot both spend | ||
| the last of the budget. | ||
| - **The key never reaches the model.** It is read from the environment inside the | ||
| tool. The agent passes a URL and gets JSON back. | ||
|
|
||
| ## Setup | ||
|
|
||
| ### 1. Navigate to the project directory | ||
|
|
||
| ```bash | ||
| cd pulsenetwork-data | ||
| ``` | ||
|
|
||
| ### 2. Create a wallet and fund it | ||
|
|
||
| Generate a throwaway key and send it a few dollars of USDC on Base. Do not use a | ||
| wallet that holds anything you care about. A dollar or two is enough for | ||
| hundreds of calls. | ||
|
|
||
| ### 3. Configure the environment | ||
|
|
||
| ```bash | ||
| cp .env.example .env | ||
| ``` | ||
|
|
||
| Edit `.env` and set `PULSE_WALLET_KEY` and your model key. You can also lower | ||
| `PULSE_MAX_PER_CALL_USD` and `PULSE_SESSION_BUDGET_USD` from their defaults of | ||
| $0.50 and $2.00. | ||
|
|
||
| ### 4. Install dependencies | ||
|
|
||
| ```bash | ||
| uv sync | ||
| ``` | ||
|
|
||
| This installs `browser-use`, the official `x402` Python SDK with its httpx and | ||
| EVM extras, and `eth-account`. | ||
|
|
||
| ### 5. Run it | ||
|
|
||
| ```bash | ||
| uv run main.py | ||
| ``` | ||
|
|
||
| The demo task scans a real token on Robinhood Chain for rug and honeypot risk | ||
| before anyone buys it, and reports the verdict with its red and green flags. | ||
|
|
||
| ## Using It In Your Own Agent | ||
|
|
||
| Import the `tools` object and hand it to any `Agent`: | ||
|
|
||
| ```python | ||
| from main import tools | ||
|
|
||
| agent = Agent(task="...", llm=ChatOpenAI(model="gpt-4.1-mini"), tools=tools) | ||
| ``` | ||
|
|
||
| The tools compose with browser-use's own actions, so an agent can read a page, | ||
| buy a fact that the page does not contain, and act on both. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| | What you see | What it means | | ||
| | --- | --- | | ||
| | `Refused: PULSE_WALLET_KEY is not set` | No `.env`, or the key line is still the shipped placeholder. | | ||
| | `Refused: PULSE_WALLET_KEY is not a valid private key` | The key is set to something that is not a 0x private key. | | ||
| | `Refused: these tools only reach PulseNetwork endpoints` | The agent tried a URL outside PulseNetwork. Working as intended. | | ||
| | `Refused, nothing was paid: the endpoint asked for $X` | The price is above your remaining allowance. Raise the cap or pick a cheaper endpoint. | | ||
| | `Refused: the session budget is spent` | Restart the process, or raise `PULSE_SESSION_BUDGET_USD`. | | ||
| | `The payment did not complete` | Usually an unfunded wallet. Check the USDC balance on Base. | | ||
| | `Endpoint answered 400` | A missing or malformed parameter. `pulse_catalog` lists what each endpoint takes. | | ||
|
|
||
| ## Links | ||
|
|
||
| - Catalog and docs: https://pulse.theaslangroupllc.com/llms.txt | ||
| - Machine-readable search: https://pulse.theaslangroupllc.com/api/catalog?q=token+safety | ||
| - x402 protocol: https://x402.org | ||
|
|
||
| ## Disclosure | ||
|
|
||
| PulseNetwork is operated by The Aslan Group LLC, who wrote this template. The | ||
| tools only pay PulseNetwork endpoints, which is a deliberate safety limit rather | ||
| than a claim that nothing else is worth buying. The pattern itself is generic: | ||
| any x402 seller can be reached the same way by changing the host allowlist and | ||
| the catalog URL. |
Binary file not shown.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The documented env-check promise doesn't hold with this placeholder: README says leaving the key placeholder yields "Refused: PULSE_WALLET_KEY is not set", but this non-empty placeholder (
0xyour-throwaway-private-key) passes theif not keyguard and instead hits Account.from_key, producing a different message ("not a valid private key"). Either add an explicit placeholder sentinel check in main.py alongside the empty check, or correct the README refusal-table entry, so the template's placeholder and the documented refusal actually match.Prompt for AI agents