Giter Club home page Giter Club logo

node's Introduction

CE Beacon Chain

CE Beacon Chain is a blockchain with a flexible set of native assets and pluggable modules. It uses tendermint for consensus and app logic is written in golang. It targets fast block times, a native dApp layer and multi-token support with no smart contract VM.

Reference Discord

Beacon Chain has the basic features of most blockchains:

  • Sending and receiving CE and digital assets
  • Issuing new digital assets (we have a standard called BEP-2)
  • Mint/burn, freeze/unfreeze, lock/unlock of digital assets

It has DEX and trading-specific functionality:

  • Propose exchange listing for trading pairs
  • Creating maker/taker orders for traders
  • Listing assets from other chains using atomic swaps (BEP-3)

Overview

  • This uses BFT consensus so up to 1/3 of all validator nodes can be rogue or bad.
  • Validator nodes are part of the "validator set" so they are known, trusted and controlled by the network.
  • Full nodes are not validator nodes, but anyone can get a copy of the whole blockchain and validate it.
  • No PoW means block times are very fast.
  • UXTO/account does not matter as we just use the cosmos bank.
  • Features like the DEX will run directly on the node as apps written in golang.

Read more about Tendermint and ABCI.

Getting Started

Environment setup

If you do not have golang yet, please install it or use brew on macOS: brew install go and brew install dep.

Mac & Linux

$ export GOPATH=~/go
$ export PATH=~/go/bin:$PATH
$ export CECHAINPATH=~/go/src/github.com/Mustafa-Agha/node
$ mkdir -p $CECHAINPATH
$ git clone [email protected]:ce-chain/node.git $CECHAINPATH
$ cd $CECHAINPATH
$ make build

Windows

If you are working on windows, GOPATH and PATH should already be set when you install golang. You may need add CECHAINPATH to the environment variables.

> md %CECHAINPATH%
> git clone git@github.com:ce-chain/node.git %CECHAINPATH%
> cd %CECHAINPATH%
> make build

To test that installation worked, try to run the cli tool:

$ cecli

Start the blockchain

This command will generate a keypair for your node and create the genesis block config:

$ cechaind init
$ cat ~/.cechaind/config/genesis.json

You may want to check the Issuing assets section below before you start, but this is how to start the node and begin generating blocks:

$ cechaind start --moniker ${YOURNAME}

If everything worked you will see blocks being generated around every 1s in your console.

Reset

When you make a change you probably want to reset your chain, remember to kill the node first.

$ cechaind unsafe_reset_all

Join mainnet/testnet

Please refer to the document for joining mainnet or testnnet.

Assets

Issuing assets

Assets may be issued through cecli while the blockchain is running; see here for an example:

$ cecli tokens issue ce -n ce -s 100000

This will post a transaction with an IssueMsg to the blockchain, which contains the data needed for token issuance.

Checking a balance

Start your node, then list your keys as below:

$ cecli keys list
All keys:
pepe    B71E119324558ABA3AE3F5BC854F1225132465A0
you     DEBF30B59A5CD0111FDF4F86664BC063BF450A1A

Check a balance with this command, e.g.:

$ cecli account DEBF30B59A5CD0111FDF4F86664BC063BF450A1A

Alternatively through http when cecli api-server is running. Amounts are returned as decimal numbers in strings.

$ curl -s http://localhost:8080/balances/cosmosaccaddr173hyu6dtfkrj9vujjhvz2ayehrng64rxq3h4yp | json_pp
{
   "address" : "cosmosaccaddr173hyu6dtfkrj9vujjhvz2ayehrng64rxq3h4yp",
   "balances" : [
      {
         "symbol" : "CE",
         "free" : "2.00000000",
         "locked" : "0.00000000",
         "frozen" : "0.00000000"
      },
      {
         "symbol" : "XYZ",
         "free" : "0.98999900",
         "locked" : "0.00000100",
         "frozen" : "0.00000000"
      }
   ]
}

Sending assets

You have to send a transaction to send assets to another address, which is possible with the cli tool:

Make sure chain-id is set correctly; you can find it in your genesis.json.

$ cecli send --chain-id=$CHAIN_ID --name=you --amount=1000mycoin --to=B71E119324558ABA3AE3F5BC854F1225132465A0 --sequence=0
Password to sign with 'you': xxx
Committed at block 88. Hash: 492B08FFE364D389BB508FD3507BBACD3DB58A98

You can look at the contents of the tx, use the tx hash above:

$ cecli tx 492B08FFE364D389BB508FD3507BBACD3DB58A98

Then you can check the balance of pepe's key to see that he now has 1000 satoshi units of mycoin:

$ cecli account B71E119324558ABA3AE3F5BC854F1225132465A0
{
  "type": "16542275FBFAB8",
  "value": {
    "BaseAccount": {
      "address": "B71E119324558ABA3AE3F5BC854F1225132465A0",
      "coins": [
        {
          "denom": "mycoin",
          "amount": 1000
        }
      ],
      ...
    },
    ...
  }
}

Amounts are represented as ints, and all coins have a fixed scale of 8. This means that if a balance of 100000000 were to be shown here, that would represent a balance of 1 coin.

DEX

Placing an order

$ cecli dex order -i uniqueid1 -l XYZ_CE -s 1 -p 100000000 -q 100000000 --from me --chain-id=$CHAIN_ID -t 1

Viewing the order book

$ cecli dex show -l XYZ_CE

Alternatively through http when cecli api-server is running. Prices and quantities are returned as decimal numbers in strings.

$ curl -s http://localhost:8080/api/v1/depth?symbol=XYZ_CE&limit=5 | json_pp
{"asks":[["0.00000000","0.00000000"],["0.00000000","0.00000000"],["0.00000000","0.00000000"],["0.00000000","0.00000000"],["0.00000000","0.00000000"]],"bids":[["0.10000000","1.00000000"],["0.00000000","0.00000000"],["0.00000000","0.00000000"],["0.00000000","0.00000000"],["0.00000000","0.00000000"]]}

Contribution

It is welcomed to contribute to this repo from everyone. If you'd like to contribute, please fork, fix, commit and submit a pull request to review and merge into the main code base. Please make sure your contributions adhere to our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. please use gofmt tool).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Pull requests need to be based on and opened against the master branch.

node's People

Contributors

mustafa-agha avatar

Watchers

 avatar

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.