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.5.0; | |
contract Cheque { | |
mapping (uint => bool) usedNonces; | |
address owner; | |
constructor() public payable { | |
owner = msg.sender; | |
} | |
} |
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
function claimPayment(uint amount, uint nonce, bytes memory sig) public { | |
require(!usedNonces[nonce], "Nonce has already been used"); | |
usedNonces[nonce] = true; | |
bytes32 message = prefixed(keccak256(abi.encodePacked(msg.sender, amount, nonce, this))); | |
require(recoverSigner(message, sig) == owner, "Signer is not owner"); | |
msg.sender.transfer(amount); | |
} |
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.5.0; | |
contract Cheque { | |
mapping (uint => bool) usedNonces; | |
address owner; | |
constructor() public payable { | |
owner = msg.sender; | |
} |
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.5.0; | |
contract Cheque { | |
mapping (uint => bool) usedNonces; | |
address owner; | |
constructor() public payable { | |
owner = msg.sender; | |
} |
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
module.exports = { | |
networks: { | |
development: { | |
host: "127.0.0.1", | |
port: 8545, | |
network_id: "*", | |
} | |
} | |
} |
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.5.0; | |
contract Cheque { | |
mapping (uint => bool) usedNonces; | |
address owner; | |
constructor() public payable { | |
owner = msg.sender; | |
} |
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
const Web3 = require('web3') | |
const web3 = new Web3('ws://localhost:8545') | |
const fs = require('fs'); | |
const rawCheque = fs.readFileSync('./build/contracts/Cheque.json') | |
const parsedCheque = JSON.parse(rawCheque) | |
const contractAddress = parsedCheque.networks['5777'].address | |
let signPayment = async (recipient, amount) => { | |
const accounts = await web3.eth.getAccounts() |
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
const Cheque = artifacts.require("./Cheque.sol"); | |
module.exports = function (deployer) { | |
deployer.deploy(Cheque, { value: 1e18 }); | |
}; |
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
constructor () public payable { | |
landlordAddress = msg.sender; | |
provable_setCustomGasPrice(100000000000); | |
OAR = OracleAddrResolverI(0xB7D2d92e74447535088A32AD65d459E97f692222); | |
} | |
function fetchUsdRate() internal { | |
require(provable_getPrice("URL") < address(this).balance, "Not enough Ether in contract, please add more"); | |
bytes32 queryId = provable_query("URL", "json(https://api.pro.coinbase.com/products/ETH-USD/ticker).price"); | |
validIds[queryId] = true; |
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
function payLease() public payable { | |
Lease storage lease = tenantLease[msg.sender]; | |
require(lease.leaseDepositPaid, "Lease deposit must be paid before making lease payments"); | |
require(!lease.leaseFullyPaid, "Lease has already been fully paid"); | |
require(lease.leasePaymentWindowEnd >= now, "Lease payment must fit into payment window"); | |
tenantAddress = msg.sender; | |
tenantPayment = msg.value; | |
workingState = State.payingLease; | |
fetchUsdRate(); |
OlderNewer