0

i´m learning Solidity now, and i saw this code on web but when i try to use the method "Deposito" i receive a error. Someone knows what's that ? (PS.: I try to put the value but every time i chose another value different from 0 don't work).

I was using the remix to test code.

pragma solidity ^0.4.2;

CODE:

mapping (address => uint) private saldos;

function deposito() public returns (uint) {
    saldos[msg.sender] += msg.value;

    // Sem necessidade de "this." ou "self." para variáveis de estado
    // todos as variáveis são inciadas com seu valor default

    LogRealizacaoDeDeposito(msg.sender, msg.value); // dispara evento

    return saldos[msg.sender];
}
New contributor
Davi Mello is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    Since you're trying to deposit "value", your method needs to be "payable", otherwise it cannot accept deposits. – Micky Socaci 4 hours ago
  • Thanks, man that solves the problem. I really need to read the documentation with more attention. ^^ – Davi Mello 4 hours ago

Your Answer

Davi Mello is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.