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 SHA256 = require('crypto-js/sha256'); | |
class Block { | |
constructor(index, timestamp, data, previousHash = '') { | |
this.index = index; | |
this.previousHash = previousHash; | |
this.timestamp = timestamp; | |
this.data = data; | |
this.hash = this.calculateHash(); | |
this.nonce = 0; |
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
func (t *SimpleChaincode) getHistoryForMarble(stub shim.ChaincodeStubInterface, args []string) sc.Response { | |
if len(args) < 1 { | |
return shim.Error("Incorrect number of arguments. Expecting 1") | |
} | |
marbleName := args[0] | |
fmt.Printf("- start getHistoryForMarble: %s\n", marbleName) |
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
/// @notice Burns `_amount` tokens from `_tokenHolder` | |
/// Sample burn function to showcase the use of the `Burned` event. | |
/// @param _tokenHolder The address that will lose the tokens | |
/// @param _amount The quantity of tokens to burn | |
function burn(address _tokenHolder, uint256 _amount, bytes _userData, bytes _operatorData) public onlyOwner { | |
requireMultiple(_amount); | |
require(balanceOf(_tokenHolder) >= _amount); | |
mBalances[_tokenHolder] = mBalances[_tokenHolder].sub(_amount); | |
mTotalSupply = mTotalSupply.sub(_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
import express from 'express' | |
import bodyParser from 'body-parser' | |
import rp from 'request-promise' | |
import Stellar from 'stellar-sdk' | |
/* Initialize app and configure bodyParser */ | |
const port = process.env.PORT || 4000 | |
const app = express() | |
app.use(bodyParser.json()) |
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
// Define the Smart Contract structure | |
type SmartContract struct { } | |
// Define the car structure, with 4 properties. | |
type Car struct { | |
Make string `json:"make"` | |
Model string `json:"model"` | |
Colour string `json:"colour"` | |
Owner string `json:"owner"` | |
} |
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
// Include the library | |
var nem = require("../../build/index.js").default; | |
// Create an NIS endpoint object | |
var endpoint = nem.model.objects.create("endpoint")(nem.model.nodes.defaultTestnet, nem.model.nodes.defaultPort); | |
// Create a common object holding key | |
var common = nem.model.objects.create("common")("", "Private key"); | |
// Create an un-prepared transfer transaction object |
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 transfer(address _to, uint _value, bytes _data) returns (bool success) |
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
import { Router } from "express"; | |
import logger from "logops"; | |
import * as driver from "bigchaindb-driver"; | |
import conn from "../helpers/bigchaindb"; | |
const base58 = require("bs58"); | |
const cryptoconditions = require("crypto-conditions"); | |
const router = Router(); | |
export default router; |
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.4.0; | |
interface ERC20 { | |
function transferFrom(address _from, address _to, uint _value) public returns (bool); | |
function approve(address _spender, uint _value) public returns (bool); | |
function allowance(address _owner, address _spender) public constant returns (uint); | |
event Approval(address indexed _owner, address indexed _spender, uint _value); | |
} | |
interface ERC223 { |
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
library SafeMath { | |
function mul(uint256 a, uint256 b) internal pure returns (uint256) { | |
uint256 c = a * b; | |
assert(a == 0 || c / a == b); | |
return c; | |
} | |
function div(uint256 a, uint256 b) internal pure returns (uint256) { | |
// assert(b > 0); // Solidity automatically throws when dividing by 0 | |
uint256 c = a / b; |
OlderNewer