Skip to content

Commit

Permalink
doc: refine readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
qywang2012 committed Nov 23, 2017
1 parent 2ec4747 commit 2dbe386
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ make build
## Run

### Run seed node
Starting a Nebulas seed node is simple. After the build step above, run command:
Starting a Nebulas seed node is simple. After the build step above, run a command:

```
./neb
```
Expand Down Expand Up @@ -135,7 +136,7 @@ The configuration schema is defined in proto _neblet/pb/config.proto:Config_. To
./neb -c <path>/config-seed.pb.txt
```

Neb supports loading KeyStore file of Ethereum format. KeyStore files from config _key_dir_ are loaded during neb bootstrap. Example testing KeyStore looks like
Neb supports loading KeyStore file in Ethereum format. KeyStore files from config _key_dir_ are loaded during neb bootstrap. Example testing KeyStore looks like

```
{"version":3,"id":"272a46f1-5141-4234-b948-1b45c6708962","address":"555fcb1b7051d3aea5cf2c0167b4e19ed6a4f98d","Crypto":{"ciphertext":"ecd4b817fa9ebed736235476c91dec43e73e0ca3e8d2f13c004725349882fb49","cipherparams":{"iv":"1ab4ed89c95f66e994f183fed23df9f9"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"baef3f92cdde9fd97a00879ce060763101530e9e66e4c75ec74352a41419bde0","n":1024,"r":8,"p":1},"mac":"d8ea471cea8184fb7b19c1563804b85a31a2b3d792dc59ecccdb15dbfb3cebc0"}}
Expand Down Expand Up @@ -178,13 +179,13 @@ time="2017-11-22T15:14:50+08:00" level=info msg="net.start: node start and join
```

## REPL console
Nebulas provides an interactive javascript console, which can invoke all API and management RPC methods. Some management methods may require passphrase. Start console using command:
Nebulas provide an interactive javascript console, which can invoke all API and management RPC methods. Some management methods may require passphrase. Start console using the command:

```
./neb console
```

We have api and admin two schemes to access the consle cmds. Users can quickly enter instructions using the TAB key.
We have API and admin two schemes to access the console cmds. Users can quickly enter instructions using the TAB key.

```
> api.
Expand Down Expand Up @@ -215,7 +216,7 @@ The command parameters of the command line are consistent with the parameters of


## RPC
Nebulas provides both [gRPC](https://grpc.io) and RESTful API, let users interact with Nebulas.
Nebulas provide both [gRPC](https://grpc.io) and RESTful API, let users interact with Nebulas.

#### Endpoint

Expand Down Expand Up @@ -266,16 +267,16 @@ For more details, please refer to [NEB RPC](https://github.com/nebulasio/wiki/bl


## NVM
Nebulas implemented a nvm to run smart contracts like ethereum.NVM provides a javascript runtime environment through v8-engine.Users can write smart contracts by javascript, which is the most popular language for world.
Nebulas implemented an nvm to run smart contracts like ethereum.NVM provides a javascript runtime environment through v8-engine.Users can write smart contracts by javascript, which is the most popular language in the world.

We can deploy and run smart contracts by two rpc methods:
We can deploy and run smart contracts by two RPC methods:

```
SendTransaction()
Call()
```
Now you can create & deploy & call smart contracts directly over HTTP/console just by 'SendTransaction()'.
If you want to create & deploy a smart contracts:
If you want to create & deploy smart contracts:

```
"use strict";
Expand Down Expand Up @@ -333,7 +334,7 @@ module.exports = BankVaultContract;
curl -i -H 'Accept: application/json' -X POST http://localhost:8191/v1/transaction -H 'Content-Type: application/json' -d '{"from":"8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf","to":"8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf","nonce":1,"source":"\"use strict\";var BankVaultContract=function(){LocalContractStorage.defineMapProperty(this,\"bankVault\")};BankVaultContract.prototype={init:function(){},save:function(height){var deposit=this.bankVault.get(Blockchain.transaction.from);var value=new BigNumber(Blockchain.transaction.value);if(deposit!=null&&deposit.balance.length>0){var balance=new BigNumber(deposit.balance);value=value.plus(balance)}var content={balance:value.toString(),height:Blockchain.block.height+height};this.bankVault.put(Blockchain.transaction.from,content)},takeout:function(amount){var deposit=this.bankVault.get(Blockchain.transaction.from);if(deposit==null){return 0}if(Blockchain.block.height<deposit.height){return 0}var balance=new BigNumber(deposit.balance);var value=new BigNumber(amount);if(balance.lessThan(value)){return 0}var result=Blockchain.transfer(Blockchain.transaction.from,value);if(result>0){deposit.balance=balance.dividedBy(value).toString();this.bankVault.put(Blockchain.transaction.from,deposit)}return result}};module.exports=BankVaultContract;", "args":""}'
```
If you succeed in deploying a smart contract, you will get the contract address & transaction hash as response.
Then you can call this samrt contract:
Then you can call this smart contract:

1. get the smart contract address.
2. give the 'function' you want to call.
Expand Down

0 comments on commit 2dbe386

Please sign in to comment.