Skip to content

Implement a maximum minting cap or require multi-signature approval for bulk mints.#36

Draft
aniket866 wants to merge 3 commits intoStabilityNexus:mainfrom
aniket866:fixing-minting-limit
Draft

Implement a maximum minting cap or require multi-signature approval for bulk mints.#36
aniket866 wants to merge 3 commits intoStabilityNexus:mainfrom
aniket866:fixing-minting-limit

Conversation

@aniket866
Copy link
Copy Markdown
Contributor

@aniket866 aniket866 commented Feb 24, 2026

Addressed Issues:

Closes #35

See issue #35 for more details

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions.
  • If applicable, I have made corresponding changes or additions to the documentation.
  • If applicable, I have made corresponding changes or additions to tests.
  • My changes generate no new warnings or errors.
  • I have joined the Stability Nexus's Discord server and I will share a link to this PR with the project maintainers there.
  • I have read the Contribution Guidelines.
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.

AI Usage Disclosure

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

@Zahnentferner

Summary by CodeRabbit

  • New Features
    • Configurable mint cap for tokens with deploy UI field and enforcement on issuance; UI shows mint progress and disables inputs when cap reached.
  • Bug Fixes
    • Clearer error handling and user toasts when token creation or local save fail; prevents confusing placeholder addresses.
  • Chores
    • Updated build target for the web app.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 24, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 51718b51-913a-4ec0-88f9-5cbba9217204

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Adds a configurable on-chain max mint cap and enforces it end-to-end: contract state/error and admin setter, factory & TNT ABIs updated to accept/expose the cap, and frontend changes to pass, display, enforce, and persist the cap during deployment and minting flows.

Changes

Cohort / File(s) Summary
Contract: Max supply enforcement
contracts/src/TNT.sol
Added MaxSupplyReached() error, uint256 public maxSupply, setMaxSupply(uint256) admin setter, and pre-mint check in issueToken to revert when cap reached.
Factory & TNT ABI updates
web/src/utils/contractsABI/TNTFactory.ts, web/src/utils/contractsABI/TNT.ts
createTNT ABI gains maxMintCap:uint256 input; TNT constructor now accepts _maxMintCap:uint256; added maxMintCap() view and MintCapReached() error to TNT ABI.
Frontend — Create / Deployment flow
web/src/app/create/page.tsx
Added maxMintCap form state and validation; pass BigInt(maxMintCap) to createTNT; replace heuristic receipt parsing with deterministic decodeEventLog for TNTCreated; improved error handling and robust saveTransaction localStorage writes.
Frontend — Token actions / Mint UI
web/src/app/token-actions/page.tsx
Read maxMintCap and getAllParticipantsCount on load; block and disable minting when cap reached; display mint progress and update totalMinted after successful mint.
Role / token info helper
web/src/utils/roleManager.ts
getTokenInfo() now reads maxMintCap (defaults to 0n on failure) and includes it in returned token info.
Build config
web/tsconfig.json
TS target bumped from ES2017 to ES2020.

Sequence Diagram(s)

sequenceDiagram
participant User
participant Frontend
participant TNTFactory
participant Blockchain
participant Decoder
participant LocalStorage

User->>Frontend: submit create form (name,symbol,revokable,imageURL,maxMintCap)
Frontend->>TNTFactory: createTNT(..., maxMintCap)
TNTFactory->>Blockchain: send tx
Blockchain-->>Frontend: txReceipt (logs)
Frontend->>Decoder: decodeEventLog(txReceipt.logs, TNTCREATED)
Decoder-->>Frontend: { tntAddress }
Frontend->>LocalStorage: saveTransaction({tntAddress, maxMintCap, txHash})
LocalStorage-->>Frontend: success/failure
Frontend-->>User: show success or error toast
Loading
sequenceDiagram
participant User
participant Frontend
participant TNTContract
participant Blockchain

