v1.6-beta.4 - add mainnet mode + minimal gas-estimate route #257
daviddprtma
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Behaviour summary
1. Network mode (
backend/src/hederaClient.js+backend/src/utils/config.js)HEDERA_NETWORKenv var added; defaults to"testnet"(so testnet mode is preserved exactly as before for any deployment that doesn't set the variable).makeHederaClient(operatorId, operatorKey, network?):network === "testnet"→Client.forTestnet()network === "mainnet"→Client.forMainnet()networkis anything else (typo, case mismatch) → explicit error:Unknown Hedera network ... Set HEDERA_NETWORK to "testnet" or "mainnet".getActiveNetwork()andisMainnet()helpers.isMainnet()is consumed byindex.jsboot path:testnetmode → logs🧪 Hedera client running in TESTNET modemainnetmode → logs a⚠️warning that the deployment is signing REAL transactions for account<operator>getHederaClient()keeps the singleton behaviour. The only contract change is the log line.2. Gas estimator (
backend/src/utils/gasEstimate.js)TINYBARS_PER_HBAR = 100_000_000nexported.currentFeeSchedule()walks the mirror-node/api/v1/network/feespayload'stransaction_fee_schedulearray and matches on Hedera'snamefield (post-0.46 mirror-node release) to pick the right bucket per transaction type. Falls back to the lowest-priced bucket when no name match exists.estimateBatchGas({ batchCount, safetyMargin, tinybarCeiling, mirrorNodeUrl, timeoutMs, usdPerHbar })returns:safetyMargin = 1.1(+10%),tinybarCeiling = 5_000_000n tinybar ≈ 0.05 HBAR. Mirror node outing falls back to a published-historical estimate (10_000ntinybar on mainnet,1_000non testnet) so the endpoint is always 200-OK.3. HTTP route (
backend/src/routes/gasEstimate.js)GET /api/gas-estimate?batchCount=N&safetyMargin=...&tinybarCeiling=...&usdPerHbar=...estimateBatchGas().400 { ok: false, error: ..., code: "gas_estimate_invalid_input" }. DB / mirror outage → HTTP200withsource: 'fallback'(the API is best-effort; the user can still submit a batch).4. Booting (
backend/src/index.js)getHederaClient()init, the server announces which network is active. This is a singleconsole.warn/console.logdifferentiated byisMainnet(). Maintaining existingtry/catch/process.exit(1)flow.5. Documentation (
backend/.env.example)HEDERA_NETWORK=testnetblock with proactive commentary on:this improvement project is proposed by @arcgod-design
You can support AgroDex project for Indonesian agriculture in here https://github.com/sponsors/daviddprtma
This discussion was created from the release v1.6-beta.4 - add mainnet mode + minimal gas-estimate route.
All reactions