Last active
March 30, 2018 16:23
-
-
Save fdouglis/c58f1d0f441529bf08757763ec37c715 to your computer and use it in GitHub Desktop.
this web3 code breaks between node3 v30 and v33.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = require('./testconfig.json'); | |
var Web3 = require('web3'); | |
var fs = require('fs'); | |
var web3 = new Web3(config.rpcAddr); | |
var mycontractBin = fs.readFileSync(config.contract_bin, 'utf8'); | |
var mycontractAbi = require(config.contract_json); | |
var defaultGas = 0xfffffffff; | |
var account; | |
var mycontract = new web3.eth.Contract(mycontractAbi.abi); | |
var debugeverything = true; | |
console.log("initialize... "); | |
web3.eth.getAccounts().then(e => { | |
account=e[0]; | |
console.log("initialize: account ", account); | |
mycontract.options.from = account; // default from address | |
mycontract.options.gasPrice = '1'; // default gas price in wei | |
mycontract.options.gas = 0xffffffff; // provide as fallback always 5M gas | |
mycontract.options.data = mycontractBin; | |
}).then(function() { | |
deploy(); | |
}); | |
function deploy() { | |
console.log("Deploy:"); | |
mycontract.deploy({ | |
data: mycontractBin, | |
arguments: [123456] | |
}).send({"from": account, | |
"gasPrice": '1000', | |
"gas" : '0xffffffff' | |
}, function(error,transactionHash){ | |
console.log("Inside function call from send"); | |
console.log(error); | |
console.log('Ethereum transaction', transactionHash, 'successfully posted.');}) | |
.on('error', function(error){ | |
console.log("Error: ", error); | |
}) | |
.on('transactionHash', function(transactionHash){ console.log("txHash: ", transactionHash); }) | |
.on('receipt', function(receipt){ | |
console.log("Addr: ", receipt.contractAddress) // contains the new contract address | |
}) | |
.on('confirmation', function(confirmationNumber, receipt){ console.log("confirmation callback ignored");}) | |
.then(function(newContractInstance){ | |
console.log("hit -then- clause of deploy"); | |
console.log(newContractInstance.options.address) // instance with the new contract address | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
testconfig.json is very simple and obvious: