Dawn Chain

This Cosmos-based blockchain powers the FirstBlood decentralized eSports platform.

πŸ› οΈ Development

Ensure you use gofmt so that golang files match expected language standards. The plugin for Sublime is here https://packagecontrol.io/packages/Gofmt

If you get errors compiling because it can't find modules, some may be private currently. This explains how to solve it https://stackoverflow.com/a/44247040

πŸ“¦ Golang Modules

This repository uses golang modules. Learn more here https://cosmos.network/docs/tutorial/gomod.html and here https://github.com/golang/go/wiki/Modules

🏎️ Building and running the dawn application

If you want to build the dawn application in this repo to see the functionalities, Go 1.12.1+ is required .

Add some parameters to environment is necessary if you have never used the go mod before.

mkdir -p $HOME/go/bin
echo "export GOPATH=$HOME/go" >> ~/.bash_profile
echo "export GOBIN=\$GOPATH/bin" >> ~/.bash_profile
echo "export PATH=\$PATH:\$GOBIN" >> ~/.bash_profile
echo "export GO111MODULE=on" >> ~/.bash_profile
source ~/.bash_profile

πŸ›Έ Example application

These modules can be added to any Cosmos-SDK based chain, but a demo application/blockchain is provided with example code for how to integrate them. It can be installed and built as follows:

πŸ”§ Running and testing the application

First, initialise a chain and create accounts to test sending of a random token.

πŸŽ›οΈ Using the application from rest-server

First, run the cli rest-server

An api collection for Postman (https://www.getpostman.com/) is provided here which documents some API endpoints and can be used to interact with it. Note: For checking account details/balance, you will need to change the cosmos addresses in the URLs, params and body to match the addresses you generated that you want to check.

πŸ•ΉοΈ Running the relayer service

For automated relaying, there is a relayer service that can be run that will automatically watch and relay events.

The relayer will now watch the contract on Ropsten and create a claim whenever it detects a lock event.

πŸŒ‰ Using the bridge

With the application set up and the relayer running, you can now use Peggy by sending a lock transaction to the smart contract. You can do this from any Ethereum wallet/client that supports smart contract transactions.

The easiest way to do this for now, assuming you have Metamask setup for Ropsten in the browser is to use remix or mycrypto as the frontend, for example:

    1. Compile Peggy.sol with solc v0.5.0

    1. Set the environment as Injected Web3 Ropsten

    1. On 'Run' tab, select Peggy and enter "0x22BFD920Ac64B0A90088D07f84137EA79bbb8Ca1" in 'At Address' field

    1. Select 'At Address' to load the deployed contract

    1. Enter the following for the variables under function lock():

    1. Enter the same number from _amount as the transaction's value (in wei)

    1. Select "transact" to send the lock() transaction

Then, wait for the transaction to confirm and mine, and for the relayer to pick it up. You should see the successful output in the relayer console. You can also confirm the tokens have been minted by using the CLI again:

πŸ‘¨β€πŸ’» Using the modules in other projects

The ethbridge and oracle modules can be used in other cosmos-sdk applications by copying them into your application's modules folders and including them in the same way as in the example application. Each module may be moved to its own repo or integrated into the core Cosmos-SDK in future, for easier usage.

There are 2 nuances you need to be aware of when using these modules in other Cosmos-SDK projects.

  • A specific version of golang.org/x/crypto (ie tendermint/crypto) is needed for compatability with go-ethereum. See the Gopkg.toml for constraint details. There is an open pull request to tendermint/crypto to add compatibility, but until that is merged you need to use the customized version (https://github.com/tendermint/crypto/pull/1)

  • The govendor steps in the application as above are needed

For instructions on building and deploying the smart contracts, see here.

Last updated

Was this helpful?