User->>Frontend: request mint(recipient)
Frontend->>TNTContract: read maxMintCap(), read getAllParticipantsCount()
TNTContract-->>Frontend: maxMintCap, totalMinted
alt cap reached
Frontend-->>User: show "Cap Reached" toast / disable form
else allowed
Frontend->>TNTContract: issueToken(recipient)
TNTContract->>Blockchain: mint tx
Blockchain-->>Frontend: txConfirmed
Frontend->>Frontend: totalMinted += 1
Frontend-->>User: show success toast
end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

Solidity Lang, Typescript Lang

Suggested reviewers

  • ceilican

Poem

🐰 I hopped in code, a cap to weave,
No endless mints for dawn to grieve.
Admin sets the bound so small,
Frontend, factory heed the call —
Tokens tally, safe for all. 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements a maximum minting cap to prevent unlimited token minting, fully addressing the primary security objective [#35]. However, multi-signature approval for bulk mints was not implemented, leaving one suggested mitigation incomplete. Implement multi-signature approval for bulk mints as a complementary security measure, or document why this approach was not pursued in favor of the maximum cap solution.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature implemented: a maximum minting cap has been added to limit token issuance.
Out of Scope Changes check ✅ Passed All changes are scoped to implement the minting cap feature: contract updates, UI integration, ABI changes, and TypeScript configuration are directly related to the linked issue #35 objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
contracts/src/TNT.sol (1)

63-67: Confirm intended “max supply” semantics (lifetime minted vs. active supply).
The check uses _nextTokenId, so revokes/burns won’t free capacity. If you want a cap on circulating supply, track active supply instead and compare that in issueToken.

If active-supply cap is the goal, one approach is:

  • Add uint256 public totalSupply;
  • Increment in issueToken, decrement in revokeToken and burnToken
  • Check if (maxSupply > 0 && totalSupply + 1 > maxSupply) revert MaxSupplyReached();

Please confirm which behavior you want.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@contracts/src/TNT.sol` around lines 63 - 67, The current maxSupply check in
issueToken uses _nextTokenId, so burned/revoked tokens do not free capacity; if
you intend maxSupply to limit circulating (active) tokens instead of
lifetime-minted tokens, introduce a uint256 public totalSupply, increment
totalSupply in issueToken and decrement it in revokeToken and burnToken, and
change the guard in issueToken to check if (maxSupply > 0 && totalSupply + 1 >
maxSupply) revert MaxSupplyReached(); otherwise confirm you want lifetime-minted
semantics and keep the existing _nextTokenId check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@contracts/src/TNT.sol`:
- Around line 59-61: The setter setMaxSupply currently allows lowering maxSupply
below already minted tokens (tracked by _nextTokenId), which can block minting;
update setMaxSupply to require the new _maxSupply is at least the number of
tokens already minted (use _nextTokenId to compute minted count) and revert
otherwise, and emit a MaxSupplyChanged (or MaxSupplyUpdated) event with old and
new values for auditability; add the event declaration (e.g.,
MaxSupplyChanged(uint256 old, uint256 updated)) and use it in setMaxSupply while
preserving the onlyRole(DEFAULT_ADMIN_ROLE) guard.

---

Nitpick comments:
In `@contracts/src/TNT.sol`:
- Around line 63-67: The current maxSupply check in issueToken uses
_nextTokenId, so burned/revoked tokens do not free capacity; if you intend
maxSupply to limit circulating (active) tokens instead of lifetime-minted
tokens, introduce a uint256 public totalSupply, increment totalSupply in
issueToken and decrement it in revokeToken and burnToken, and change the guard
in issueToken to check if (maxSupply > 0 && totalSupply + 1 > maxSupply) revert
MaxSupplyReached(); otherwise confirm you want lifetime-minted semantics and
keep the existing _nextTokenId check.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05a195f and e7ae64d.

📒 Files selected for processing (1)
  • contracts/src/TNT.sol

Comment thread contracts/src/TNT.sol
Copy link
Copy Markdown
Contributor

@Zahnentferner Zahnentferner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is interesting, but corresponding changes in the frontend are needed. Could you do the frontend changes? Please add screenshots of before and after the frontend changes.

@aniket866 aniket866 force-pushed the fixing-minting-limit branch from 0f73fa9 to 29d6ad4 Compare March 21, 2026 14:36
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/app/create/page.tsx (1)

167-173: ⚠️ Potential issue | 🔴 Critical

Critical: Contract call will fail due to ABI/contract parameter mismatch.

This call passes 5 arguments including BigInt(maxMintCap), but as noted in the TNTFactory.ts review, the actual Factory.sol contract's createTNT function only accepts 4 parameters. This transaction will revert with a function selector mismatch or ABI decoding error.

This must be fixed in conjunction with the TNTFactory.ts ABI correction. Either:

  1. Remove maxMintCap from the call and set it post-deployment via setMaxSupply(), or
  2. Update the Solidity contract to accept the parameter.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/app/create/page.tsx` around lines 167 - 173, The createTNT call is
passing BigInt(maxMintCap) but Factory.sol's createTNT only takes 4 params,
causing ABI mismatch; update the call site in writeContract (symbols:
writeContract, createTNT, TNTFactoryAbi, factoryAddress, maxMintCap) to remove
BigInt(maxMintCap) from the args array so you pass only [tokenName.trim(),
tokenSymbol.trim(), revokable, cleanImageURL], then after the deployment tx
completes call the factory's setMaxSupply (or the deployed TNT contract's
setMaxSupply) via a separate writeContract call passing BigInt(maxMintCap); also
ensure TNTFactory.ts ABI matches the 4-arg createTNT signature to keep ABI and
callsite consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/app/create/page.tsx`:
- Around line 146-149: The current validation allows non-integer strings like
"1.5" which will cause BigInt(maxMintCap) to throw; update the check around
maxMintCap to ensure it is an integer string before converting to BigInt by
validating either with a regex (e.g. /^\d+$/) or
Number.isInteger(Number(maxMintCap)) and rejecting values containing a decimal
point; if validation fails call toast.error("Max Mint Cap must be a positive
integer") and return. Apply this to the same code path that currently checks
maxMintCap (the variable maxMintCap and the subsequent BigInt(maxMintCap)
conversion) so you prevent the conversion error.

In `@web/src/app/token-actions/page.tsx`:
- Line 299: The optimistic increment using setTotalMinted((prev) => prev + 1n)
can desync with on‑chain state; remove that optimistic update and instead, after
a successful issueToken transaction confirmation, call the contract/read method
getAllParticipantsCount (or the existing helper that queries _allUsers) and
setTotalMinted to the returned value (BigInt) to reflect the true on‑chain
count; ensure this fetch occurs after the transaction is mined/confirmed in the
same flow that calls issueToken so the UI always matches
getAllParticipantsCount.
- Around line 119-137: The UI is calling a non-existent contract function
maxMintCap and misinterpreting getAllParticipantsCount as total minted; update
the readContract call to read the public state variable "maxSupply" (replace
functionName: "maxMintCap" with functionName: "maxSupply") and setMintCap with
that result, and either (A) if you want to show participants rename the UI
state/labels from totalMinted to totalParticipants and keep using
getAllParticipantsCount, or (B) if you need actual minted token count add a new
public accessor in the contract (e.g., expose _nextTokenId or a totalMinted()
view) and read that new function from the UI (update the readContract
functionName and setTotalMinted accordingly). Ensure the symbols referenced are
maxSupply, getAllParticipantsCount, setMintCap, setTotalMinted (or
setTotalParticipants) and adjust UI labels to match the chosen metric.

In `@web/src/utils/contractsABI/TNT.ts`:
- Around line 35-40: Update the TNT.ts ABI to match the Solidity contract:
remove the constructor parameter named "_maxMintCap" so the constructor
parameters match the 6-arg TNT.sol constructor, rename the view/state entry
"maxMintCap" to "maxSupply" (and any corresponding function ABI entry) so
callers read the public variable correctly, and replace the error name
"MintCapReached" with "MaxSupplyReached" to match the contract's custom error;
adjust any related references in the ABI object to these exact symbols
(constructor, maxSupply, MaxSupplyReached).
- Around line 425-437: The ABI in TNT.ts uses incorrect names (maxMintCap and
MintCapReached) that don't match the Solidity contract symbols; replace
occurrences of "maxMintCap" with "maxSupply" and "MintCapReached" with
"MaxSupplyReached" in the ABI so the JSON keys for the function and custom error
match the contract (ensure the function entry name "maxSupply" and the error
entry "MaxSupplyReached" are used where currently "maxMintCap" and
"MintCapReached" appear, including at the locations around the current
maxMintCap block and the error block near lines 946-950).

In `@web/src/utils/contractsABI/TNTFactory.ts`:
- Around line 26-31: ABI and frontend disagree with the contract: TNTFactory.ts
declares a fifth parameter "maxMintCap" (uint256) while Factory.sol's createTNT
function only accepts (name, symbol, revokable, imageURL), and page.tsx
currently calls createTNT with five args; fix by either removing "maxMintCap"
from the ABI (TNTFactory.ts) and stop passing it from page.tsx (remove
BigInt(maxMintCap) and any ABI entries for maxMintCap), OR update the smart
contract createTNT signature and the TNT constructor to accept and store
maxMintCap, recompile and redeploy the contract and then update TNTFactory.ts
ABI to match the new createTNT(name,symbol,revokable,imageURL,maxMintCap)
signature so the function selector and call arguments align.

---

Outside diff comments:
In `@web/src/app/create/page.tsx`:
- Around line 167-173: The createTNT call is passing BigInt(maxMintCap) but
Factory.sol's createTNT only takes 4 params, causing ABI mismatch; update the
call site in writeContract (symbols: writeContract, createTNT, TNTFactoryAbi,
factoryAddress, maxMintCap) to remove BigInt(maxMintCap) from the args array so
you pass only [tokenName.trim(), tokenSymbol.trim(), revokable, cleanImageURL],
then after the deployment tx completes call the factory's setMaxSupply (or the
deployed TNT contract's setMaxSupply) via a separate writeContract call passing
BigInt(maxMintCap); also ensure TNTFactory.ts ABI matches the 4-arg createTNT
signature to keep ABI and callsite consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 94a1fb0f-0a75-42ea-8b7e-1f6b7ca46d2a

📥 Commits

Reviewing files that changed from the base of the PR and between e7ae64d and 29d6ad4.

📒 Files selected for processing (6)
  • web/src/app/create/page.tsx
  • web/src/app/token-actions/page.tsx
  • web/src/utils/contractsABI/TNT.ts
  • web/src/utils/contractsABI/TNTFactory.ts
  • web/src/utils/roleManager.ts
  • web/tsconfig.json

Comment thread web/src/app/create/page.tsx Outdated
Comment on lines +119 to +137

// read mint cap and total minted from contract
const publicClient = getPublicClient(config as any, { chainId });
if (publicClient) {
const [cap, minted] = await Promise.all([
publicClient.readContract({
address: contractAddress,
abi: TNTAbi,
functionName: "maxMintCap",
}) as Promise<bigint>,
publicClient.readContract({
address: contractAddress,
abi: TNTAbi,
functionName: "getAllParticipantsCount",
}) as Promise<bigint>,
]);
setMintCap(cap);
setTotalMinted(minted);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if TNT.sol has totalSupply or a token counter that tracks actual minted count
echo "=== Looking for totalSupply or token counter ==="
rg -n "totalSupply|tokenId|_nextTokenId|_tokenIdCounter" -g "TNT.sol"

echo ""
echo "=== Check issueToken function to see how tokens are counted ==="
rg -n "function issueToken" -g "TNT.sol" -A 20

Repository: StabilityNexus/TNT

Length of output: 3793


🏁 Script executed:

#!/bin/bash
# Check for getter functions that expose token count or supply
echo "=== Looking for public getter functions in TNT.sol ==="
rg -n "function.*\(.*\).*public.*view.*returns" contracts/src/TNT.sol | head -30

echo ""
echo "=== Check the full file to see all public read methods ==="
rg -n "public.*view" contracts/src/TNT.sol

Repository: StabilityNexus/TNT

Length of output: 1616


🏁 Script executed:

#!/bin/bash
# Check if maxMintCap exists in TNT.sol
echo "=== Searching for maxMintCap in TNT.sol ==="
rg -n "maxMintCap" contracts/src/TNT.sol

echo ""
echo "=== Looking for max supply related variables ==="
rg -n "maxSupply|max_.*supply|supply" contracts/src/TNT.sol | head -20

Repository: StabilityNexus/TNT

Length of output: 398


Critical: maxMintCap function does not exist on the contract.

The code attempts to call publicClient.readContract() with functionName: "maxMintCap", but TNT.sol only exposes a public state variable maxSupply (line 32), not a function. This will cause a runtime error. Use the public state variable maxSupply instead.

Additionally, getAllParticipantsCount() counts unique recipients, not total tokens minted. The contract's actual token count is tracked by the private _nextTokenId variable (incremented per issuance), but this is not exposed publicly. Using getAllParticipantsCount as the "totalMinted" metric is semantically incorrect—a user receiving multiple tokens still counts as one participant. If the intent is to enforce a token supply cap, consider whether the contract should expose _nextTokenId or if the metric should track participants instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/app/token-actions/page.tsx` around lines 119 - 137, The UI is calling
a non-existent contract function maxMintCap and misinterpreting
getAllParticipantsCount as total minted; update the readContract call to read
the public state variable "maxSupply" (replace functionName: "maxMintCap" with
functionName: "maxSupply") and setMintCap with that result, and either (A) if
you want to show participants rename the UI state/labels from totalMinted to
totalParticipants and keep using getAllParticipantsCount, or (B) if you need
actual minted token count add a new public accessor in the contract (e.g.,
expose _nextTokenId or a totalMinted() view) and read that new function from the
UI (update the readContract functionName and setTotalMinted accordingly). Ensure
the symbols referenced are maxSupply, getAllParticipantsCount, setMintCap,
setTotalMinted (or setTotalParticipants) and adjust UI labels to match the
chosen metric.

toast.success("Token issued successfully!");
console.log("Issue token tx:", tx);
setIssueRecipient("");
setTotalMinted((prev) => prev + 1n);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Optimistic update may desync from actual on-chain state.

The optimistic increment setTotalMinted((prev) => prev + 1n) assumes every successful issueToken call increases getAllParticipantsCount. However, if the recipient already exists in _allUsers, the on-chain count doesn't change, causing the UI to show a higher "minted" count than reality.

Consider re-fetching getAllParticipantsCount after a successful transaction, or remove the optimistic update:

Suggested fix
      toast.success("Token issued successfully!");
      console.log("Issue token tx:", tx);
      setIssueRecipient("");
-     setTotalMinted((prev) => prev + 1n);
+     // Re-fetch actual count from contract
+     const publicClient = getPublicClient(config as any, { chainId });
+     if (publicClient) {
+       const minted = await publicClient.readContract({
+         address: contractAddress,
+         abi: TNTAbi,
+         functionName: "getAllParticipantsCount",
+       }) as bigint;
+       setTotalMinted(minted);
+     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/app/token-actions/page.tsx` at line 299, The optimistic increment
using setTotalMinted((prev) => prev + 1n) can desync with on‑chain state; remove
that optimistic update and instead, after a successful issueToken transaction
confirmation, call the contract/read method getAllParticipantsCount (or the
existing helper that queries _allUsers) and setTotalMinted to the returned value
(BigInt) to reflect the true on‑chain count; ensure this fetch occurs after the
transaction is mined/confirmed in the same flow that calls issueToken so the UI
always matches getAllParticipantsCount.

Comment on lines +35 to 40
},
{
"name": "_maxMintCap",
"type": "uint256",
"internalType": "uint256"
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify TNT.sol constructor parameters and maxMintCap/maxSupply naming
echo "=== TNT.sol constructor ==="
rg -n "constructor\(" -g "TNT.sol" -A 15

echo ""
echo "=== Check for maxMintCap or maxSupply variable ==="
rg -n "maxMintCap|maxSupply" -g "TNT.sol"

echo ""
echo "=== Check for MintCapReached or MaxSupplyReached error ==="
rg -n "MintCapReached|MaxSupplyReached" -g "TNT.sol"

Repository: StabilityNexus/TNT

Length of output: 1554


ABI contains multiple mismatches with actual TNT contract implementation.

The TNT.ts ABI file has three interconnected inconsistencies with the actual contract:

  1. Constructor parameter mismatch: The ABI declares a 7-parameter constructor with _maxMintCap, but the actual TNT.sol constructor (lines 43–57) has only 6 parameters and no _maxMintCap parameter.

  2. State variable naming mismatch: The ABI declares a maxMintCap() view function, but the contract has a public state variable named maxSupply (line 32).

  3. Error naming mismatch: The ABI declares a MintCapReached error, but the contract defines MaxSupplyReached (line 19).

These inconsistencies will cause issues with contract verification tools, block explorers, and any frontend code attempting to read the maxMintCap or call the MintCapReached error. Update the ABI to reflect the actual contract: use maxSupply instead of maxMintCap and MaxSupplyReached instead of MintCapReached, and remove _maxMintCap from the constructor parameters.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/utils/contractsABI/TNT.ts` around lines 35 - 40, Update the TNT.ts
ABI to match the Solidity contract: remove the constructor parameter named
"_maxMintCap" so the constructor parameters match the 6-arg TNT.sol constructor,
rename the view/state entry "maxMintCap" to "maxSupply" (and any corresponding
function ABI entry) so callers read the public variable correctly, and replace
the error name "MintCapReached" with "MaxSupplyReached" to match the contract's
custom error; adjust any related references in the ABI object to these exact
symbols (constructor, maxSupply, MaxSupplyReached).

Comment on lines +425 to +437
{
"type": "function",
"name": "maxMintCap",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check exact function/variable and error names in TNT.sol
echo "=== Public variables and functions containing 'mint' or 'supply' ==="
rg -n "public.*max|function.*max" -g "TNT.sol" -i

echo ""
echo "=== Error definitions ==="
rg -n "^error " -g "TNT.sol"

Repository: StabilityNexus/TNT

Length of output: 323


🏁 Script executed:

#!/bin/bash
# Search for error definitions with broader patterns
echo "=== Search for error/Error patterns in TNT.sol ==="
rg -n "error|Error|revert|Revert" -g "TNT.sol" -i | head -30

echo ""
echo "=== Check ABI file lines 946-950 ==="
sed -n '946,950p' web/src/utils/contractsABI/TNT.ts

Repository: StabilityNexus/TNT

Length of output: 1267


ABI naming mismatches will cause contract interaction failures.

The ABI declares maxMintCap and MintCapReached, but the contract uses maxSupply (line 32 in TNT.sol) and MaxSupplyReached (line 19 in TNT.sol). Frontend readContract calls will fail with "function not found" and "error not found" errors. Update the ABI to match the contract's actual function and error names.

Applies to lines 425-437 and 946-950.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/utils/contractsABI/TNT.ts` around lines 425 - 437, The ABI in TNT.ts
uses incorrect names (maxMintCap and MintCapReached) that don't match the
Solidity contract symbols; replace occurrences of "maxMintCap" with "maxSupply"
and "MintCapReached" with "MaxSupplyReached" in the ABI so the JSON keys for the
function and custom error match the contract (ensure the function entry name
"maxSupply" and the error entry "MaxSupplyReached" are used where currently
"maxMintCap" and "MintCapReached" appear, including at the locations around the
current maxMintCap block and the error block near lines 946-950).

Comment on lines +26 to 31
},
{
"name": "maxMintCap",
"type": "uint256",
"internalType": "uint256"
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the Factory.sol createTNT function signature
echo "=== Factory.sol createTNT function signature ==="
rg -n "function createTNT" --type solidity -A 3 || rg -n "function createTNT" -g "*.sol" -A 3

echo ""
echo "=== TNT.sol constructor signature ==="
rg -n "constructor\(" -g "*.sol" -A 10 | head -30

Repository: StabilityNexus/TNT

Length of output: 1251


🏁 Script executed:

# Check the frontend call in create/page.tsx
echo "=== Frontend createTNT call ==="
rg -n "createTNT\|maxMintCap" web/src/app/create/page.tsx -B 2 -A 2

echo ""
echo "=== Look for setMaxSupply or maxMintCap in TNT.sol ==="
rg -n "setMaxSupply\|maxMintCap" -g "*.sol" -A 3

echo ""
echo "=== Check full ABI structure in TNTFactory.ts ==="
head -50 web/src/utils/contractsABI/TNTFactory.ts

Repository: StabilityNexus/TNT

Length of output: 1646


🏁 Script executed:

# Find files related to token creation
echo "=== Find create-related files ==="
fd -t f "create" web/src --type f | head -20

echo ""
echo "=== Search for TNTFactory usage ==="
rg -n "TNTFactory" web/src -A 2

echo ""
echo "=== Look for maxSupply in TNT contract ==="
rg -n "maxSupply\|_maxSupply\|maxMint" contracts/src/TNT.sol -B 2 -A 2

echo ""
echo "=== Check if there are any external function calls to createTNT ==="
rg -n "\.createTNT\|createTNT\(" web/src

Repository: StabilityNexus/TNT

Length of output: 3102


🏁 Script executed:

# Show the complete createTNT function from Factory.sol
rg -n "function createTNT" contracts/src/Factory.sol -A 10

Repository: StabilityNexus/TNT

Length of output: 668


Critical: ABI declares maxMintCap parameter but Factory.sol does not accept it.

The createTNT function in contracts/src/Factory.sol (line 24) accepts only 4 parameters: name, symbol, revokable, and imageURL. However, the ABI in web/src/utils/contractsABI/TNTFactory.ts declares 5 parameters, adding maxMintCap as a uint256.

The frontend code in web/src/app/create/page.tsx (line 171) calls this function with 5 arguments: args: [tokenName.trim(), tokenSymbol.trim(), revokable, cleanImageURL, BigInt(maxMintCap)]. Because the function selector is computed from the ABI signature (5 parameters), it will not match the actual contract function signature (4 parameters), causing token creation transactions to fail.

Required fix: Either:

  1. Remove maxMintCap from the ABI and handle it separately (if needed via a separate contract method), OR
  2. Update Factory.sol and the TNT constructor to accept and handle maxMintCap as a parameter.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/utils/contractsABI/TNTFactory.ts` around lines 26 - 31, ABI and
frontend disagree with the contract: TNTFactory.ts declares a fifth parameter
"maxMintCap" (uint256) while Factory.sol's createTNT function only accepts
(name, symbol, revokable, imageURL), and page.tsx currently calls createTNT with
five args; fix by either removing "maxMintCap" from the ABI (TNTFactory.ts) and
stop passing it from page.tsx (remove BigInt(maxMintCap) and any ABI entries for
maxMintCap), OR update the smart contract createTNT signature and the TNT
constructor to accept and store maxMintCap, recompile and redeploy the contract
and then update TNTFactory.ts ABI to match the new
createTNT(name,symbol,revokable,imageURL,maxMintCap) signature so the function
selector and call arguments align.

@aniket866 aniket866 marked this pull request as draft March 21, 2026 18:24
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

[BUG]: Implement a maximum minting cap or require multi-signature approval for bulk mints.

2 participants