Open Source Universal Framework for Chains based on Appbase
UFC is open source framework for supporting blockchain service. You can easily create your own blockchain framework using UFC.
- MySQL
- MongoDB
- Email (SMTP)
- Slack (Incoming Webhooks)
- Telegram (Telegram Bot)
- Tendermint (for Cosmos SDK based Blockchain)
- Ethereum (PoC)
UFC is based on appbase-rs. It ported C++ appbase of EOS node. UFC basically uses JSON-RPC server developed by Parity and RocksDB.
UFC provides the plugin to support to save data on MySQL database and MongoDB, and specially if you want to save data on MySQL DB, you could create JSON Schema file on proper path in this project directory. (ex. ufc-appbase/schema/tm_mysql.json) UFC reads the file and automatically creating table and insert query.
UFC has Tendermint and Ethereum Plugin, so if you want to monitor or archive block and tx of Cosmos SDK based blockchain or Ethereum, clone this project and run UFC.
cargo run --package ufc-appbase --bin ufc-appbase -- --config-dir .
curl --location --request POST 'localhost:8080' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"id": 1,
"method": "tm_subscribe",
"params": {
"target": "block",
"sub_id": "cosmoshub-4",
"start_height": 7364551,
"nodes": ["https://cosmoshub-4--lcd--full.datahub.figment.io/apikey/..."]
}
}'
- download MariaDB docker image and run docker image
docker pull mariadb
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mariadb -e MYSQL_DATABASE=ufc --name mariadb mariadb
- edit config.toml or add flag on UFC running command
[tendermint]
block-mysql-sync=true # save cosmos block to mysql db
tx-mysql-sync=true # save cosmos tx to mysql db
[ethereum]
block-mysql-sync=true # save ethereum block to mysql db
tx-mysql-sync=true # save ethereum tx to mysql db
[app]
plugin=["MySqlPlugin"]
or
# add to save cosmos block to mysql db
cargo run --package ufc-appbase --bin ufc-appbase -- --config-dir . --plugin MySqlPlugin --tm-block-mysql-sync
- request to subscribe block or tx
- download MongoDB docker image and run docker image
docker pull mongo
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=mongodb --name mongo
- edit config.toml or add flag on UFC running command
[tendermint]
block-mongo-sync=true # save cosmos block to mongodb
tx-mongo-sync=true # save cosmos tx to mongodb
[ethereum]
block-mongo-sync=true # save ethereum block to mongodb
tx-mongo-sync=true # save ethereum tx to mongodb
[app]
plugin=["MongoPlugin"]
or
# add to save cosmos block to mongo db
cargo run --package ufc-appbase --bin ufc-appbase -- --config-dir . --plugin MongoPlugin --tm-block-mongo-sync
- request to subscribe block or tx
- download RabbitMQ docker image and run docker image
docker pull rabbitmq
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 --restart=unless-stopped -e RABBITMQ_DEFAULT_USER=rabbitmq -e RABBITMQ_DEFAULT_PASS=rabbitmq rabbitmq:management
- edit config.toml or add flag on UFC running command
[tendermint]
block-rabbit-mq-publish=true # publish cosmos block message
tx-rabbit-mq-publish=true # publish cosmos tx message
[ethereum]
block-rabbit-mq-publish=true # publish cosmos block message
tx-rabbit-mq-publish=true # publish cosmos tx message
[app]
plugin=["RabbitPlugin"]
or
# add to publish cosmos block message
cargo run --package ufc-appbase --bin ufc-appbase -- --config-dir . --plugin RabbitPlugin --tm-block-rabbit-mq-publish
- request to subscribe block or tx
-
add sending email code
// code example
let email_msg = EmailMsg::new(String::from("[email protected]"), String::from("Test Subject"), String::from("Email Contents"));
let _ = email_channel.send(email_msg);
- edit config.toml or add flag on UFC running command
[email]
smtp-username="smtp_username"
smtp-password="smtp_password"
smtp-relay="smtp.gmail.com"
from="NoBody <[email protected]>"
reply-to="NoBody <[email protected]>"
[app]
plugin=["EmailPlugin"]
or
cargo run --package ufc-appbase --bin ufc-appbase -- --config-dir . --plugin EmailPlugin --smtp-username [username] --smtp-password [password]
- create workspace and add channel
- add slack app and activate incoming webhooks
- add sending slack code
// code example
let slack_msg = SlackMsg::new(String::from("https://hooks.slack.com/services/slack_hook_address"), String::from("Slack Test Message"));
let _ = slack_channel.send(slack_msg);
- edit config.toml or add flag on UFC running command
[app]
plugin=["SlackPlugin"]
or
cargo run --package ufc-appbase --bin ufc-appbase -- --config-dir . --plugin SlackPlugin
-
create telegram bot and get telegram bot token
-
add sending telegram
// code example
let telegram_msg = TelegramMsg::new(String::from("chat_id"), String::from("Test Text"));
let _ = telegram_channel.send(telegram_msg);
- edit config.toml or add flag on UFC running command
[telegram]
bot-token="TELEGRAM_BOT_TOKEN"
[app]
plugin=["TelegramPlugin"]
or
cargo run --package ufc-appbase --bin ufc-appbase -- --config-dir . --plugin TelegramPlugin --telegram-bot-token [TELEGRAM_BOT_TOKEN]
To add plugins to support other blockchains, please refer to the existing tendermint or ethereum plugins.
If you look at the two plugins, you will realize that the parts that need to communicate directly with the blockchain node were written individually, but most of the functions utilized other plugins.
Build your own blockchain framework with UFC!