Repository: https://github.com/aljmiller87/ethereum-dispute-resolution
In my solidity file @0.5.0, I have a Factory Contract and a child contract. Although I am able to compile it with some trial and error noted in the commented-out lines in ethereum/compile.js.
However, when I run node ethereum/deploy.js
, I encounter an error:
Attempting to deploy from account 0xff831110eeA8322639bee543AD1477AD9f472E22
UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit.
...
...
...
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:24059) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have verified that this contract code works in remix. Additionally, I've attempted using truffle-hdwallet-provider
on versions 0.0.3
and 0.0.5
, updating the arguments accordingly for both .deploy()
and .send()
.
This exact setup has been successful in another project @ solidity 0.4.17 where deploying worked fine. Here's the repository for the previous project: https://github.com/aljmiller87/ethereum-kickstart
Repository Link:https://github.com/aljmiller87/ethereum-dispute-resolution
ethereum/deploy.js
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const compiledContract = require('./build/ThreeJudge.json');
const compiledFactory = compiledContract.ContractFactory
const compiledFactoryABI = compiledFactory.abi;
const compiledFactoryBytecode = compiledFactory.evm.bytecode.object;
const provider = new HDWalletProvider(
`${process.env.SEED_KEY}`,
'https://rinkeby.infura.io/v3/ad66eb1337e043b2b50abe1323fff5f0'
);
const web3 = new Web3(provider);
const deploy = async () => {
// Get account to deploy from
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account', accounts[0]);
// deploy code
const result = await new web3.eth.Contract(compiledFactoryABI)
.deploy({ data: '0x' + compiledFactoryBytecode })
.send({ gas: '1000000', from: accounts[0] });
console.log('result address', result.options.address)
};
deploy();
package.json:
{
"name": "kickstart",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha test/ThreeJudge.test.js --timeout 10000",
"test-local": "mocha test/ThreeJudge-local.test.js --timeout 10000",
"dev": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^8.0.0",
"fs-extra": "^8.1.0",
"ganache-cli": "^6.5.0",
"mocha": "^6.1.4",
"next": "^4.1.4",
"next-routes": "^1.4.2",
"path": "^0.12.7",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^0.87.3",
"solc": "0.5.2",
"truffle-hdwallet-provider": "0.0.5",
"web3": "^1.0.0-beta.37"
}
}
When running node ethereum/deploy.js
, I encounter the following error:
Attempting to deploy from account 0xff831110eeA8322639bee543AD1477AD9f472E22
(node:24059) UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit.
at Object.callback (/Users/alexmiller/Projects/solidity/threejudges/node_modules/web3-core-method/src/index.js:333:46)
...
...
...
(node:24059) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:24059) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.