Skip to content

feat: add build-energy-grid example with market simulation - #467

Open
ABEEGOLD wants to merge 1 commit into
nirium-protocol:mainfrom
ABEEGOLD:energy-smart-grid
Open

ABEEGOLD wants to merge 1 commit into
nirium-protocol:mainfrom
ABEEGOLD:energy-smart-grid

Conversation

@ABEEGOLD

Copy link
Copy Markdown

Closes #360

Build with Nirium: Energy Smart Grid over x402

What changed and why

SUMMARY

Added examples/build-energy-grid/, a testnet-only energy market example. Two simulated solar producers sell one-kWh allocations through their own x402Serve routes; a storage agent selects the cheapest offer and pays with initX402. A daily-budget policy allows three purchases and rejects the next before signing.

The example includes CLI key generation and market startup, price selection, transaction-hash extraction, and offline tests for the policy, market model, and settlement responses. Setup and key-role instructions are in the README.

Package(s) touched

  • nirium (TypeScript SDK)
  • nirium (Python SDK)
  • nirium-cli
  • nirium-mcp
  • An example
  • Documentation only

How this was tested

All tests were run offline; no network payments or testnet accounts were used.

  • npm test — passed, 8 tests
  • npm run typecheck — passed
  • npm run build in packages/sdk — passed
  • git diff --check — passed
  • No lint script is configured for this example.

Live testnet transaction hashes and the required short demo video have not yet been added. The README marks the transaction evidence as pending an owner-run testnet demo.

Checklist

  • Ran the example’s tests and type-check; no lint script is configured
  • No secret keys were added; the live key-generation command was not run
  • AI-assisted commit includes the required co-author trailer — no commit was created.

- Created package.json for the build-energy-grid example with necessary dependencies and scripts.
- Implemented CLI functionality in src/cli.ts for generating keys and running the market.
- Developed DailyBudgetPolicy in src/daily-budget.ts to manage daily spending limits for energy producers.
- Defined market model in src/market-model.ts, including energy offers and pricing logic.
- Built market logic in src/market.ts to handle producer applications and payment processing.
- Added payment response handling in src/payment-response.ts to extract transaction hashes from responses.
- Implemented tests for daily budget policy, market model, and payment response to ensure functionality.
- Configured TypeScript settings in tsconfig.json for the example project.
@drips-wave

drips-wave Bot commented Nov 22, 2026

Copy link
Copy Markdown

@ABEEGOLD Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build with Nirium: an energy smart grid, panels and storage paying each other over x402 on testnet

1 participant