GithubHelp home page GithubHelp logo

cross-chain-api-server's Introduction

Corss Chain API Server

pull requests welcome badge Language License

介绍

跨链API服务层旨面向合作开发者,辅助其将区块链更方便快捷的接入到跨链系统。API服务通过代理BCDNS(区块链域名系统)服务,提供申请区块链域名的功能;同时,提供向Relay服务添加指定区块链的功能,需要携带区块链绑定的插件服务信息及区块链配置信息。

架构

image-20240603104659012

  • Relay服务:跨链桥中继(AntChain Bridge Relayer)是蚂蚁链跨链开源项目的重要组件,负责连接区块链、区块链域名服务(BCDNS)和证明转化组件(PTC),完成可信信息的流转与证明,实现区块链互操作。
  • BCDNS服务:区块链域名系统(BlockChain Domain Name System, BCDNS),是按照IEEE 3205跨链标准中的身份协议实现的证书颁发服务,负责给跨链系统中的证明转化组件(PTC)、中继(Relayer)、和区块链域名赋予唯一性标识和可信证书,以实现跨链互操作过程中的身份认证。

快速开始

部署API

环境

API使用了MySQL和Redis,这里建议使用docker快速安装依赖。

首先通过脚本安装docker,或者在官网下载。

wget -qO- https://get.docker.com/ | bash

然后下载MySQL镜像并启动容器:

docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD='YOUR_PWD' mysql --default-authentication-plugin=mysql_native_password

然后下载Redis镜像并启动容器:

docker run -itd --name redis-test -p 6379:6379 redis --requirepass 'YOUR_PWD' --maxmemory 500MB

构建

*在开始之前,请您确保安装了maven和JDK,这里推荐使用openjdk-1.8版本

进入代码的根目录,运行mvn编译即可:

mvn clean package -Dmaven.test.skip=true

cross-chain-api-server/target下面会产生压缩包cross-chain-api-server.zip,将该压缩包解压到运行环境即可。

配置

在获得安装包之后,执行解压缩操作:

unzip cross-chain-api-server.zip

进入解压后的目录,可以看到:

cd cross-chain-api-server/
tree .
.
├── bin
│   ├── launch
│   ├── launch.bat
│   ├── wrapper-linux-x86-64
│   └── wrapper-windows-x86-64.exe
├── conf
│   ├── application-dev.properties
│   ├── application.properties
│   ├── application-pro.properties
│   ├── application-test.properties
│   ├── db.sql
│   └── wrapper.conf
├── lib
│   ├── animal-sniffer-annotations-1.21.jar
│   ├── ......

修改配置

配置文件在conf目录下,不同的配置文件由项目的根目录配置文件(pom.xml)中的profiles配置决定,开发环境为dev、测试环境为test和生产环境pro。

配置文件示例:

server.port=8113 //服务端口号
logging.level.root=info

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/bcdns?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=false //mysql配置
spring.datasource.username=xxx //mysql用户名
spring.datasource.druid.filter.config.enabled=true
public-key=xxx //用于解密mysql密码的解密公钥
spring.datasource.druid.connection-properties=config.decrypt=true;config.decrypt.key=${public-key}
spring.datasource.password=xxx //加密后的mysql密码
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.max-wait=60000
spring.datasource.druid.validation-query=select 1
spring.datasource.druid.time-between-log-stats-millis=1800000
spring.mvc.servlet.load-on-startup=1

redis.host=127.0.0.1 
redis.port=6379
redis.password=xxx //加密后的redis密码
redis.publicKey=xxx //用于解密redis密码的解密公钥

object-identity.manager.address=did:bid:ef23GG....Y4K //API管理员地址
relay.admin.address=127.0.0.1:8088 //中继grpc访问地址
bif.ipList=127.0.0.1:8080 //星火主链对外出口IP地址

运行

首先运行数据库脚本来创建表单,数据库脚本为src/main/resources/db.sql 数据库表单创建成功后,在项目根目录之下,运行命令即可:

./bin/launch start

日志文件存储在logs目录之下。可以通过./bin/launch stop关闭服务。

示例

服务启动之后即可调用http接口完成区块链域名申请和区块链注册。接口调用流程如下图所示,接口调用详情请参考跨链服务层API说明文档

社区治理

欢迎您参与开发者社区进行讨论和建设。

License

详情参考LICENSE

cross-chain-api-server's People

Contributors

curious-yc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.