Git Product home page Git Product logo

js-ethereum-libp2p's Introduction

js-ethereum-libp2p

Coverage Status Travis CI Circle CI Dependency Status js-standard-style

Get the ethereum blockchain in the Browser or in a Node.js process using libp2p and run through it using ethereum-vm. This is the humble starts of getting a full ethereum node running in JavaScript that can interact with the rest of the network.

BEWARE BEWARE BEWARE

This module is a work in progress! So beware of dragons! 🐲 πŸ‰

Description

Example

Usage

Install

API

Ethereum Node Class: Ethereum.Node

Create an Ethereum Node: const eth = new Ethereum.Node()

Start the node: eth.start([PeerInfo], callback)

Stop the node: eth.stop(callback)

libp2p: eth.libp2p

See ipfs/js-libp2p-ipfs for documentation.

BlockChain: eth.blockchain

Synchronize (fetch) the latest state of the blockchain eth.blockchain.sync([PeerInfo], callback)

Synchronizes the BlockChain, fetching every block in the network.

Virtual Machine eth.vm

Instance of ethereumjs-vm, see ethereumjs/ethereumjs-vm for docs.

Blocks

WIP

Send a block

Broadcast a block

Transactions

WIP

Send a transaction

Broadcast a transaction

License

MIT Β© David Dias

js-ethereum-libp2p's People

Contributors

daviddias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

js-ethereum-libp2p's Issues

design

@dignifiedquire @victorbjelkholm could you help me with getting a good looking webpage for the demo?

Currently I've the skeleton which looks like this:

image

You can get to this page by:

git clone [email protected]:diasdavid/js-ethereum-libp2p.git
cd js-ethereum-libp2p
npm i
cd examples/webui 
npm i
npm run mon
# open localhost:9001

And the inspiration is to get something close to:
image

With an extra column (on the left for)

  • 2 buttons one for "simulation" and another for "🌟" that execute two different functions
  • An accounts box - This accounts box needs to be a map of {hash: balance} and I need to be able to set and reset given the hash
  • A peers box - This is where we will be showing the peers connected through libp2p. So it will be a list of multiaddrs

With regards to blocks, a block looks like this:

{ header:
   { parentHash: '0x2ce94342df186bab4165c268c43ab982d360c9474f429fec5565adfc5d1f258b',
     uncleHash: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
     coinbase: '0xdd2f1e6e498202e86d8f5442af596580a4f03c2c',
     stateRoot: '0xe208bde4aebc06bbd749674bee4b6ea7eb0c90b2bd950e2bc67f11b4669d93df',
     transactionsTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
     receiptTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
     bloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
     difficulty: '0x03ff7fc008',
     number: '0x09',
     gasLimit: '0x1388',
     gasUsed: '0x',
     timestamp: '0x55ba42a3',
     extraData: '0x476574682f76312e302e302d30636463373634372f6c696e75782f676f312e34',
     mixHash: '0x75588cae5e63ea1ef3cebb72b06b983b5c18c078389d4a5134ac302181fd27b4',
     nonce: '0x5b2575f3f38a1310' },
  transactions: [],
  uncleHeaders: [] }

And I want to be able to show its number, timestamp and its parentHash. Blocks should be ordered ascending by number.

As for transactions, some blocks will have transactions. Still working on getting them properly exposed, will come back later with more info.

You can see an example of where the blocks come from at: https://github.com/diasdavid/js-ethereum-libp2p/blob/master/examples/run-through-blockchain/example.js

This is what will be running in the browser (the blocks will come through libp2p, instead of being loaded by a generated pre-set)

Feel free to change the whole setup of the page to React, if that makes you more productive and able to ship it on time.

getting transactions and state of the accounts

@wanderer, I'm not getting to see any Tx coming on the beforeBlock and the afterBlock only returns an object with empty values. beforeTx and afterTx never fires, but I guess that is natural since we are not issuing transactions.

I guess I can take the real transactions from the block itself. Is there a way to see "what accounts do I know and what balance do these accounts have"?

update 1 - Getting subscriptions through go-ethereum/libp2p

@wanderer @kumavis we've managed (me and @whyrusleeping) to get transactions to come through a go-ethereum+go-libp2p build to the node.js js-ethereum-libp2p.

image

You can try it by running this custom go-ethereum build - https://gist.github.com/whyrusleeping/b5e6a22a1369581ae6bd22260148caa1 and then running this script https://github.com/diasdavid/js-ethereum-libp2p/blob/master/examples/rx.js

We also added a way to fetch blocks from this go-ethereum/libp2p, attaching that to the js-ethereum-libp2p tomorrow :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.