DeployContract script update

This commit is contained in:
viktor 2017-06-30 19:24:26 +03:00
parent 54c754563e
commit 1f2a8528a1
1 changed files with 14 additions and 14 deletions

View File

@ -7,18 +7,18 @@ var web3;
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
web3 = new Web3(new Web3.providers.HttpProvider(config.smartContract.rpc[config.environment]));
web3 = new Web3(new Web3.providers.HttpProvider(config.Ethereum[config.environment].rpc));
}
var contractABI = config.smartContract.abi;
var compiled = config.smartContract.bin;
var contractABI = config.Ethereum.contracts.ProofOfPhone.abi;
var compiled = config.Ethereum.contracts.ProofOfPhone.bin;
//estimateGas();
deployContract();
function estimateGas() {
web3.eth.defaultAccount = web3.eth.accounts[1];
web3.eth.defaultAccount = web3.eth.accounts[0];
var balance = web3.eth.getBalance(web3.eth.defaultAccount);
console.log(balance.toString(10));
console.log(balance.toNumber());
@ -32,23 +32,23 @@ function estimateGas() {
function deployContract() {
console.log(web3.eth.accounts);
web3.eth.defaultAccount = web3.eth.accounts[1];
web3.eth.defaultAccount = web3.eth.accounts[0];
var gasWillUsed = web3.eth.estimateGas({
from: web3.eth.defaultAccount,
data: compiled
});
console.log(gasWillUsed);
//gasWillUsed += 30000;
gasWillUsed += 30000;
var phonetoaddressContract = web3.eth.contract(contractABI);
phonetoaddressContract.new(
{
data: compiled,
gas: gasWillUsed,
from: web3.eth.defaultAccount
}, function(err, contract) {
if(!err) {
var proofOfPhoneContract = web3.eth.contract(contractABI);
proofOfPhoneContract.new(
{
data: compiled,
gas: gasWillUsed,
from: web3.eth.defaultAccount
}, function(err, contract) {
if (!err) {
if (typeof contract.address != 'undefined') {
console.log("contract:");
console.log(contract);