Skip to content

Repository files navigation

DREP CLI

DREP Command Line Interface, a JSON-RPC based client for connecting to the DREP chain to query information on the chain and send transactions.

Features

  1. Provides a decentralized ID system and data privacy protection
  2. Integrates the underlying chain with both smart contracts and novel smart reputation pipes.
  3. Provides the DREP reputation protocols and reputation templates.
  4. Has high performance and high compatibilities.

Installation

Binaries (Windows/Linux/macOS)

Executable binaries can be downloaded from our GitHub page

Build from source code (all platforms)

Clone the repository into the appropriate $GOPATH/src/github.com/drep-project directory.

NOTE: requires Go >= 1.1.11.

 git clone https://github.com/drep-project/drepcli.git
cd drepcli
go install

Usage

To start the DREP Cli

 drepcli http://127.0.0.1:15645

After the DREP Cli is started, it will connect to the DREP chain. Meanwhile, you can input commands into the interface and perform operations to the chain.

APIs

Blocks and balances

[{
Data: {
TxCount: 1,
TxList: [{
Data: {...},
Sig: null
}]
},
Header: {
ChainId: "33333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330",
GasLimit: "RWORgkT0AAA=",
GasUsed: "",
Height: 10,
LeaderPubKey: "0x0258fc6797a561c701ca2c1336b4ea641745bd427319c50e82fa044c8a85b18616",
MerkleRoot: "miMn/oiEs+F7TYCzjRmm7Yj9SvqRK1UxdW8pNJnyXYU=",
MinorPubKeys: ["0x0242901062c10d36702cdf75330f74a597ef8058245027a5d2d993418c089fd704", "0x027d6958df8109037eab3fb5f2ca2b03ddf5f1952eed1348f8019c29437770b150"],
PreviousHash: "e94imdsJSiPBxu3GqRJJ0DsJwOjzLePIx99aEcnMUqQ=",
StateRoot: "kovoW3vQnm4jgiwOeMxNzwlAwzpEdvraCpdrLqiKUDI=",
Timestamp: 1547280876,
TxHashes: ["miMn/oiEs+F7TYCzjRmm7Yj9SvqRK1UxdW8pNJnyXYU="],
Version: 1
},
MultiSig: {
Bitmap: "AQE=",
Sig: {
R: 3.7142117789744075e+76,
S: 9.782885030459428e+75
}
}
}...]
  • getBalance
MethodgetBalance
Parameters1: Address
2: Chain id
DescriptionGet the account's balance with respect to the address
ReturnsNumber
Exampledb.getBalance("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b",0)
Example Return0
  • getBlock
MethodgetBlock
ParametersBlock height
DescriptionGet the corresponding block
ReturnsObject
Exampledb.getBlock(10)
{
Data: {TxCount: 1,TxList: [{Data: {...},
Sig: null}]},Header: {ChainId: "33333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330",GasLimit: "RWORgkT0AAA=",GasUsed: "",Height: 10,LeaderPubKey: "0x0258fc6797a561c701ca2c1336b4ea641745bd427319c50e82fa044c8a85b18616",MerkleRoot: "miMn/oiEs+F7TYCzjRmm7Yj9SvqRK1UxdW8pNJnyXYU=",MinorPubKeys: ["0x0242901062c10d36702cdf75330f74a597ef8058245027a5d2d993418c089fd704", "0x027d6958df8109037eab3fb5f2ca2b03ddf5f1952eed1348f8019c29437770b150"],PreviousHash: "e94imdsJSiPBxu3GqRJJ0DsJwOjzLePIx99aEcnMUqQ=",StateRoot: "kovoW3vQnm4jgiwOeMxNzwlAwzpEdvraCpdrLqiKUDI=",Timestamp: 1547280876,TxHashes: ["miMn/oiEs+F7TYCzjRmm7Yj9SvqRK1UxdW8pNJnyXYU="],Version: 1},MultiSig: {Bitmap: "AQE=",Sig: {R: 3.7142117789744075e+76,S: 9.782885030459428e+75}}}
  • getBlocksFrom
