The Solidity Contract-Oriented Programming Language - By chatting here you agree to the https://github.com/ethereum/solidity/blob/develop/CODE_OF_CONDUCT.md
contract Coop {
IERC20 public token;
struct Cooperant {
uint256 feePayed;
uint256 kg;
uint256 received;
}
// map of cooperant addresses to structs
mapping (address => Cooperant) cooperants;
address[] public cooperantAdresses;
constructor () public {
//proveriti
token = new COOPToken("COOP token", "COOP", 18, 1_000_000_000_000_000_000);
}
// fund COOP with yearly fee
function fundCoop() public payable returns (bool) {
cooperants[msg.sender].feePayed += msg.value;
cooperantAdresses.push(msg.sender);
return true;
}
function depositFruitsToCOOP(uint256 _kg) public returns (bool) {
token.transfer(address(this), msg.sender, _kg);
cooperants[msg.sender].kg += _kg;
cooperants[msg.sender].received += _kg;
return true;
}
function getCOOPBalance() public view returns (uint256, uint256) {
return (address(this).balance, token.balanceOf(address(this)));
}
function getUserAccountBalance() public view returns (uint256, uint256,uint256, uint256){
return (cooperants[msg.sender].feePayed, cooperants[msg.sender].kg, cooperants[msg.sender].received, token.balanceOf(msg.sender));
}
function getUsersAddresses() public view returns (address[]memory) {
return cooperantAdresses;
}
}