Skip to content
A BlockChain based around pokemon, made for fun.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
data
imgs
src
LICENSE
README.md
package-lock.json
package.json

README.md

PokeChain

A from-scratch block chain, drawing inspiration from Nimiq. Made to inspire you to collect all the pokemon

Features

  • SHA256 encryption
  • Pokemon based collectible cryptocurrency
  • Bitcoin based blockchain
  • Basic tamper prevention including chain reversion on faulty block creation

Usage

Require file

const pokechain = require('pokechain');

"Create" a wallet

//You have 2 options to create a key/wallet, based on the private key. You can use an eliptic curve to create one
var newkey = pokechain.generatekey(); //uses 'secp256k1' curve by default
console.log(newkey);
var key = newkey;

//Alternatively you can pass a custom string/privatekey to generate a keyset. Highly recommended to have a large string to increase security
var key = pokechain.grabKey('Enter a private key here');

//Public key is their address, should be known by whoever he wants to interact with 
const curraddr = key.getPublic('hex');

//Ensure user remembers private key, and is secret to them
//It will be needed for transactions. 

Mine a block

//Miner is awarded 6 pokemon
//This mines using the server. Looking into client side mining.
var result = pokechain.mineTransactions(curraddr);
console.log(result); //Returns "Transaction Complete!" or an error

Find "Balance"

//This crawls the blockchain, finding all transactions involving the curraddr, and consolidating down as needed
//Json array object
var userbox = pokechain.getUserbox(curraddr);

Create a transaction

//If you need a a pokemon id to trade:
//Had issues when not using JSON.parse - to fix
var pokemonid = JSON.parse(userbox[0]);
pokemonid = pokemonid.id;

//Create transaction
pokechain.addTransaction(curraddr, recievingaddr, pokemonid, key);

Config

//Recommended to change location for accessibility and prevent overwriting
"Main": {
   "blockchainfile": "./data/blockchain.json",
   "Difficulty": 2
 }
 //Change available pokemon
 {
 "Pokemon": {
   "MinID": 1,    //based on pokedex, this is bulbasaur
   "MaxID": 809,  //based on pokedex, this is melmetal. change to 151 if you want just gen 1
   "ShinyMin": 0,    //Update shiny odds. Generates a random number. If the number == 420, is shiny
   "ShinyMax": 8191, //Odds match that of actual games. Update for special events if you want
   "StatsMin": 0,    //Update IV odds. IVs are from 0-31. 
   "StatsMax": 31    //Update for special events if you want. 31 is "perfect"
 },

Contributions

Any and all contributions/feedback welcome!

You can’t perform that action at this time.