Skip to content

Instantly share code, notes, and snippets.

View jsphdnl's full-sized avatar

Bharath Kadaluri jsphdnl

View GitHub Profile
@jsphdnl
jsphdnl / Token.sol
Last active January 22, 2018 09:16
BasicToken
pragma solidity ^0.4.18;
contract TRexCoin {
//Coin name
string public name = "TRexCoin";
///Symbol
string public symbol = "TRC";
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply = 1000000;
@jsphdnl
jsphdnl / BlockChain1.js
Created January 9, 2018 13:32
BlockChain from Scratch Part 01 - javascript
var crypto = require('crypto')
, shasum = crypto.createHash('sha1');
/*
* Install "cyrpto" lib dependeny to compute the hash
* `npm install crypto`
*/
class TRBlock {
/**
* constructor for creating a block
@jsphdnl
jsphdnl / BlockChain_1.java
Created January 9, 2018 12:54
BlockChain from Scratch Part 01 - java
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
@jsphdnl
jsphdnl / BlockChain_1.java
Created January 9, 2018 12:54
BlockChain from Scratch Part 01 - java
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
@jsphdnl
jsphdnl / blockchain_1.py
Created January 9, 2018 12:40
BlockChain from Scratch Part 01 - python
import hashlib
import json
class TRBlock(object) :
def __init__(self, index, timestamp, data, prevHash, nonce, target):
'''
Default constructor for creating a block.
Parameters
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
class SHA1Gen1 {
public static final String SHA1 = "SHA-1";
/**
* Encode data in base64 string
* @param data data in bytes
* @return a string in base64 format