I have ReactJS working to read data from my blockchain but I cannot update the blockchain. Here is my code to read the blockchain which works -

  var reviewContract = ETHEREUM_CLIENT.eth.contract(reviewContractABI).at(reviewContractAddress)
  var reviewData = reviewContract.getReviews()

When I try and update it fails:

reviewContract.addReview("company1", "trevor lee oakley", 1)

Uncaught Error: invalid address
at inputAddressFormatter (http://localhost:3000/static/js/bundle.js:45751:12)
at inputTransactionFormatter (http://localhost:3000/static/js/bundle.js:45577:21)
at http://localhost:3000/static/js/bundle.js:45881:29
at Array.map (native)
at Method.formatInput (http://localhost:3000/static/js/bundle.js:45880:33)
at Method.toPayload (http://localhost:3000/static/js/bundle.js:45906:24)
at Eth.send [as sendTransaction] (http://localhost:3000/static/js/bundle.js:45931:31)
at SolidityFunction.sendTransaction (http://localhost:3000/static/js/bundle.js:48458:27)
at SolidityFunction.execute (http://localhost:3000/static/js/bundle.js:48544:38)
at App.componentWillMount (http://localhost:3000/static/js/bundle.js:32663:23)

I have this code to add.

pragma solidity ^0.4.8;
contract Review {

Review[] public reviews;
struct Review {
    bytes32 companyName;
    bytes32 companyReviewer;
    uint companyReview;

function addReview (bytes32 _companyName, bytes32 _companyReviewer, uint _companyReview) returns (bool success) {
    Review memory newReview;
    newReview.companyName = _companyName;
    newReview.companyReviewer = _companyReviewer;
    newReview.companyReview = _companyReview;

    return true;

function getReviews() constant returns (bytes32[], bytes32[], uint[]) {

    uint length = reviews.length;
    bytes32[] memory companyNames = new bytes32[](length);
    bytes32[] memory companyReviewers = new bytes32[](length);
    uint[] memory companyReviews = new uint[](length);

    for (uint i=0; i<reviews.length; i++) {
        Review memory currentReview;
        currentReview = reviews[i];


    return (companyNames, companyReviewers, companyReviews);

The contract works in truffle so I know -

  1. The solidity is OK
  2. Access to the blockchain is OK
  3. Update fails.

Any help is welcome.

  • Run web3.eth.defaultAccount = web3.eth.coinbase on your client console as you are trying to call a function which performs state write operation. Let me know the result – Aniket Apr 17 '17 at 14:55
  • > web3.eth.defaultAccount = web3.eth.coinbase "0x48884f1f259a4fdbb22b77b56bfd486fe7784304" – Trevor Lee Oakley Apr 17 '17 at 17:11
  • Now, are you able to call the function ? – Aniket Apr 18 '17 at 6:27
  • Uncaught TypeError: ETHEREUM_CLIENT.eth.coinbase is not a function same for defaultAccount. – Trevor Lee Oakley Apr 19 '17 at 8:22

I finally worked this out. You need to make the function payable and also define a base account.

So I added in the ReactJS -

ETHEREUM_CLIENT.eth.defaultAccount = ETHEREUM_CLIENT.eth.coinbase;


  function addReview (bytes32 _companyName, bytes32 _companyReviewer, uint _companyReview) payable returns (bool success) {

I checked at github and the method I think is method.js which is relevant. The solidity method needs to be payable to change the state on the blockchain and there a default account worked for the charges.

| improve this answer | |

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.