Skip to content

fix: detect standard contract creation bytecode prefix in decodeTxData - #1309

Open
mariazuheros wants to merge 1 commit into
scaffold-eth:mainfrom
mariazuheros:fix/decode-tx-data-contract-creation-prefix
Open

fix: detect standard contract creation bytecode prefix in decodeTxData#1309
mariazuheros wants to merge 1 commit into
scaffold-eth:mainfrom
mariazuheros:fix/decode-tx-data-contract-creation-prefix

Conversation

@mariazuheros

Copy link
Copy Markdown

Description

The contract-creation guard in decodeTxData.ts only skipped inputs starting with 0x60e06040, but the common Solidity init code prefix is 0x60806040 (PUSH1 0x80 PUSH1 0x40 MSTORE).

As a result, standard contract creation transactions fell through to the function decoder, failed to match any ABI, and were mislabeled as ⚠️ Unknown in the block explorer.

Fix

Check the input against both known init-code prefixes:

  • 0x60806040 — the common prefix
  • 0x60e06040 — used when a contract stores immutables (preserves the previous behavior)

This way deployments are correctly detected and skipped, while regular function calls still decode normally.

+const CONTRACT_CREATION_PREFIXES = ["0x60806040", "0x60e06040"];
+
 export const decodeTransactionData = (tx: TransactionWithFunction) => {
-  if (tx.input.length >= 10 && !tx.input.startsWith("0x60e06040")) {
+  const isContractCreation = CONTRACT_CREATION_PREFIXES.some(prefix => tx.input.startsWith(prefix));
+  if (tx.input.length >= 10 && !isContractCreation) {

Testing

  • yarn next:check-types — passes
  • yarn next:lint — passes
  • Prettier formatting — clean
  • Verified the logic against standard deploys (0x60806040), immutable deploys (0x60e06040), and normal function calls (transfer, approve): deployments are now skipped and function calls still decode.

Fixes #1246

The contract-creation guard only skipped inputs starting with 0x60e06040,
but the common Solidity init code prefix is 0x60806040 (PUSH1 0x80 PUSH1
0x40 MSTORE). As a result, standard contract creation transactions fell
through to the function decoder and were mislabeled as "⚠️ Unknown" in the
block explorer.

Check against both known init-code prefixes (0x60806040 and 0x60e06040, the
latter used when a contract stores immutables) so deployments are correctly
skipped while regular function calls still decode.

Fixes scaffold-eth#1246

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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: decodeTxData.ts checks wrong bytecode prefix (0x60e06040 vs 0x60806040)

1 participant