Blockchain 在web3.js中获取有关写入发送的错误
您好,我收到错误信息Blockchain 在web3.js中获取有关写入发送的错误,blockchain,ethereum,smartcontracts,web3js,Blockchain,Ethereum,Smartcontracts,Web3js,您好,我收到错误信息 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 et
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
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;
}
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);
})
当我从web3.js调用函数时,如
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
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;
}
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);
})
此错误显示在所有写入函数上。。雷德工作得很好。我以前从未遇到过这个错误。我试着在Ropsten和Rinkeby上部署contract时也犯了同样的错误。
这些合同功能在etherscan和remix上运行良好。
在web3js中,事务中甚至不会出现元掩码。可能是什么问题 正如我上面提到的,我使用的是eth.js。所以这就是问题所在。我没有使用ethjs,只是通过使用web3js进行了变通。因为我已经实现了我的节点应用程序的所有读取功能和所有功能,所以更改所有内容都是浪费时间。制作了2个差异变量,1个来自ethjs(用于读取),1个来自纯web3js
const NameContract = web3.eth.contract(tokenABI);
window.tokenContract2 = NameContract.at(tokenAddress); //web3js
window.tokenContract = eth.contract(tokenABI).at(tokenAddress); ethjs
然后我使用了如下函数
tokenContract2.regUser({ from: user_address, gas: 400000 },
(err, res) => { /** callback **/ }
)
回调是必要的,因为metamask会发出错误
我仍然想知道问题的根源。但由于时间不够,我不得不继续进行我正在使用的项目