Hi @Duende
Please check this FAQ that will guide you to post readable code in the forum: FAQ - How to post code in the forum
Let’s consider your code:
pragma solidity 0.7.5;
contract myfirstbank {
mapping (address =>uint) balance;
balance[msg.sender] amount
function withdraw (uint amount) public returns uint {
require (balance [msg.sender] => amount “not enough funds”;
}
function deposit (uint amount) public returns uint{
require msg.sender.transfer(amount);
return balance[msg.sender];
}
Not sure what you meant to do this this line:
balance[msg.sender] amount
-
amount
is not defined; - the syntax is wrong as
balance[msg.sender]
does not point to a struct that has a property calledamount
, also the;
is missing at the end of the line.
function withdraw (uint amount) public returns uint {
require (balance [msg.sender] => amount “not enough funds”;
}
The function correctly checks that the balance of msg.sender is higher than the amount that msg.sender wants to withdraw, but then nothing happens in the function.
There is a syntax error in the require statement because you are missing the closing )
.
function deposit (uint amount) public returns uint{
require msg.sender.transfer(amount);
return balance[msg.sender];
The function deposit should payable
because you want to send Ether to it.
The function deposit should not transfer amount
to msg.sender
, you want to do that in the withdraw function.
There is a syntax error because you did not close the final }
.
You should also increase and decrease balance[msg.sender] in your deposit and withdraw functions.
Check it out and let me know
Happy learning,
Dani