MethodgetBlocksFrom
Parameters1:The height of the first block to get
2:The number of the blocks to get
DescriptionGet the blocks between two heights
ReturnsArray
Exampledb.getBlocksFrom(10,2)
[{
Data: {TxCount: 1,TxList: [{...}]
},Header: {ChainId: "33333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330",GasLimit: "RWORgkT0AAA=",GasUsed: "",Height: 10,LeaderPubKey: "0x0258fc6797a561c701ca2c1336b4ea641745bd427319c50e82fa044c8a85b18616",MerkleRoot: "miMn/oiEs+F7TYCzjRmm7Yj9SvqRK1UxdW8pNJnyXYU=",MinorPubKeys: ["0x0242901062c10d36702cdf75330f74a597ef8058245027a5d2d993418c089fd704", "0x027d6958df8109037eab3fb5f2ca2b03ddf5f1952eed1348f8019c29437770b150"],PreviousHash: "e94imdsJSiPBxu3GqRJJ0DsJwOjzLePIx99aEcnMUqQ=",StateRoot: "kovoW3vQnm4jgiwOeMxNzwlAwzpEdvraCpdrLqiKUDI=",Timestamp: 1547280876,TxHashes: ["miMn/oiEs+F7TYCzjRmm7Yj9SvqRK1UxdW8pNJnyXYU="],Version: 1},MultiSig: {Bitmap: "AQE=",Sig: {R: 3.7142117789744075e+76,S: 9.782885030459428e+75}}}, ...]
  • getByteCode
MethodgetByteCode
Parameters1:Address
2:Chain id
Descriptionget bytecode of a stored smart contract by its address and chainID
ReturnsArray
Examplechain.check("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b","0x00")
  • getCodeHash
MethodgetCodeHash
Parameters1:Address
2:Chain id
Descriptionget the bytecode hash value of a smart contract by its address and chainID
ReturnsArray
Examplechain.check("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b","0x00")
  • getHighestBlock
MethodgetHighestBlock
ParametersNone
DescriptionGet latest block
ReturnsObject
Exampledb.getHighestBlock()
{
Data: {TxCount: 1,TxList: [{Data: {...},
Sig: null}]},Header: {ChainId: "33333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330",GasLimit: "RWORgkT0AAA=",GasUsed: "",Height: 1018,LeaderPubKey: "0x0258fc6797a561c701ca2c1336b4ea641745bd427319c50e82fa044c8a85b18616",MerkleRoot: "v1M3UKxS9xoaIMraw/UlYlBb7o+4vMkgLgGuUfUXlf8=",MinorPubKeys: ["0x0242901062c10d36702cdf75330f74a597ef8058245027a5d2d993418c089fd704", "0x027d6958df8109037eab3fb5f2ca2b03ddf5f1952eed1348f8019c29437770b150"],PreviousHash: "mCK7fbNwQpGUcVwqgYnH2Ea0a8gwbf2irAHdZqH3xYQ=",StateRoot: "1oGeQV/LDejnVqb9Q4uovyAiQvoYzan3FRFqJGHkq/U=",Timestamp: 1547288016,TxHashes: ["v1M3UKxS9xoaIMraw/UlYlBb7o+4vMkgLgGuUfUXlf8="],Version: 1},MultiSig: {Bitmap: "AQE=",Sig: {R: 8.467045644602432e+76,S: 9.513484500254109e+75}}}
  • getMaxHeight
MethodgetMaxHeight
ParametersNone
DescriptionGet current block's height
ReturnsNumber
Example Returndb.getMaxHeight()
  • getMostRecentBlocks
