Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. pragma solidity ^0.5.1;
  2. contract Borrower{
  3. enum Status{open,funded,closed}
  4. struct BorrowerRequest{
  5. uint requestId;
  6. address account;
  7. string borrowerName;
  8. uint reqAmt;
  9. string location;
  10. uint mobile;
  11. Status status;
  12. bool exists;
  13. }
  14.  
  15. uint maxAmt;
  16. constructor() public{
  17. maxAmt=10000;
  18. }
  19. uint TotalRequests=0;
  20. mapping(uint=>BorrowerRequest) public borrowerRequestDetails;
  21. function createRequest(string memory borrowerName,uint reqAmt,string memory location,uint mobile) public {
  22. TotalRequests++;
  23. require(reqAmt<=maxAmt);
  24. borrowerRequestDetails[TotalRequests]=BorrowerRequest(TotalRequests,msg.sender,borrowerName,reqAmt,location,mobile,Status.open,true);
  25. }
  26.  
  27. function updateRequest(uint requestId,string memory borrowerName,uint reqAmt,string memory location,uint mobile) public {
  28. require( borrowerRequestDetails[requestId].exists);
  29. require(reqAmt<=maxAmt);
  30. borrowerRequestDetails[requestId]=BorrowerRequest(requestId,msg.sender,borrowerName,reqAmt,location,mobile,Status.open,true);
  31. }
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement