bytom

module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2017 License: AGPL-3.0

README

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

Directories

Path Synopsis
accesstoken
Package accesstoken provides storage and validation of Chain Core credentials.
Package accesstoken provides storage and validation of Chain Core credentials.
account
Package account stores and tracks accounts within a Chain Core.
Package account stores and tracks accounts within a Chain Core.
pin
pseudohsm
Package pseudohsm provides a pseudo HSM for development environments.
Package pseudohsm provides a pseudo HSM for development environments.
query
Package query implements indexing and querying of annotated blockchain data.
Package query implements indexing and querying of annotated blockchain data.
query/filter
Package filter parses and evaluates Chain filter expressions.
Package filter parses and evaluates Chain filter expressions.
rpc
signers
Package signers associates signers and their corresponding keys.
Package signers associates signers and their corresponding keys.
txbuilder
Package txbuilder builds a Chain Protocol transaction from a list of actions.
Package txbuilder builds a Chain Protocol transaction from a list of actions.
txdb/internal/storage
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.
cmd
Package common contains various helper functions.
Package common contains various helper functions.
bech32
Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.
Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.
ed25519
Package ed25519 implements the Ed25519 signature algorithm.
Package ed25519 implements the Ed25519 signature algorithm.
sha3pool
Package sha3pool is a freelist for SHA3-256 hash objects.
Package sha3pool is a freelist for SHA3-256 hash objects.
encoding
base32
Package base32 implements base32 encoding as specified by RFC 4648.
Package base32 implements base32 encoding as specified by RFC 4648.
blockchain
Package blockchain provides the tools for encoding data primitives in blockchain structures
Package blockchain provides the tools for encoding data primitives in blockchain structures
bufpool
Package bufpool is a freelist for bytes.Buffer objects.
Package bufpool is a freelist for bytes.Buffer objects.
Package env provides a convenient way to convert environment variables into Go data.
Package env provides a convenient way to convert environment variables into Go data.
Package errors implements a basic error wrapping pattern, so that errors can be annotated with additional information without losing the original error.
Package errors implements a basic error wrapping pattern, so that errors can be annotated with additional information without losing the original error.
lib
math
checked
Package checked implements basic arithmetic operations with underflow and overflow checks.
Package checked implements basic arithmetic operations with underflow and overflow checks.
Package metrics provides convenient facilities to record on-line high-level performance metrics.
Package metrics provides convenient facilities to record on-line high-level performance metrics.
net
http/httperror
Package httperror defines the format for HTTP error responses from Chain services.
Package httperror defines the format for HTTP error responses from Chain services.
http/httpjson
Package httpjson creates HTTP handlers to map request and response formats onto Go function signatures.
Package httpjson creates HTTP handlers to map request and response formats onto Go function signatures.
http/reqid
Package reqid creates request IDs and stores them in Contexts.
Package reqid creates request IDs and stores them in Contexts.
http/static
Package static provides a handler for serving static assets from an in-memory map.
Package static provides a handler for serving static assets from an in-memory map.
p2p
Uses nacl's secret_box to encrypt a net.Conn.
Uses nacl's secret_box to encrypt a net.Conn.
upnp
Taken from taipei-torrent Just enough UPnP to be able to forward ports
Taken from taipei-torrent Just enough UPnP to be able to forward ports
bc
Package bc is a generated protocol buffer package.
Package bc is a generated protocol buffer package.
bc/bctest
Package bctest provides utilities for constructing blockchain data structures.
Package bctest provides utilities for constructing blockchain data structures.
patricia
Package patricia computes the Merkle Patricia Tree Hash of a set of bit strings, as described in the Chain Protocol spec.
Package patricia computes the Merkle Patricia Tree Hash of a set of bit strings, as described in the Chain Protocol spec.
vm
sync
idempotency
Package idempotency provides a duplicate function call suppression mechanism.
Package idempotency provides a duplicate function call suppression mechanism.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL