Estoy tratando de probar un contrato simple para depositar y retirar ether en remix.
Código:
pragma solidity ^0.4.17;
contract EtherInteractionTest {
function withdraw() public {
msg.sender.transfer(address(this).balance);
}
function deposit(uint256 amount) payable public {
require(msg.value == amount);
}
function getBalance() public view returns (uint256) {
return address(this).balance;
}
}
Error:
This is the error I get:
transact to EtherInteractionTest.deposit errored: VM error: revert.
revert The transaction has been reverted to the initial state.
Note: The constructor should be payable if you send value. Debug the transaction to get more information.
Pantalla de remezcla:
¡Gracias por su ayuda!
Su código requiere que sea msg.value
igual al amount
parámetro. Sin embargo, la captura de pantalla de tu remix muestra que estás enviando un tx de valor 0 con una cantidad de 10 como parámetro.
Esto falla la require
declaración y provoca una reversión.
Asegúrese de que su parámetro y el valor de tx sean los mismos.