KCoin Project
Pull request is welcome and appreciated.
To contribute source codes to KCoin, basically you need to:
kaiyuanshe/kcoin
project to your personal accountgit clone https://github.com/<your github account>/kcoin.git
KCoin consists of two components, a standard ruby web server and a java-based backend server as a proxy to forward blockchain requests to HyperLeger. See below for details.
Below are quick steps to setup dev environment for the web:
rvm
is recommended.curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.4.0
rvm list
Run ruby -version
to make sure it's ready
cd kcoin/src/web
bundle install
cp lib/config-sample.rb lib/config.rb
lib/config.rb
and update config values like github oauth secret.
CONFIG = {
github: {
client_id: 'xxxxxxxxxxxxx',
client_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
sign_event: true
},
server: {
url: 'http://localhost:8080'
},
email: {
form: 'notification@kaiyuanshe.org',
address: 'smtp.exmail.qq.com',
port: 587,
helo: 'qq.com',
user: 'notification@kaiyuanshe.org',
secret: '<Your email password here>',
account: 'notification@kaiyuanshe.org'
}
}.freeze
When you apply for github oauth,you need to set callback url:
'http://localhost:9292/auth/github/callback'
If you forget it,plese delete 'src/web/kcoin.sqlite' and try again.
puma -C config/puma_local.rb
puma -C config/puma_local.rb
and browse http://localhost:9292/
Install RubyMine or VS Code, or any other preferred IDE first. Open <repo>\src\web
.
To start/debug in RubyMime, add a new Rack configuration with default parameters.
lib/config-sample.rb
is just a sample. Changing values in this file makes no difference to your running app. You need to copy the contents to lib/config.rb
and update config values to adapt your local environment. In case you add any new config item, add to the sample file first. Don't push lib/config.rb
to github. It's ignored by default.config/migrations
. Never alter table schema directly in existing migration files. That's because migration of the same name only gets executed once.invoke
API if you need to write any data into blockchain, or query
API if read data only. See src/web/helpers/fabric_helpers.rb
for example.KCoin is built on several popular ruby frameworks:
KCoin uses HyperLedger to persist token and token history. At the same time uses sqlite to store user profile, github project metadata and so on. Data in sqlite can be edited and deleted. But data in HyperLedger cannot be revoked or deleted.
In your local dev environment, you can download DB Browser for SQLite or CLI tool sqlite3
to view (and edit) your local data.
The JFinal-based backend server is only a proxy for HyperLedger because HyperLedger doesn't have a Ruby SDK. In most cases, you only want to run the server without changing any Java source codes. But if you want learn about the details, about the hierarchy of backend server, see KCoin Server Guide
<repo>/src/server/src/main/resources/fabric
. Never push the certificates to github in any form
/etc/hosts
(Linux) or C:\Windows\System32\drivers\etc\hosts
(Windows). Note that the IP 117.78.50.99
and DNS might change in future when time goes by. Update hosts file if needed. See <repo>/src/server/src/main/resources/config.properties
for the latest IP address, and kcoin-sdk-config-dev.yaml
for latest DNS(usually part of url
config).117.78.48.87 orderer-81efaa2f8ec402ad2c8743d99c0609550d4ca2f0-0.orderer-81efaa2f8ec402ad2c8743d99c0609550d4ca2f0.default.svc.cluster.local
117.78.48.87 peer-51809cd89ab98256de47e9908c70c588a8e4db01-0.peer-51809cd89ab98256de47e9908c70c588a8e4db01.default.svc.cluster.local
mvn jetty:run
in command line. Or run Maven task in inteliJ IDEA or Eclipse.curl -vvv -H "Content-Type:application/json" -X POST --data '{"fn":"balance", "args":["symbol","owner"]}' http://localhost:8080/fabric/query
. If responded http status code is 200, it's working and running as expected. Otherwise you may need to debug in IDE or call for dev team for help.curl ...
in commandline, you can download API test tool such as PostMan for easier testingChaincode is one of key concepts in HyperLedger which is written in GO language. See https://hyperledger-fabric.readthedocs.io/en/release-1.2/chaincode4ade.html for more.
KCoin deploys chaincode to Huawei BCS. The process of develop and deploy chaincode:
<repo>/src/server/src/resources/chaincode/kctoken.go
<repo>/src/server/chaincode.MD
which also includes how to guide about how to test chaincode locallykctoken.go
and have it well tested in your local environment.<repo>/src/server/src/main/resources/config.properties
Some other things to be aware of:
MIT
Copyright (c) Kaiyuanshe
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。