npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

luotuocoin

v1.0.3

Published

A blockchain for educational purpose

Downloads

24

Readme

GitHub Issues GitHub Pull Requests Downloads HitCount License


⚠️ 本项目仅作为了解区块链及区块链入门教学使用 For educational purpose only

测试覆盖率(Test Coverage)

| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | | ------------- | ------- | -------- | ------- | ------- | ----------------- | | All files | 96.15 | 88.46 | 100 | 96.05 | | blockChain.js | 96.15 | 88.46 | 100 | 96.05 | 76,133,168 |

功能(Features)

  • 工作量证明机制(Proof of Work, PoF)的简单实现, A simple implementation of the Proof of Work algorithm.
  • 区块链的验证, Block chain validation to prevent it from being maliciously tampered.
  • Transaction 的签名. Sign transactions.
  • 钱包地址生成. Wallet generation.
  • 挖矿. Mining

🦊 开始 Let's get started

祝学习愉快。 Happy Learning. All the demo can be found in bilibiliDemo folder. 所有的视频里的示例都可以在 bilibiliDemo 的文件夹里找到

安装依赖(Install dependencies)

npm install --save
yarn

如果作为依赖安装, it's published to npm, so if you want to install it as an dependency, please use

npm install --save luotuocoin
or
yarn add luotuocoin

运行测试用例(Run tests)

npm run test
or
yarn test

生成一个密钥对(Generate your wallet)(bilibiliDemo/encryption/keygen.js)

密钥对讲用于发起转账,公钥(public key)会用作你的钱包地址,私钥(private key)会用来生成转账的数字签名。 The keypair will be used for signing transactions(private key) and receving miner rewards/transactions, public key will be your wallet address.

const ecLib = require("elliptic").ec;
const ec = new ecLib("secp256k1"); // curve name
const sha256 = require("crypto-js/sha256");
// 生成我们的密钥对 generate the keypair
const key = ec.genKeyPair();
// 拿到我们的私钥和公钥 希望拿到hex string格式的
console.log("private", key.getPrivate("hex"));
console.log("public", key.getPublic("hex"));

创建区块链(Create Blockchain)

const { chain, transaction } = require("luotuocoin");
const myCoin = new chain();

发起转账(Create Transaction)

利用上述步骤生成的keypair object, use the keypair object generated above

// 发起一笔转给to 10块钱的交易
// create a transaction that transfer 10 coin to address 'to'
const transaction = new Transaction(key.getPublic("hex"), "to", 10);
transaction.sign(key);
myCoin.addTransaction(transaction);

挖矿(Mine)

同样需要利用之前生成的 key object,将公钥作为参数传入挖矿的方法,如果你最后挖矿成功,区块链会向这个地址发放一个矿工奖励。 Using the same keypair object, passin the public key to receive the minder reward.

myCoin.mineTransactionPool(key.getPublic("hex"));

📽 视频教程(Video tutorial)

本项目均可在 b 站找到视频教程 我的 B 站区块链视频. 第一列视频均为理论讲解,第二列视频均为代码实现。

| 视频 1-1: 区块链概念讲解 | 视频 1-2: 简单区块链的实现 | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | | | | 视频 2-1: 工作量证明机制(pow)概念讲解 | 视频 2-2: 整合 Proof of Work 到区块链 | | | | | 视频 3-1: 数字货币是怎么产生的 | 视频 3-2: 把区块链变成数字货币 | | | | | 视频 4-1: 比特币中的数字签名是什么 | 视频 4-2: 向区块链中添加数字签名 | | | |