Skip to main content
formatting fixes
Source Link
Malone
  • 1.6k
  • 12
  • 23

In solidity code I have function addPhase and it works well. The code below also works well

for (let j = 0; j < companies[i].phases.length; j++) {
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

But if I try to estimate gas consumption

for (let j = 0; j < companies[i].phases.length; j++) {
    let call_data_phase = this.contract.addPhase.getData(
        companies[i].phases[j].start_time,
        companies[i].phases[j].prices_in_wei,
        companies[i].phases[j].prices_in_wei_ends,
        companies[i].phases[j].tokens_count,
        companies[i].phases[j].min_tokens_to_sell
    );
    let gas_needed_phase = Web3Helpers.web3.eth.estimateGas({
        data: call_data_phase,
        to: this.contract.address,
        from: sender
    });
    console.log("Gas estimation=" + gas_needed_phase);
    
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

I get error gas required exceeds allowance or always failing transaction. I use similar code for other functions and gas estimation works well. Have anyboby

Has anybody seen something like this andand what cancould it be?

In solidity code I have function addPhase and it works well. The code below also works well

for (let j = 0; j < companies[i].phases.length; j++) {
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

But if I try to estimate gas consumption

for (let j = 0; j < companies[i].phases.length; j++) {
    let call_data_phase = this.contract.addPhase.getData(
        companies[i].phases[j].start_time,
        companies[i].phases[j].prices_in_wei,
        companies[i].phases[j].prices_in_wei_ends,
        companies[i].phases[j].tokens_count,
        companies[i].phases[j].min_tokens_to_sell
    );
    let gas_needed_phase = Web3Helpers.web3.eth.estimateGas({
        data: call_data_phase,
        to: this.contract.address,
        from: sender
    });
    console.log("Gas estimation=" + gas_needed_phase);
    
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

I get error gas required exceeds allowance or always failing transaction. I use similar code for other functions and gas estimation works well. Have anyboby seen something like this and what can it be?

In solidity code I have function addPhase and it works well. The code below also works well

for (let j = 0; j < companies[i].phases.length; j++) {
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

But if I try to estimate gas consumption

for (let j = 0; j < companies[i].phases.length; j++) {
    let call_data_phase = this.contract.addPhase.getData(
        companies[i].phases[j].start_time,
        companies[i].phases[j].prices_in_wei,
        companies[i].phases[j].prices_in_wei_ends,
        companies[i].phases[j].tokens_count,
        companies[i].phases[j].min_tokens_to_sell
    );
    let gas_needed_phase = Web3Helpers.web3.eth.estimateGas({
        data: call_data_phase,
        to: this.contract.address,
        from: sender
    });
    console.log("Gas estimation=" + gas_needed_phase);
    
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

I get error gas required exceeds allowance or always failing transaction. I use similar code for other functions and gas estimation works well.

Has anybody seen something like this and what could it be?

Source Link
Alexey Barsuk
  • 2.3k
  • 2
  • 17
  • 25

Using web3.eth.estimateGas cause "gas required exceeds allowance or always failing transaction"

In solidity code I have function addPhase and it works well. The code below also works well

for (let j = 0; j < companies[i].phases.length; j++) {
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

But if I try to estimate gas consumption

for (let j = 0; j < companies[i].phases.length; j++) {
    let call_data_phase = this.contract.addPhase.getData(
        companies[i].phases[j].start_time,
        companies[i].phases[j].prices_in_wei,
        companies[i].phases[j].prices_in_wei_ends,
        companies[i].phases[j].tokens_count,
        companies[i].phases[j].min_tokens_to_sell
    );
    let gas_needed_phase = Web3Helpers.web3.eth.estimateGas({
        data: call_data_phase,
        to: this.contract.address,
        from: sender
    });
    console.log("Gas estimation=" + gas_needed_phase);
    
    transactions.push(
        this.contract.addPhase(
            companies[i].phases[j].start_time,
            companies[i].phases[j].prices_in_wei,
            companies[i].phases[j].prices_in_wei_ends,
            companies[i].phases[j].tokens_count,
            companies[i].phases[j].min_tokens_to_sell,
            Web3Helpers.sender_envelope(sender,10000000000)));
}

I get error gas required exceeds allowance or always failing transaction. I use similar code for other functions and gas estimation works well. Have anyboby seen something like this and what can it be?