Ethereum: Why is my contribute method failing with “missing revert data”?
Ethereum: Why is my contribute method failing with “missing revert data”?


Ethereum: Why my contribution method fails with the "missing return data"

As a developer who works on an intelligent solidity contract for an initial currency offer (ico), you have probably encountered various problems that can prevent the success of your project. ”, Which affect the functionality of certain methods of contribution. In this article, we will deepen what causes this error and provide guidance on how to solve the contract.


what does 'missing reeart date' mean?

In Ethereum, he re -attends the event when an invalid or unpoported state is Encountered During a Transaction. This can happen for various reasons, including:


  • Invalid or missing contract data

    Ethereum: Why is my contribute method failing with

    : If the internal variables of the contract are not correctly initialized, it can trigger a return.


  • Invalid functional calls



    : functions that do not comply with the standard syntax of solitude or use incorrect types of parameters can cause return.


  • Non -finalized state variables : If the condition of the contract is not properly established before using certain functions, it can lead to return.


Why does my method of contribution fail with the "lacking data"?

Suppose your contribution method looks like this:

`Solidity

Pragma solidity ^0.6,0;

TokeenContribator contract {

The address of the public owner;

Uint Public Balance = 0;

// function to contribute with tokens

Function Function () Public paid {

Request (msg.value> = 1 ether, "invalid input");

IF (balance> 0) {

Request (MSG.Value == Balance * 1 Ether, "tokens must be equal to the initial amount");

Balance += msg.value;

} else {

// add a return condition here

}

}

}

`

In this example, the "contribution" function checks whether the user has contributed sufficient chips and if their contribution is equal to the initial value. However, there is no "retard" statement that manages the cases in which an invalid or missing state is encountered.


Error "missing return data" **

If your contract meets a revert event, it will interrupt the execution and return the control of the caller with an error message indicating that the entrance is invalid or the state has changed. This can make your contribution method fail if not properly managed.

For example, let's say you try to contribute 100 tokens, but get a return:

Solidity

Pragma solidity ^0.6,0;

TokeenContribator contract {

The address of the public owner;

Uint Public Balance = 0;

// function to contribute with tokens

Function Function () Public paid {

Request (msg.value> = 1 ether, "invalid input");

IF (balance> 0) {

Request (MSG.Value == Balance * 100 Ether, "Chips must be equal to the initial amount");

Balance += msg.value;

} else {

// return the status here

return();

}

}

}

`

In this case, when a user tries to contribute with 100 chips, but receives an invalid return message, their contribution method will fail and stop the execution.


Solving the problem of "missing return data"

To solve this problem, you need to addStatements' Statements in the functions of your contract that can cause return. Here are some suggestions:


  • Add a return condition at the beginning of each function : This ensures that an error is thrown if invalid or missing state variables are encountered.

`Solidity

Pragma solidity ^0.6,0;

TokeenContribator contract {

The address of the public owner;

Uint Public Balance = 0;

// function to contribute with tokens

Function Function () Public paid {

Request (msg.value> = 1 ether, "invalid input");

IF (balance> 0) {

Request (MSG.Value == Balance * 100 Ether, "Chips must be equal to the initial amount");

Balance += msg.

Ethereum Getting Reason Invalid Reason

Leave a Reply

Your email address will not be published. Required fields are marked *