I have a private ethereum blockchain with a script, filename.js.

loadScript("path to FileStorage.js");
var DataStorageContract = web3.eth.contract(JSON.parse(FileOutput.contracts["FileContract.sol:D
var f = 'QmaFDzPfZKwKchNNPBKKVHDz7msc6PTtkYjkWudyKnvF8B'  
var d = 'dc2e26b90098aef8457c24bde1ffd5fda15667cf98697fe0c2f77d6be3b6726d'
var fileStorage = DataStorageContract.new(f, d, { from: web3.eth.accounts[0], data: "0x" + File
Output.contracts["FileContract.sol:DataStorage"].bin, gas: '1000000'},  function (e, contract) 
    if(!e) {
        if(!contract.address) {
            console.log("Contract transaction send: TransactionHash: " + contract.transactionHa
sh + " waiting to be mined...");
            console.log('Error1: ' + e);
        } else {
            console.log("Contract mined! Address: " + contract.address); console.log(contract);
            console.log('Error2: ' + e);
        console.log('Error3: ' + e);
    console.log('Error4: ' + e);

When I attach to the blockchain

geth --attach "path to ipc"

it returns a console. When I ran

loadScript("path to filename.js")

I got an output

Contract transaction send: TransactionHash: 0x92a875d52660c659ccf0e8fbb1b9d8be109f632db22b1c017 978cdee406cdf18 waiting to be mined... true

Contract mined! Address: 0xbfb5b63dacbd32833919c54da763be85d55f26e3 [object Object]

However, when I run it non-interactive using

geth --exec 'loadScript("path to filename.js")' attach "path to ipc"

I get an output

Contract transaction send: TransactionHash: 0x5e3d9ccfcf3b19d25e8c1dcd662606de10418320270679d8e086e93f04630d1c waiting to be mined...


It does not show the "Contract Mined" section in the non-interactive. How do I correct this?

  • Maybe try printing out the error (e)? – smarx Dec 26 '17 at 3:37
  • Nope, I tried printing the error in multiple places, it did not print the "Contract mined" section. – trialcritic Dec 26 '17 at 3:42
  • In the case where it didn't print "waiting to be mined" and also didn't print "Contract mined!", what was the value of e? Or are you saying execution never entered that function at all? – smarx Dec 26 '17 at 3:43
  • It printed None for e. It did enter the function in the interactive mode, when I printed the values, it did print f and d from the contract.address. – trialcritic Dec 26 '17 at 3:51
  • What is None? Sounds like Python, but this is JavaScript, right? Was it the string "None" or something else? (If so, what type?) I'm confused about how you could enter neither console.log branch but also have a falsey value for e. – smarx Dec 26 '17 at 4:00

Your Answer

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

Browse other questions tagged or ask your own question.