This is how far I made it till now without using the template and trying all on my own. At the moment I am a bit stuck. Also I get error messages, but only with solidity 0.8.9; If i use 0.7.5 the same errorws do not appear. Do some of you know what I did wrong? I´ll mark the error messages with comments inside the code. Thanks in advance for your feedback.
pragma solidity 0.8.9;
contract WalletProject{
mapping(address => uint) balance;
address payable public owner;
modifier onlyOwner{
require(msg.sender == owner);
_;
}
//admin is defined
address[] public admins;
//Add an Admin to the adminArray
function addAdmin(address _admin)public onlyOwner{
admins.push(_admin);
}
//modifier for admins
modifier onlyAdmin{
require(msg.sender == admins);
//Error; Operator == not compatible with this adress type.
_;
}
//Admins can approve the transaction here
function approveTransaction() public onlyAdmin{
}
//modifer for approved transaction
//Here are the functions for the regular Enduser.
function deposit() public payable returns (uint){
balance[msg.sender] += msg.value;
return balance[msg.sender];
}
//Withdraw would need an array to save the transaction history and then approve those transactions.
function withdraw(uint amount) public payable returns (uint){
require(balance[msg.sender] >= amount, "Error! Not enough ETH!");
balance[msg.sender] -= amount;
msg.sender.transfer(amount);
//Error .transfer is not available.
return balance[msg.sender];
}
function transfer(address recipient, uint amount) public {
require(balance[msg.sender] >= amount, "Balance not sufficient");
require(msg.sender != recipient, "Don't transfer money to yourself");
uint previousSenderBalance = balance[msg.sender];
balance[msg.sender] -= amount;
balance[recipient] += amount;
assert(balance[msg.sender] == previousSenderBalance - amount);
}
}