Skip to content

DoraFactory/Doge-SDK

Repository files navigation

Doge-SDK

Cosmos Rust SDK for Dear Doge

Interview

Doge SDK is mainly used to start a cosmos-sdk-based blockchain in rust. Due to the fact that Cosmos SDK currently only has Go language version, we have implemented a Rust version of the Cosmos SDK to meet the requirements for different consensus mechanisms(the Go version of the Cosmos SDK is tightly coupled with the tendermint consensus, we have also implemented a separate SDK for starting the application, which is decoupled from the consensus layer). This allows us to test Rust-based consensus mechanisms more effectively. Here, we thank the contributions and inspiration from the gears. We have made some adaptations and improvements to gears to accommodate other consensus mechanisms.

Architecture

The following is the general architecture of our designed implementation of Doge SDK.

image

Requirements

Doge SDK uses the tendermint-abci to communicate between Asynchronous Consensus instance and app, which run as separate process.

  • Rust compiler

The minimum supported Rust version is 1.67.1. Follow the installation instructions.

  • libclang
sudo apt-get install libclang-dev build-essential

Running a local chain

  1. Clone this repo:
git clone https://github.com/DoraFactory/Doge-SDK.git
cd Doge-SDK
  1. Initialize a SDK client:
make init
  1. Build and start the application:
make run

The application will listen for connections on 127.0.0.1:26658.

  1. From a different terminal window start Asynchronous Consensus:
git clone https://github.com/DoraFactory/consensus-abci.git && cd consensus-abci

cargo build --release && ./target/release/hbbft run --abci-server 26668 --rpc-port 26667

Asynchronous Consensus will connect to the application and bind it's RPC server to 127.0.0.1:26657.

The chain (consisting of one node) is now up and running.

How to use Dear SDK

In this section we'll install Ddoged and use it to query the chain (just like cosmos-sdk based chains the Ddoged binary serves as a node and client).

By default, the executable file we compile is named Ddogd and using cosmos address

  1. Install Ddoged:
make install
  1. Query a balance:
Ddoged query bank balances cosmos1syavy2npfyt9tcncdtsdzf7kny9lh777pahuux

which returns:

{
  "balances": [
    {
      "denom": "uatom",
      "amount": "34"
    }
  ],
  "pagination": null
}

The balance of this address was set to 34 in the genesis file.

  1. Import the key corresponding to the above address into the gaia-rs key store:
echo "race draft rival universe maid cheese steel logic crowd fork comic easy truth drift tomorrow eye buddy head time cash swing swift midnight borrow" | Ddoged keys add alice
  1. Send tokens:
Ddoged tx bank send alice cosmos180tr8wmsk8ugt32yynj8efqwg3yglmpwp22rut 10uatom --fee 1uatom
  1. Query the address balance and observe that it has decreased by 11uatom which is the sum of the amount transferred and the fee:
Ddoged query bank balances cosmos1syavy2npfyt9tcncdtsdzf7kny9lh777pahuux

Which returns:

{
  "balances": [
    {
      "denom": "uatom",
      "amount": "23"
    }
  ],
  "pagination": null
}

Resources

Now we do not provide the public rpc and rest api for using. In the near future, we will gradually open it up for testing.

Releases

No releases published

Packages

No packages published

Languages