Coder Social home page Coder Social logo

artooze / bytom Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bytomdao/bytom

0.0 2.0 0.0 30.09 MB

Official Go implementation of the Bytom protocol

Home Page: https://bytom.io/

License: GNU Affero General Public License v3.0

Makefile 0.04% Go 99.96%

bytom's Introduction

Bytom

Build Status AGPL v3

Table of Contents

What is Bytom?

Bytom is software designed to operate and connect to highly scalable blockchain networks confirming to the Bytom Blockchain Protocol, which allows partipicants to define, issue and transfer digitial assets on a multi-asset shared ledger. Please refer to the White Paper for more details.

In the current state bytom is able to:

  • Issue assets
  • Manage account as well as asset
  • Spend assets

Build from source

Requirements

  • Go version 1.8 or higher, with $GOPATH set to your preferred directory

Installation

Ensure Go with the supported version is installed properly:

$ go version
$ go env GOROOT GOPATH

Get the source code

$ git clone https://github.com/Bytom/bytom $GOPATH/src/github.com/bytom

Build

  • Bytomd
$ cd $GOPATH/src/github.com/bytom
$ make install
$ make bytomd
  • Bytomcli
$ cd $GOPATH/src/github.com/bytom/cmd/bytomcli
$ make bytomcli

Example

Currently, bytom is still in active development and a ton of work needs to be done, but we also provide the following content for these eager to do something with bytom.

Create and launch a single node

When successfully building the project, the bytom and bytomcli binary should be present in cmd/bytomd and cmd/bytomcli directory, respectively. The next step is to initialize the node:

$ cd ./cmd/bytomd
$ ./bytomd init

After that, you'll see .bytom generated in current directory, then launch the single node:

$ ./bytomd node --wallet.enable

Given the bytom node is running, the general workflow is as follows:

  • create an account
  • create an asset
  • create/sign/submit a transaction to transfer an asset
  • query the assets on-chain

Create an account

Create an account named alice:

$ ./bytomcli create-account alice
xprv:<alice_account_private_key>
responses:<create-account-responses>
account id:<alice_account_id>

Check out the new created account:

$ ./bytomcli list-accounts

Create an asset

Create an asset named gold:

$ ./bytomcli create-asset gold
xprv:<gold_asset_private_key>
xpub:<gold_asset_public_key>
responses:<create-asset-responses>
asset id:<gold_asset_id>

Check out the new created asset:

$ ./bytomcli list-assets

Asset issuance test

Since the account alice and the asset gold are ready, we need to create another account bob, which is also neccessary for the following Expenditure test:

$ ./bytomcli create-account bob

Firstly, Alice issue <issue_amount>, e.g., 10000, gold:

$ ./bytomcli sub-create-issue-tx <alice_account_id> <bob_account_id> <gold_asset_id> <gold_asset_private_key> <issue_amount>

When the transaction above is mined, query the balances:

# Alice should have 10000 gold now
$ ./bytomcli list-balances

Expenditure test

  • Alice -> Bob

Alice pays Bob <payment_amount>, e.g., 1000, gold:

$ ./bytomcli sub-spend-account-tx <alice_account_id> <bob_account_id> <gold_asset_id> <alice_private_key> <payment_amount>
# In our case, after Alice pays Bob 1000 gold, the amount of Alice's gold should be 9000, Bob's balances should be 1000
$ ./bytomcli list-balances
  • Bob -> Alice

Bob pays Alice <payment_amount>, e.g., 500, gold:

$ ./bytomcli sub-spend-account-tx <bob_account_id> <alice_account_id> <gold_asset_id> <bob_private_key> <payment_amount>
# In our case, after Bob pays Alice 500 gold, the amount of Alice's gold should be 9500, Bob's balances should be 500
$ ./bytomcli list-balances

Set up a wallet and manage the key

If you have started a bytom node, then you can create an account via create-key password, which will generate a keystore directory containing the keys under the project directory.

$ ./bytomcli create-key account_name password   # Create an account named account_name using password
$ ./bytomcli delete-key password pubkey         # Delete account pubkey
$ ./bytomcli reset-password oldpassword newpassword pubkey  # Update password

Multiple node

Get the submodule depenency for the two-node test:

$ git submodule update --init --recursive

Create the first node bytomd0 and second node bytomd1:

$ cd cmd/bytomd/2node-test
$ ./test.sh bytomd0  # Start the first node
$ ./test.sh bytomd1  # Start the second node

Then we have two nodes:

$ ./bytomcli net-info
net-info:map[listening:true listeners:[Listener(@192.168.199.43:3332)] peers:[map[node_info:map[listen_addr:192.168.199.43:3333 version:0.1.2 other:[wire_version=0.6.2 p2p_version=0.5.0] pub_key:D6B76D1B4E9D7E4D81BA5FAAE9359302446488495A29D7E70AF84CDFEA186D66 moniker:anonymous network:bytom remote_addr:127.0.0.1:51036] is_outbound:false connection_status:map[RecvMonitor:map[Start:2017-10-30T13:45:47.18+08:00 Bytes:425130 AvgRate:27010 Progress:0 Active:true Idle:1.04e+09 Samples:42 InstRate:4591 CurRate:3540 PeakRate:114908 BytesRem:0 TimeRem:0 Duration:1.574e+10] Channels:[map[RecentlySent:5332 ID:64 SendQueueCapacity:100 SendQueueSize:0 Priority:5]] SendMonitor:map[Active:true Idle:1.24e+09 Bytes:16240 Samples:41 CurRate:125 AvgRate:1032 Progress:0 Start:2017-10-30T13:45:47.18+08:00 Duration:1.574e+10 InstRate:147 PeakRate:4375 BytesRem:0 TimeRem:0]]]]]

Running Bytom in Docker

Ensure your Docker version is 17.05 or higher.

$ docker build -t bytom .

Contributing

Thank you for considering to help out with the source code! Any contributions are highly appreciated, and we are grateful for even the smallest of fixes!

If you run into an issue, feel free to file one in this repository. We are glad to help!

License

AGPL v3

bytom's People

Contributors

gguoss avatar colt-z avatar icodezjb avatar langyu avatar liuchengxu avatar zhouyasong avatar jeason-ustc avatar paladz avatar yahtoo avatar detailyang avatar wliyongfeng avatar

Watchers

James Cloos avatar  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.