2
votes

Hi I am getting error

Error: [ethjs-query] while formatting inputs '[{"0":false}]' for method 'getTransactionReceipt' error: Error: [ethjs-format] hex string '[object Object]' must be an alphanumeric 66 utf8 byte hex (chars: a-fA-F) string, is 0 bytes
    at ethjs.min.js:11
    at new Promise (<anonymous>)
    at i.getTransactionReceipt (ethjs.min.js:11)
    at i.e.<computed> [as getTransactionReceipt] (ethjs.min.js:11)
    at ethjs.min.js:11

Im calling the smartcontract invest function :

function invest()public payable onlyAmount() firstExist  returns(bool){    

//  balances[msg.sender]=msg.value;
 invested[msg.sender]+= msg.value;
 isInvested[msg.sender]=true;
 users[msg.sender].creationTime=now;
  commission=(msg.value.mul(10)).div(100);
 forCreators(commission);
emit Invest(msg.sender,msg.value);
 return true;
}

Where As Im calling the function from web3.js like

tokenContract.invest({
    from: user_address,
    gasLimit: web3.toHex(8000000),
    gasPrice: web3.toHex(web3.toWei('10', 'gwei')),
    value : web3.toHex( web3.toWei(0.25, 'ether'))

  })
  .then(txHash =>  eth.getTransactionSuccess(txHash)
      .then(receipt => {
        alert("Sigup Has been successful",receipt);
      })
  )
  .catch((err) => {
    alert("Error couldnot signUp");
    console.log(err);
  })

this error is showing on all write functions .. Read is working just fine. I have never encountered this error before. I tried deploying contract on Ropsten and Rinkeby same error. And these contract functions are working just fine on etherscan and remix. In web3js Even Metamask doesnt appears for transactions. What might be the issue?

1
I am using <script type="text/javascript" src="cdn.jsdelivr.net/npm/[email protected]/dist/…> - Syed Zain Hasan

1 Answers

0
votes

so as I mentioned above I was using eth.js . So somehow that was the issue. I did a worked around by not using ethjs and just by using web3js. As I already implemented all the read functions and all the functionality of my node app so It was a waste of time to change everything . made 2 diff variables 1 from ethjs (for read ) and 1 from pure web3js

const NameContract = web3.eth.contract(tokenABI);
window.tokenContract2 = NameContract.at(tokenAddress); //web3js


 window.tokenContract = eth.contract(tokenABI).at(tokenAddress); ethjs

then I used the function like

tokenContract2.regUser({ from: user_address, gas: 400000 },
(err, res) => { /** callback **/ }
)

call backs are necessary because metamask gives out an error.

I would still like to know the root of the issue. But since I was low on time I had to move forward with the project