5

I haven't been able to run the Greeter contract on the live network and am referring to these excellent Q&As for guidance. I have a feeling that it's because my client hasn't finished syncing with the blockchain yet. I confirmed that I have 0.1 ether in my account (enough to pay for gas) using an online blockchain explorer, but this isn't reflected yet when I check the balance via command line (still reports 0 balance).

Do I have to finish syncing in order to deploy the contract?

3

Currently, when trying to deploy the contract, you should be seeing an error in Geth about your account not having sufficient balance.

You have to wait until you've synced the block containing the transaction that gives your account the 0.1 Ether. Then Geth will show your balance and you will be able to deploy the contract: check the transaction hash against a block explorer. The explorers will show your deployed contract, but for your client to see it, your client will have to sync up to the block that has your contract deployment.

2

Here is the deployment step from the excellent Q&As:

> var greeter = greeterContract.new(_greeting, {from: eth.accounts[0], data: greeterCompiled.greeter.code, gas: 4000000}, 
  function(e, contract) {
    if (!e) {
      if (!contract.address) {
        console.log("Contract transaction send: TransactionHash: " +
          contract.transactionHash + " waiting to be mined...");
      } else {
        console.log("Contract mined! Address: " + contract.address);
        console.log(contract);
      }
    } 
  })
Contract transaction send: TransactionHash: 0x90d201388971770036898a7a22ab252cb0bf3c556f988a7b87583315cdaf58bc waiting to be mined...
undefined
> Contract mined! Address: 0x083628160c1cf218d14f2f0998c7a8dc72aec180
[object Object]


Blocks Synced Up To Where You Have A Balance In Your Account

If your local geth node has synced up to the point where it has the block containing the transaction that creates the 0.1 ETH balance in your account, you WILL be able to deploy the Greeter contract.

Reference: My geth node is taking ages to sync, can I still send ether? where a regular transaction is sent when the blockchain is not synced. The same principle applies when sending contract creation transactions.

You should see the Contract transaction send: TransactionHash: ... message as your geth client will be able to broadcast the transaction.

However, you will not see the message Contract mined! Address: ... on your geth client because your client will not have received the new block on the Mainnet blockchain containing your contract creation transaction.

You will have to wait until your geth client syncs up to the block containing your contract creation transaction before the Contract mined! Address: ... message is displayed in your console.


Blocks NOT Synced Up To Where You Have A Balance In Your Account

In this case, you will have a zero balance in your account, and your geth client will prevent you from sending your contract creation transaction to the Mainnet blockchain.

0

Your node needs to be synced up. If you do not run your own node use Infura. Here is a little snippet I use for deployment after I've compiled contract with truffle:

const etherlime = require('etherlime');

const ICOTokenContract = require('./build/contracts/ICOToken.json');

const randomAddress = '0xda8a06f1c910cab18ad187be1faa2b8606c2ec86';

const defaultConfigs = {
    gasPrice: 20000000000,
    gasLimit: 4700000
}

const deployer = new etherlime.InfuraPrivateKeyDeployer('Your Privste KEY', 'ropsten', 'Your infura API key', defaultConfigs);

const runICODeployment = async () => {
    const contractWrapper = await deployer.deploy(ICOTokenContract);
    const transferTransaction = await contractWrapper.contract.transferOwnership(randomAddress);
    const result = await contractWrapper.verboseWaitForTransaction(transferTransaction.hash, 'Transfer Ownership');
}
runICODeployment()

Then just run node yourFileThatPastedTheAbove.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.