Skip to content

Instantly share code, notes, and snippets.

View EtDu's full-sized avatar

ET EtDu

  • Canada
View GitHub Profile
pragma solidity ^0.5.0;
contract Cheque {
mapping (uint => bool) usedNonces;
address owner;
constructor() public payable {
owner = msg.sender;
}
}
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);
}
pragma solidity ^0.5.0;
contract Cheque {
mapping (uint => bool) usedNonces;
address owner;
constructor() public payable {
owner = msg.sender;
}
pragma solidity ^0.5.0;
contract Cheque {
mapping (uint => bool) usedNonces;
address owner;
constructor() public payable {
owner = msg.sender;
}
pragma solidity ^0.5.0;
contract Cheque {
mapping (uint => bool) usedNonces;
address owner;
constructor() public payable {
owner = msg.sender;
}
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()
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
}
}
}
const Cheque = artifacts.require("./Cheque.sol");
module.exports = function (deployer) {
deployer.deploy(Cheque, { value: 1e18 });
};
pragma solidity ^0.5.17;
import "./SafeMath.sol";
import "./provableAPI.sol";
contract LeaseGenerator is usingProvable {
using SafeMath for uint;
address payable landlordAddress;
address payable tenantAddress;
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;