MethodgetMostRecentBlocks
ParametersThe number of the newest blocks
DescriptionGet newest blocks data via the number parameter
ReturnsArray
Exampledb.getMostRecentBlocks(2)
[{
Data: {TxCount: 1,TxList: [{...}]
},Header: {ChainId: "33333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330333333303333333033333330",GasLimit: "RWORgkT0AAA=",GasUsed: "",Height: 1,LeaderPubKey: "0x0258fc6797a561c701ca2c1336b4ea641745bd427319c50e82fa044c8a85b18616",MerkleRoot: "oRDZuhaSx/h2IlTXgEvSdGIUzln/V50MZIxK/PlVgrg=",MinorPubKeys: ["0x0242901062c10d36702cdf75330f74a597ef8058245027a5d2d993418c089fd704", "0x027d6958df8109037eab3fb5f2ca2b03ddf5f1952eed1348f8019c29437770b150"],PreviousHash: "IsZzW/wWnPD9zt1b+gQAd0mvyNzx/fmEtHsjEDiX+QE=",StateRoot: "jdME0UFb2ooUd84ymQMAQeTMhl/xuQZmb5uDlFv6RaA=",Timestamp: 1547291143,TxHashes: ["oRDZuhaSx/h2IlTXgEvSdGIUzln/V50MZIxK/PlVgrg="],Version: 1},MultiSig: {Bitmap: "AQE=",Sig: {R: 7.159555199205425e+76,S: 6.394261149473947e+76}}}]
  • getNonce
MethodgetNonce
Parameters1:Address
2:Chain id
DescriptionGet value fo nonce in the chain via address and chain id
ReturnsNumber
Exampledb.getNonce("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b","0x00")

Chain

  • me
Methodme
ParametersNone
DescriptionGet information about yourself
ReturnsObject
Example Returnchain.me()
{
addr: "0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b",balance: 0,chainId: 0,nonce: 0
}
  • check
Methodcheck
Parameters1: Address
2: Chain id
DescriptionGet information of the chain via address
ReturnsObeject
Examplechain.check("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b","0x00")
{
Balance: 0,ByteCode: null,CodeHash: "0x0000000000000000000000000000000000000000000000000000000000000000",Nonce: 0,Reputation: 0
}
  • checkNonce
MethodcheckNonce
ParametersAddress
DescriptionGet nonce via address
ReturnsNumber
Examplechain.checkNonce("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b")
  • checkBalance
MethodcheckBalance
ParametersAddress
DescriptionGet balance via address
ReturnsNumber
Examplechain.checkBalance("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b")
  • create
Methodcreate
ParametersThe code of contract
DescriptionCreate contract
ReturnsString
Examplechain.create("60806040523480...")
  • call
Methodcall
Parameters1:Address
2:Chain id
3:Contract address
4:Amount
5:Whether the read-only
DescriptionInvoke contract
ReturnsString
Example Returnchain.call("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b","0x00","511bede065df9c06e98ca75df9f0584f48a0a4f31a66104a5c8095377d69a60f","10",false)
  • send
MethodgetAllBlocks
Parameters1:Adress
2:Chain id
3:Amount
DescriptionGet data of all the blocks
ReturnsArray
Examplechain.send("0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b","0x00","10")

Account

  • addressList
MethodaddressList
ParametersNone
DescriptionPrint the list of local accounts
ReturnsArray
Exampleaccount.addressList()
["0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b"]
  • createAccount
MethodcreateAccount
ParametersNone
DescriptionCreate account
ReturnsString
Exampleaccount.createAccount()
0x772dec19e0b0b2d63a57a3a7fb03fc066d915e6b
  • dumpPrikey
MethoddumpPrikey
ParametersAddress
DescriptionExport privekey
ReturnsString
Exampleaccount.dumpPrikey()
  • open
Methodopen
ParametersPassword
DescriptionOpen wallet
ReturnsNone
Exampleaccount.open()
  • close
Methodclose
ParametersNone
DescriptionClose wallet
ReturnsNone
Exampleaccount.close()
  • lock
Methodlock
ParametersNone
DescriptionLock password
ReturnsNone
Exampleaccount.lock()
  • unLock
Methodopen
ParametersPassword
DescriptionUnlock wallet
ReturnsNone
Exampleaccount.unLock()

License

The drep-cli library is licensed under the GNU Lesser General Public License v3.0.

About

DREP Command Line Interface

Resources

Stars

28 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages