Skip to content

Instantly share code, notes, and snippets.

@gabrielkirsten
Last active April 22, 2021 21:13
Show Gist options
  • Save gabrielkirsten/b6ba14bd13f40939f5a62c4c011ccf38 to your computer and use it in GitHub Desktop.
Save gabrielkirsten/b6ba14bd13f40939f5a62c4c011ccf38 to your computer and use it in GitHub Desktop.
POC loan (solidity)
pragma solidity >=0.7.0 <0.9.0;
contract loan {
address payable lender;
address payable borrower;
uint totalcents;
uint payed;
uint interest;
// Loan creation
constructor (uint _interest, address payable _borrower) payable {
lender = payable(msg.sender);
borrower = _borrower;
totalcents = msg.value + interest;
interest = _interest;
payed = 0;
borrower.transfer(msg.value);
}
function viewbalance() public view returns(uint) {
return totalcents;
}
function makepayment() public payable {
totalcents -= msg.value;
payed += msg.value;
lender.transfer(msg.value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment