Closed saarshah closed 4 years ago
I think atm no one of the current maintainers will have time to debug and analyze such complex usage example beside everyday maintenance work TBH. Please report if you find a solution here, thanks!
Hey @saarshah!
I almost sure that your problem is that you are sending value to a non-payable function. I noticed this because your transaction had some ETH. The only other things that can make it fail is if you try to set the supply with a different account from owner
(not the case), or if the supply wasn't exhausted (you should check this).
Debugging contracts on live networks can be really hard, so my recommendation is to include every relevant scenario (like setting the supply after exhausting it) in your test suite and running those tests locally. I released this tool a few weeks ago that will be helpful for that.
This error isn't related to this library though. The transaction was created and signed correctly, and that's why it got included Ropsten's blockchain and appears on etherscan. The failure comes from the contract's code, so I'm closing this issue.
yes making payable works thanks
I have deployed my following contract to ropsten network, making some transaction ok. when I consumed all my tokens (totalSupply) and confirmed it. After confirmation, i call setTotalSupply. But when i called setTotalSupply (through making trx with value =0, value=100gwei or without value parameter .. all are in vein... my error is given below;
and here is my .js file
var Tx = require('ethereumjs-tx').Transaction const Web3 = require('web3'); const provider = new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/7fb0bdc97cbe419fbdf969............."); const web3 = new Web3(provider); const contractAddress1 = '0x66CfBc4C8fC163faf502715963C12216188D4Be1' const contractABI = [{"constant":true,"inputs":[],"name":"getBalance","..............; var contract1 = new web3.eth.Contract(contractABI, contractAddress1) var tx ; var serializedTx; var raw ="raw"; var txObject; const txData1 = contract1.methods.buyToken().encodeABI(); const txData2 = contract1.methods.setTotalSupply(6).encodeABI(); const abiData='0x60806040526040..............'; setTotalSupply(contractAddress1, txData2);
function setTotalSupply(contractAddress, txData){
web3.eth.getTransactionCount(account3, (err, txCount) => { txObject = { nonce: web3.utils.toHex(txCount), gasLimit: web3.utils.toHex(1000000), gasPrice: web3.utils.toHex(web3.utils.toWei('100', 'gwei')), to: contractAddress, value: web3.utils.toHex(web3.utils.toWei('100', 'gwei')), data:txData } tx = new Tx(txObject, {chain:'ropsten', hardfork: 'petersburg'}) tx.sign(privateKey3) serializedTx = tx.serialize() raw = '0x' + serializedTx.toString('hex') web3.eth.sendSignedTransaction (raw, (err, txHash)=> { console.log('err:', err) console.log('txHash', txHash) }) }) } ERROR: