Created
January 10, 2019 13:53
-
-
Save anshumanv/6e1861386ee22606eba016742c7e338a to your computer and use it in GitHub Desktop.
Playing around with solidity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.22 <0.6.0; | |
contract WorkDone { | |
address owner; | |
struct Donation { | |
address fromAddress; | |
address toAddress; | |
string message; | |
uint value; | |
} | |
struct User { | |
string userName; | |
string info; | |
address userAddress; | |
string email; | |
bool emailConfirmed; | |
// Donation[] donationsRecieved; | |
// Donation[] donationsGiven; | |
} | |
mapping(address => User) public users; | |
modifier isOwner() { require(msg.sender == owner); _; } | |
modifier verifyCaller (address _address) { require (msg.sender == _address); _;} | |
constructor() public { | |
owner = msg.sender; | |
} | |
function donate(address donateTo, uint amount, string memory message) public payable { | |
msg.sender.transfer(msg.value); | |
// users[donateTo].donationsRecieved.push(Donation({fromAddress: msg.sender, toAddress: donateTo, message: message, value: amount})); | |
} | |
function updateProfile(string memory newUsername, string memory newInfo, string memory newEmail) public returns (string memory, string memory, string memory, address){ | |
users[msg.sender].userName = newUsername; | |
users[msg.sender].info = newInfo; | |
users[msg.sender].email = newEmail; | |
return (newUsername, newInfo, newEmail, msg.sender); | |
} | |
function createUser(string memory newUsername, string memory newInfo, string memory newEmail) public { | |
users[msg.sender] = User({ | |
userName: newUsername, | |
email: newEmail, | |
info: newInfo, | |
userAddress: msg.sender, | |
emailConfirmed: false | |
// donationsRecieved: new Donation[](0), | |
// donationsGiven: new Donation[](0) | |
}); | |
} | |
// function getUser() view public returns (User memory userData) { | |
// User storage userData = users[msg.sender]; | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment