Skip to content

feat: LitkeyPaymentGateway contract + Hardhat project#373

Open
clawdbot-glitch003 wants to merge 1 commit into
nextfrom
glitch003/lit-payments-litkey-contract
Open

feat: LitkeyPaymentGateway contract + Hardhat project#373
clawdbot-glitch003 wants to merge 1 commit into
nextfrom
glitch003/lit-payments-litkey-contract

Conversation

@clawdbot-glitch003
Copy link
Copy Markdown
Collaborator

Summary

  • First slice of Feature 2 from plans/lit-payments-app.md: the on-chain piece the LITKEY → Stripe credit listener and payment page will both depend on.
  • New self-contained Hardhat project at lit-payments/contracts/ (Solidity 0.8.28, matches the existing lit_node_express conventions). LitkeyPaymentGateway is immutable — pay(amount, wallet) pulls LITKEY via SafeERC20.safeTransferFrom, forwards to the treasury (company Safe on Base), and emits Payment(indexed wallet, indexed payer, amount). Reverts on zero treasury / wallet / amount via custom errors.
  • 12 Hardhat tests covering deploy guards, every revert path, happy-path balance + event assertions, multi-payer attribution, cross-wallet payments, and indexed-topic filtering.
  • scripts/deploy.ts deploys + (optionally) Basescan-verifies. README walks through Base Sepolia → mainnet.
  • New CI workflow .github/workflows/lit-payments-contracts-ci.yml runs hardhat compile + hardhat test on PRs touching lit-payments/contracts/.

Test plan

  • npm test in lit-payments/contracts/ — 12 / 12 passing locally
  • npx hardhat compile clean
  • Deploy to Base Sepolia with a throwaway treasury, confirm Payment event shape via Basescan (manual step before merging)

Follow-up PRs (Feature 2 remaining)

  1. CoinGecko rate poller + litkey_rate schema + admin rate-override UI
  2. Alchemy WSS listener + 60s reconciliation poll + litkey_payments schema
  3. Wagmi /payWithLitkey payment page + dashboard "Pay with tokens" link

First slice of Feature 2 from plans/lit-payments-app.md — the on-chain
piece that the LITKEY → Stripe credit listener and the payment page
will both depend on. Follow-up PRs add the rate poller, the WSS
listener, and the Wagmi payment page.

What's here:
- lit-payments/contracts/ — self-contained Hardhat + TS project at
  Solidity 0.8.28 (matches the existing lit_node_express conventions).
  Networks: hardhat (local), baseSepolia, base.
- LitkeyPaymentGateway.sol — immutable contract; pay(amount, wallet)
  pulls LITKEY from msg.sender via SafeERC20.safeTransferFrom, forwards
  to the treasury (the company Safe on Base), and emits
  Payment(indexed wallet, indexed payer, amount). Reverts on zero
  treasury / zero wallet / zero amount via custom errors.
- Test-only MockERC20 + 12 unit tests: constructor guards, every
  revert path, happy path + balance + event args assertions, multi-
  payer attribution, cross-wallet payments (payer ≠ credited), and
  topic-filter sanity for the off-chain listener's queries.
- scripts/deploy.ts — reads LITKEY_ADDRESS + TREASURY_ADDRESS from
  env, deploys, optionally Basescan-verifies if BASESCAN_API_KEY is
  set.
- README.md walks through local test + Base Sepolia / mainnet deploy.
- .github/workflows/lit-payments-contracts-ci.yml runs `npm ci` +
  `hardhat compile` + `hardhat test` on every PR touching
  lit-payments/contracts/.

All 12 tests pass locally; clean compile.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@clawdbot-glitch003 clawdbot-glitch003 requested a review from a team May 21, 2026 00:55
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​types/​node@​22.19.9 ⏵ 22.19.19100 +110081 +196 +1100
Updated@​openzeppelin/​contracts@​5.4.0 ⏵ 5.6.110010010090100
Added@​nomicfoundation/​hardhat-verify@​2.1.39810010096100

View full report

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.

2 participants