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
dawn
applicationIf 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.
đ¸ 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:
Go to remix.ethereum.org
Compile
Peggy.sol
withsolc v0.5.0
Set the environment as
Injected Web3 Ropsten
On 'Run' tab, select Peggy and enter
"0x22BFD920Ac64B0A90088D07f84137EA79bbb8Ca1"
in 'At Address' field
Select 'At Address' to load the deployed contract
Enter the following for the variables under function
lock()
:
Enter the same number from
_amount
as the transaction's value (in wei)
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
(ietendermint/crypto
) is needed for compatability withgo-ethereum
. See theGopkg.toml
for constraint details. There is an open pull request totendermint/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