{"record":{"id":"a251a1ea76b8e355","repo":"ethereum/go-ethereum","slug":"the-contract-code-couldn-t-be-stored-please-check","errorCode":null,"errorMessage":"The contract code couldn't be stored, please check your gas amount.","messagePattern":"The contract code couldn't be stored, please check your gas amount\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"internal/jsre/deps/web3.js","lineNumber":2933,"sourceCode":"                            if(code.length > 3) {\n\n                                // console.log('Contract code deployed!');\n\n                                contract.address = receipt.contractAddress;\n\n                                // attach events and methods again after we have\n                                addFunctionsToContract(contract);\n                                addEventsToContract(contract);\n\n                                // call callback for the second time\n                                if(callback)\n                                    callback(null, contract);\n\n                            } else {\n                                if(callback)\n                                    callback(new Error('The contract code couldn\\'t be stored, please check your gas amount.'));\n                                else\n                                    throw new Error('The contract code couldn\\'t be stored, please check your gas amount.');\n                            }\n                        });\n                    }\n                });\n            }\n        }\n    });\n};\n\n/**\n * Should be called to create new ContractFactory instance\n *\n * @method ContractFactory\n * @param {Array} abi\n */\nvar ContractFactory = function (eth, abi) {\n    this.eth = eth;\n    this.abi = abi;","sourceCodeStart":2915,"sourceCodeEnd":2951,"githubUrl":"https://github.com/ethereum/go-ethereum/blob/6bb0588ad8e7f922e4ad5580f51265a4097af08f/internal/jsre/deps/web3.js#L2915-L2951","documentation":"During contract deployment confirmation, web3 fetched the receipt and then called getCode on the receipt's contractAddress. If the deployed address holds no code (!code), it concludes the constructor did not store bytecode and reports that the contract code could not be stored, suggesting the gas amount is wrong. Classic signature: the deployment tx was mined but OUT_OF_GAS, leaving an empty contract.","triggerScenarios":"contract.new({data: ..., gas: N}) where N is less than the constructor's actual execution cost; the transaction is mined, receipt.contractAddress exists, but getCode returns empty. Also triggered by a constructor that reverts (failing assert/require or throw in old Solidity).","commonSituations":"Underestimating deployment gas (especially large bytecode or expensive constructors), Solidity 0.4.x 'throw' in the constructor, or a linked-library placeholder left unresolved causing the constructor to fail.","solutions":["Raise the gas limit for the deploy transaction (estimate first if possible) and redeploy.","Inspect the receipt's gasUsed vs the gas sent: gasUsed == gas limit strongly indicates out-of-gas.","Check the constructor logic for reverts/throws and that all library placeholders (__$...$__) were linked.","Redeploy to a fresh address; the failed attempt leaves a useless empty contract."],"exampleFix":"// before\ncontract.new({from: acct, data: code, gas: 100000}, cb);\n\n// after\ncontract.new({from: acct, data: code, gas: 4700000}, cb);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"contract.new(opts, function (err, c) {\n  if (err && /gas amount/.test(err.message)) {\n    // deployment mined but empty: bump gas and redeploy to a new address\n    opts.gas = Math.floor(opts.gas * 1.5);\n    contract.new(opts, arguments.callee.bind(null));\n  }\n});","preventionTips":["Estimate deployment gas generously (bytecode size x 200 + constructor cost).","Check receipt.gasUsed === tx.gas as an out-of-gas smell test before interpreting the error.","Ensure all library link placeholders are resolved before deploy."],"tags":["web3","deployment","out-of-gas"],"backgroundTag":null,"analyzedSha":"6bb0588ad8e7f922e4ad5580f51265a4097af08f","analyzedAt":"2026-08-15T10:06:53.996Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}