the following execution of my smart contract function runs out of Gas on the Ropsten network, but works fine on Rinkeby, do you have an idea why this happens?

struct vehicleData{
        string status;
        uint timestamp;
        string mileage;
        string gps_position;
        string soc_relative;
        uint soc_absolute;
        string sessionId;

    mapping(string => vehicleData) private data;

    function setVehicleData(string memory vin, string memory status, uint timestamp, string memory mileage, string memory gps_position, string memory soc_relative, uint soc_absolute, string memory sessionId) public{
        data[vin] = vehicleData(status,timestamp,mileage,gps_position,soc_relative,soc_absolute,sessionId);

this is what I do in my Javascript Code:

const gasLimit = 100000;
const gasPrice = '2';
    const txObject = {
                nonce: web3.utils.toHex(txcount),
                gasLimit: web3.utils.toHex(gasLimit),
                gasPrice: web3.utils.toHex(web3.utils.toWei(gasPrice, 'gwei')),
                to: storeAndCheckAddress,
                data: contractStoreAndCheck.methods.setVehicleData(vin, status, timestamp, mileage, gps, soc_relative, soc_absolute, sessionId).encodeABI()
            const tx = new Tx(txObject)
            //sign transaction with private key from sender

            const serializedTx = tx.serialize()
            const raw = '0x' + serializedTx.toString('hex')

            //send tx
            web3.eth.sendSignedTransaction(raw,function(error,result){if(!error){return result}else{console.log(error)}});

Success on Rinkeby: https://rinkeby.etherscan.io/tx/0x86c3cfc3a5fb058810cc1854b6231b51224346e9fdd2ef835b336dff0e3796a4

Failure on Ropsten: https://ropsten.etherscan.io/tx/0xd48a369d549b8248383f5bd4bcf937cd1c727b6393bf2e7609ae6013258b11a6

  • The code is different between the two, so that seems like a more likely culprit than a difference between the networks (though that's also possible). – user19510 Apr 10 at 19:00
  • I did check the code with a text diff tool and it is the same.. where have you spotted a difference? – Felix Apr 10 at 19:08
  • mileage is a string in Ropsten and uint in Rinkeby. – user19510 Apr 10 at 19:14
  • Thank you so much - I would have checked for ages. Deployed a new contract to all networks, but forgot to change the address for Rinkeby in the Code. Somehow for my text comparison I used the new contract, thats why i didn't see the difference. – Felix Apr 10 at 19:19
  • Now both run out of gas - do you see why that can be the case? – Felix Apr 10 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.