2

I have a simple meteor app that is running on a local node on a private chain. I am attempting to send some ether from one test account to another, and I get the following error, from inside the getR() function. Any insight would be greatly appreciated!

Error: common: unmarshalJSON failed: hash must be exactly 32 bytes(…)?

here is the getR() function, please see full code snippet below for context:

var getR = function() {
    console.log(window.transactionHash);
web3.eth.getTransactionReceipt(window.transactionHash, function(err, receipt){
    console.log(err);
    console.log(receipt);
    // document.getElementById("response2").innerHTML = receipt.transactionHash;
});

};

* inside of the this function err returns the error stated in the title, and the receipt object is null.

<body>
    <h3>Account</h3>
    <p id="account"></p>
    <h3>Account Balance</h3>
    <p id="balance"></p> ether
    <button id="sendEther" onclick="sendSomeEther()">Send 1 Ether</button>
    <p id="response"></p>
    <button id="getR" onclick="getR()">What Happened!</button>
    <p id="response2"></p>
    <script type="text/javascript">

    window.web3 = new Web3();
    window.transactionHash = '';
    alert(window);

    var getR = function() {
        console.log(window.transactionHash);

        web3.eth.getTransactionReceipt(window.transactionHash, function(err, receipt){
            console.log(err);
            console.log(receipt);
            // document.getElementById("response2").innerHTML = receipt.transactionHash;
        });
    };

    function sendSomeEther(){
        var txObject = {
            from: web3.eth.defaultAccount,
            gas: 30000000,
            value: web3.toWei(12, 'ether'),
            to: 'ac97d0feb8b4b3bcaa2b153dff1d4eaa5b4bee9c'
        };

        web3.eth.sendTransaction(txObject, function(err, result){
            if(err)
            return document.getElementById("response").innerHTML = 'Error: ' + err;

            document.getElementById("response").innerHTML = 'Yay, first one! transaction hash:' + result;

            window.transactionHash = result;
        });
    };

    web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

    web3.eth.getAccounts(function(err, accounts){
        web3.eth.defaultAccount = accounts[0];

        document.getElementById("account").innerHTML = accounts[0];

        web3.eth.getBalance(accounts[0], function(err, balance){
            document.getElementById("balance").innerHTML = web3.fromWei(balance, 'ether');

        });
    });


    </script>
</body>
2

Follow instructions from this post, on unlocking an account with the --unlock flag - while starting geth. Once the sending account was unlocked in the current geth instance, the transaction was successful.

Error: account is locked. Attempting to send ether from one account to another, Local Node on Private Blockchain

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.