Open
feat: wire backend to deployed BNB Testnet contracts#3
Conversation
Co-authored-by: OmLanke <92863779+OmLanke@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Connect backend to smart contracts
feat: wire backend to deployed BNB Testnet contracts
Feb 27, 2026
OmLanke
marked this pull request as ready for review
February 27, 2026 16:44
Collaborator
|
@Arnab-Afk Looks good to me. Please check |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The backend had no live connection to the deployed GhostPool/GhostPaymaster contracts — contract addresses were placeholders, deposits required manual API calls, and nullifier/commitment checks were DB-only.
Contract ABI + Address Layer
src/contracts/abis.ts— typed minimal ABIs for GhostPool and GhostPaymaster (view functions + events the backend actually calls)src/contracts/addresses.ts— chainId-keyed address registry hardcoded fromdeployments/97/addresses.json; env vars always overrideExtended Contract Reads (
paymasterClient.ts)Added GhostPaymaster reads:
isNullifierSpentOnChain(hash)— authoritative on-chain nullifier checkgetBnbToUsdcRate()— current fee conversion rateisZkVerificationEnabled()— paymaster verification flagRefactored to use shared ABIs; exported
publicClientfor reuse.On-Chain Deposit Indexer (
src/indexer/depositIndexer.ts)Polls
GhostPool.Depositevents every 15s (configurable viaINDEXER_POLL_INTERVAL_MS). Auto-inserts new deposits into the off-chain Merkle tree and DB — removes the requirement for the frontend to manually callPOST /pool/deposit.Route Hardening
POST /pool/deposit— now callsisCommitmentInsertedon-chain before accepting; rejects if commitment not yet in GhostPoolGET /pool/status— response now includesonChain.merkleRootandonChain.nextLeafIndexread live from the contractPOST /relay— dual nullifier check: local DB (fast path) thenisNullifierSpentOnChain(authoritative)Config
.env.exampleupdated with BNB Testnet (chainId 97) deployed addresses pre-filledINDEXER_POLL_INTERVAL_MSenv var added💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.