This file contains hidden or 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
await stubHelper.putState(verifiedArgs.key, car, {privateCollection: 'carCollection'}); |
This file contains hidden or 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
async queryPrivateCar(stubHelper: StubHelper, args: string[]) { | |
const verifiedArgs = await Helpers.checkArgs<any>(args[0], Yup.object() | |
.shape({ | |
key: Yup.string().required(), | |
})); | |
const car = await stubHelper.getStateAsObject(verifiedArgs.key, {privateCollection: 'carCollection'}); | |
if (!car) { | |
throw new NotFoundError('Car does not exist'); |
This file contains hidden or 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
### Keybase proof | |
I hereby claim: | |
* I am michielmulders on github. | |
* I am michielmulders (https://keybase.io/michielmulders) on keybase. | |
* I have a public key ASB9UR_k4yrvwvtGSf6dTRRvrRkO2yL1dXCUHUnM-VJkego | |
To claim this, I am signing this object: |
This file contains hidden or 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
bool private stopped = false; | |
address private owner; | |
modifier isAdmin() { | |
if(msg.sender != owner) { | |
throw; | |
} | |
_ | |
} |
This file contains hidden or 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
contract RateLimit { | |
uint enabledAt = now; | |
modifier enabledEvery(uint t) { | |
require(now >= enabledAt, "Access is denied. Rate limit exceeded."); | |
enabledAt = now + t; | |
_; | |
} | |
This file contains hidden or 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
/* | |
The following code is a part of the smart contract patterns library: | |
http://www.github.com/blockchaindev/smart-contract-patterns | |
*/ | |
contract speed_bump { | |
function speed_bump() { | |
allowed_time = 0; | |
} | |
modifier allow_every(uint t) { |
This file contains hidden or 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
struct RequestedWithdrawal { | |
uint amount; | |
uint time; | |
} | |
mapping (address => uint) private balances; | |
mapping (address => RequestedWithdrawal) private requestedWithdrawals; | |
uint constant withdrawalWaitPeriod = 28 days; // 4 weeks | |
function requestWithdrawal() public { |
This file contains hidden or 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
contract LimitBalance { | |
uint256 public limit; | |
function LimitBalance(uint256 value) public { | |
limit = value; | |
} | |
modifier limitedPayable() { | |
require(this.balance <= limit); |
This file contains hidden or 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 auctionEnd() public { | |
// 1. Checks | |
require(now >= auctionEnd); | |
require(!ended); | |
// 2. Effects | |
ended = true; | |
// 3. Interaction |
This file contains hidden or 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 csv = require('csvtojson') | |
const StellarSdk = require('stellar-sdk'); | |
// TODO - set up keypair and server | |
async bulkSubmit(fileName) { | |
const rows = await csv().fromFile(csvFilePath); | |
for(const row of rows) { | |
const {source, dest, amount} = row; |