讨论共识算法、经济模型以及智能合约的开发

重磅发布 | Ultrain 2020 年技术路线图
B

Ultrain 主网于 2019.4.15 上线以来,已经稳定运行了一年的时间。目前 Ultrain 全网由近 700 个节点组成,节点分布在中国、美国东西海岸、澳大利亚、南非和德国等多个国家和地区,网络部署方式包括公有云网络(阿里云、亚马逊云、微软云、金山云)、企业内网、企业专网、公开互联网和家庭宽带网络的混合部署。

在技术稳定和成型的基础上,Ultrain 在 2020 年的主要任务是实现区块链技术在商业上的落地。在 2019 年下半年,我们花费了大量的精力与我们的众多商业合作伙伴进行商业模式的探索和设计,对区块链技术在商业竞争中的优劣势也有了充分的认识,具体可以见该文《区块链商业与技术现状与发展趋势展望》(深度好文:区块链商业与技术现状与发展趋势展望(上)、深度好文:区块链商业与技术现状与发展趋势展望(下))。在此基础上,我们确定了 2020 年希望通过 Ultrain 技术重点赋能的商业模式:在充分竞争的行业中,通过低成本建立互信的加盟制商业模式。

为实现这个目标,在 2020 年 Ultrian 的技术还需要从以下几个方面进一步升级:

符合商业合规要求:近几个月,各部委出台了区块链技术相关的规范指南,如央行颁布的《金融分布式账本技术安全规范》等。这些规范在后续将成为企业应用落地的基本门槛,为满足这些规范的要求,实现商业合规,Ultrain 需要在多个方面进行进一步的研发;

共识创新:加盟制商业模式有两个特点,一个是加盟商众多,一个是加盟商地域分布非常分散。这主要带来了多种技术挑战,包括加盟商的网络环境各异,需要让用户无感知的自动适配不同的网络;网络节点数量众多,加盟商的在线时间不固定,如何面对一个动态的网络维持区块链网络的稳定;做为一个开放式网络,如何保证网络的安全性;这些方面都是我们在今年需要解决的技术挑战;

区块链隐私保护:在商业环境下,隐私保护是系统运行的底线要求,央行在今年年初颁布的《个人金融信息保护技术规范》可以做为一个参考。Ultrain 在区块链隐私保护方案有深厚的积累,今年我们会形成商业化的解决方案对外输出并提供服务;

以上是 Ultrain 在 2020 年的三条技术路线,我们对该技术路线做了进一步的划分:

2020 年 Ultrain 技术路线图

以上就是Ultrain在2020年的技术路线图,其中包含了多个世界领先的技术突破。我们会在每个时间节点进一步公布技术实现的细节,与大家分享我们的进展。希望Ultrain在技术方面的突破能为区块链技术商业落地贡献自己的力量。

read more

关于区块链与币市的行业动态与最新消息

一文全面了解 Ultrain 区块链证书管理体系
B

密码学技术是信息技术的基石,区块链中大量使用了现代信息安全和密码学的技术成果,主要包括:哈希算法、对称加密、非对称加密、数字签名、数字证书等。哈希算法解决了信息完整性验证问题,对称算法提高了加密运算效率,非对称算法解决了对称密钥传递问题,数字证书则为公钥所有者背书,解决了公钥持有者的证明问题,PKI/CA 体系形成了解决信息安全、信息机密性、完整性和抗抵赖的完整解决方案。

目前在中国主流发展的区块链技术被称为开放许可链,什么叫做许可链呢?就是所有组成许可链的节点所有者,其身份都是被认证过,被许可授权后,才能加入到该区块链网络的。

在这种场景中,网络向授权的组织或机构开放,链上各参与方之间是一种协作关系,存在准入机制。PKI/CA 体系作为完整解决方案,可以为许可链各参与方提供身份认证证书,实现准入权限控制。可以说,证书机制是许可链网络安全的基石。本文对 PKI/CA 基本概念进行必要描述后,详细阐述 Ultrain 证书管理体系。

01

公钥基础设施

公钥基础设施(Public Key Infrastructure,简称 PKI)是一个包含硬件、软件和策略等集合,用来实现基于公钥密码体制的密钥和证书的产生、管理、存储、分发和撤销等功能的完整系统。

1.1 PKI 系统

PKI 系统包括证书机构 CA(Certificate Of Authority,认证中心)、注册机构 RA 和相应的 PKI 存储库。CA 用于签发并管理证书;RA 可作为 CA 的一部分,也可以独立,其功能包括个人身份审核、CRL管理、密钥产生和密钥对备份等;PKI 存储库包括 LDAP(Lightweight Directory Access Protocol,轻量目录访问协议)目录服务器和普通数据库,用于对用户申请、证书、密钥、CRL(Certificate revocation lists)和日志等信息进行存储和管理,并提供一定的查询功能。


图1 PKI系统

1.2 证书申请过程

• 用户申请:

用户生成自己的公钥和私钥,将公钥和自己的身份信息提交给安全服务器,安全服务器将用户的申请信息传送给 RA 服务器。

• RA 审核:

用户向 RA 证明自己的身份,RA 收到用户的申请后进行核对。如果 RA 同意用户申请证书的请求,则对证书申请信息做数字签名;否则拒绝用户的申请。

• CA 发行证书:

RA 将用户申请和 RA 签名传输给 CA,CA 对 RA 数字签名做认证,如果验证通过,则同意用户请求,颁发证书,然后将证书输出。如果验证不通过,则拒绝证书申请。

• RA 转发证书:

RA 从CA 得到新的证书,首先将证书输出到 LDAP 服务器以提供目录浏览,再通知用户证书发行成功,告知证书序列号,到指定的网址去下载证书。

• 用户证书获取:

用户使用证书序列号去指定网址下载自己的数字证书。

1.3 X.509 证书格式

主流的证书格式为 X.509 格式。X.509 标准规定了证书可以包含什么信息,并说明了记录信息的方法。

X.509 结构中包括版本号(Version Number)、序列号(Serial Number)、签名算法(Signature Algorithm)、颁布者(Issuer)、有效期(Validity)、主体(Subject)、主体公钥信息(Subject Public Key Info)、主体公钥算法(Public Key Algorithm)、主体公钥(Subject Public Key)、证书签名算法(Certificate Signature Algorithm)和证书签名(Certificate Signature)。

1.4 证书验证原理

对证书中的明文利用相同的散列函数得到摘要值 H1。

用 CA 根证书验证客户证书的签名合法性,即证书中的签名用 CA 根证书的公钥解签,解签的结果与步骤 1 中的 H1 对比,如果一致,说明证书是由信任的根证书签发,且证书的内容没有被篡改。

检查客户证书是否有效 (当前时间在证书结构中的所定义的有效期内)。

检查客户证书是否作废 (OCSP 方式或 CRL 方式)。

验证客户证书结构中的证书用途。

上述所有信息都验证通过,那么证书中客户的公钥信息就能够在后续的操作中使用。

02

Ultrain 证书管理体系

许可链经过授权的节点组成联盟从而共享和访问数据。PKI 体系是一套用户审核、身份管理和隐私保护的完整的、成熟的体系,Ultrain 定义了一套从上而下的证书管理流程,从而实现许可链节点的权限管理和访问控制。

2.1 Ultrain 证书体系

Ultrain 采用面向 CA 的准入机制,实现基于 X.509 格式证书的认证和动态管理。根据现有业务场景,证书体系如图 2 所示,自上而下包含以下类型:根证书、链证书、节点证书和用户证书。

根证书:根证书是一个自签名的证书,为所有证书的根,对应的私钥 key 文件由联盟委员会共同管理。

链证书:在多链架构中,单链管理机构生成链私钥,并生成请求文件 chain.csr 发送给联盟委员会,联盟委员会审核通过后签发链证书 chain.crt。

节点证书:节点证书由链证书签发。节点生成并保存自己的私钥文件 node.key,并生成请求文件 node.csr 发送给链管理机构,链管理机构审核通过后签发节点证书 node.crt。节点证书是节点的身份凭证,拥有节点证书的节点能够与区块链网络中节点建立 SSL 链接,实现节点间的加密通信。

用户证书:用户证书由提供链访问接口的节点签发。用户生成并保存自己的私钥文件 sdk.key,并生成请求文件 sdk.csr 发送给需要访问的节点管理机构,节点管理机构审核通过后签发用户证书 sdk.crt。用户证书是客户端的身份凭证,拥有用户证书的客户端才能正常访问链接口。

Ultrain 提供了一套证书申请签发管理程序,方便各级证书的申请、验证及签发。

图2 Ultrain 证书体系

2.2 证书使用场景及验证

根证书由 Ultrain 联盟委员会共同管理,目前采用自签名证书,也可以与商业证书签发机构对接,使用权威机构签发的证书。当业务需要建立新的侧链时,该侧链管理机构提交证书请求文件,联盟委员会审核通过后使用根证书签发链证书;链证书由该链管理委员会进行管理,链管理委员会接收联盟成员成为运行节点的证书请求文件,委员会审核通过后签发节点证书;联盟成员使用节点证书以接入该侧链节点网络,才可以进行共识及交易信息的正常收发。如果该节点提供链上数据访问接口,则需签发用户证书提供给客户端使用;客户端使用特定节点签发的用户证书,才可以正常访问该节点提供的数据接口,进行数据读取、交易发送等操作。

节点证书验证

节点证书在节点间建链时使用。基于证书验证的链接建立之后,节点才能组成 P2P 网络,从而实现共识协议信息和交易信息的传播,下图为节点证书的使用流程。

图3 Ultrain 节点证书验证流程

节点在启动时,携带自己的节点证书可以与同样拥有节点证书的节点建立 SSL 安全链接。当证书过期、被篡改时,不能加入到 P2P 网络中,从而不能共享和传播链上数据。

在 Ultrain 的证书吊销(CRL)管理体系中,证书的吊销由该证书签发机构完成。节点可以向 CA 管理中心定期获取 CRL 列表。节点间的心跳报文中需携带自己的节点证书,当不携带节点证书或携带的证书在 CRL 列表时,心跳报文检测端会主动拆掉与被检测端的链接,实现实时的接入管理控制。

用户证书验证

客户端访问节点提供的链接口时,可以选择校验节点证书,以验证节点身份,此时需使用根证书、链证书组成的证书链对节点证书校验。另外,客户端需提供用户证书给节点,节点的 HTTPS 服务会校验客户端所提供的用户证书(使用根证书、链证书以及节点证书组成的证书链进行校验),同时会检查 CRL 吊销列表,校验通过且该用户证书不在 CRL 列表时,则成功建立 SSL 链接,进行正常通信,否则则不能建立链接,从而保证了客户端与节点间的通信安全。

read more

黑客马拉松与经常性的线下见面会或在线趣味游戏

超脑超星计划推进 十五支队伍并驱争先
B

——Ultrain“超星计划”首届颁奖典礼即将拉开帷幕

Ultrain超脑链联合火星财经于8月10日在北京朝阳区诚盈中心举办“超星计划”DApp开发者大赛首届线下颁奖典礼活动。本次活动凝聚了此次大赛排名前15的优秀DApp作品开发者。每支队伍都将展示各自项目的技术亮点及DApp使用场景,而由国内外顶级VC投资人和区块链领域专家组成的评审团队,将会全面考察参赛队伍技术、产品、商业等综合实力,对各个团队进行评选,在经济模型、商业模式、公司管理、资本运作等方面对各队伍进行综合指导和帮助。超脑链一直致力于完整的生态社区建设,为优秀的开发者提供更好的展示机会,以及更多的支持。

随着Ultrain“超星计划”的推进,参赛的队伍开始崭露头角,下面是关于参赛队伍DAPP的大致介绍。

链上恋:团队来自于杭州,基于区块链的情侣日记本。可以让情侣公开的见证永恒的誓言和聊天记录。让不希望恋爱回忆消逝的年轻人记录自己的青春。

Fanclub粉丝论坛:团队来自于上海,基于区块链的论坛,粉丝板块用于发帖,站务板块用于发布论坛资讯,票务板块用于出售演出票。论坛采用积分制,积分可通过每日登录、发帖、回帖来获取,积分用于购买演出票,或具有优先购买权。

Deswap交易协议: 团队来自于南京,DeSwap是一个去中心化的代币兑换系统,Ultrain上的交易代币协议。设计简便,交易快捷,为小规模代币提供流动性。无需用户挂单,也可以随时买卖。适用于超脑的UGAS和积分系统

海洋大亨: 团队来自于杭州,海洋大亨是⼀款模拟社交的游戏,游戏中融合鱼市买卖系统,模拟现实生活中,买鱼饵,造鱼钩,钓鱼到卖金币,形成商业闭环拥有组队系统,可邀请好友一起钓鱼,也可以随机匹配陌⽣人,在休闲娱乐的同时,也可以扩大自身的交际圈。

加密三国:团队来自于海外,加密三国志是一款全资产上链的游戏,具有真正游戏性的非博彩RPG 类游戏。在这个游戏中,玩家的目的是通过与 NPC或其他玩家对战,赚取稀有道具和三国币,用于提升自己的英雄和装备,并通过系统的分红机制赚取分红。

奶茶供应链: 团队来自于上海,该Dapp主要功能是记录一杯奶茶从生产到上市的整个过程中的信息。此Dapp有效提高奶茶在生产到上市过程中的可溯源性,公开性。可建立商家的信誉,提高消费者的信赖。建立一个更和谐健康的生态。

GBT预言: 团队来自于杭州,用户在该DAPP中可使用相应的代币进行预言,预言将扣除部分代币注入奖励池账户,为日后运营做基础。而大部分的代币将注入瓜分奖池账户,预言成功根据所投入代币比例瓜分奖池中代币,预言失败,则扣除投入代币。

IDE: 团队来自于南京,“ChainIDE”是全球第一个多链的智能合约集成环境(IDE), 能够快速的帮助开发者搭建初始的设计环境和节约成本。是一款优异的开发工具。

闪电保险:团队来自于重庆,通过区块链和人工智能技术,构建了保险商业联盟,将成熟稳定的人工智能的判别场景链入整个保险体系,从而将核保过程降为由机器识别、分钟级赔保的范围,极大提升用户体验,增加人们对保险产品信任感。

Last Trip “最后的旅途”:团队来自于南京, 是一款基于区块链的冒险解谜类游戏,玩家在游戏中是一个书写者。通过玩家各自的方式,撰写一本自己的《神曲》。游戏中包含了不同的文化,宗教,人文,故事,哲理。并将7种不同的画风,横跨欧亚非的哲理故事,数百种独立剧情,无数选择,人性,思考,迷雾,探索共融一炉。其完美结合区块链特性,将玩家的每一段旅途上链,并且化身为NPC,影响其他玩家的故事线。

区块链电商:团队来自于合肥,区块链电商项目可适用于多种购物场景和平台。在本次的模型设计中,我们以传统网购平台为载体,搭建一个基于区块链的网购平台,构建出一个可以实现保护用户隐私安全,减少信息骚扰的网购平台

餐引人:团队来自于杭州, 餐引人是基于区块链餐饮商家的一站式服务平台,链接小微餐饮商家的绝大多数服务商。以区块链技术为基础,力争打造“去中心化的真正可信的餐饮商家服务平台。

GC: 团队来自于杭州,作为垃圾分类的DAPP,一个有偿的知识分享平台,将代币和垃圾分类相结合,并逐渐形成垃圾分类知识库,设计简洁,功能清晰,是一款结合生活、环保的实用性DAPP。

Delibrary: 团队来自于南京, 是一款闲置图书共享领域的DAPP,拥有灵活经济激励模型,让更多的旧书籍放大其闲置图书的功效,可通过闲置图书的赠送、交换、出租和出售等操作实现资源的共享,并利用智能合约实现自动业务逻辑。

流浪宝贝: 一款专为流浪狗设计的DAPP,结合区块链,让用户的每一笔捐助触及狗狗本身。借助区块链,完成流浪狗身份溯源,监护人关系和捐助交易与消费流水。让流浪狗不在流浪!

read more

链上分布式应用的开发工具以及高质量的应用推荐

新版Ultrain浏览器上线,终于可以查Token啦!
I

Ultrain测试网上线后,很多开发者尝试写了合约,并用Ultrain浏览器进行了合约的部署操作。其中最热门的就是发Token合约,大家也想亲身体验发Token的快感!连Ultrain团队的的好几个程序员都迫不及待地进行创建账户、申请资源、写合约、部署合约、调用合约等一系列流程,尝试发Token。

可是操作完,大家向产品经理抱怨:通过「超脑浏览器」对Token合约部署、调用操作之后,在浏览器找不到自己的Token信息。于是产品经理第一时间拉着视觉、开发们,完成了测试网超脑浏览器的Token查询的设计,同时新版的Ultrain浏览器也在很多方面做了优化,继续往下看吧!

1、新增首页数据
打开新版Ultrain浏览器,首页除了全新的视觉设计,一眼就能看到块高、交易数、账户数、合约数、Token数的信息,帮助用户直观地了解超脑链最新数据。

2、Token查询
部署完Token合约,直接在超脑浏览器就可以查询到Token信息,超方便啦!

3、查看账户内Token信息
除了Token列表,在自己的账户内也可以查看账户拥有的Token信息啦。不用手动搜索,浏览器自动同步账户内Token信息,很贴心了哦~

4、无线端兼容
新版的整体视觉做了优化,包括列表页、详情页、创建账户流程、合约部署和调用流程等,同时也特别对无线端做了兼容处理,让用户在手机上操作时更舒服。

5、其他
开发还在性能上、缓存策略上进行了优化,使页面加载速度有了明显提升。

Ultrain浏览器的地址(https://explorer.ultrain.io/),你也来试一试吧!有问题的话,可以到开发者门户-论坛(https://bbs.ultrain.io/)给我们留言哦!

read more

consensus and smart contract development

Ultrain Technology Roadmap in 2020
B

The Ultrain main net has been running steadily for a year since it was launched on 2019.4.15. At present, the Ultrain network is composed of nearly 700 nodes, which are distributed in many countries and regions such as China, the East and West Coast of the United States, Australia, South Africa and Germany. The network deployment methods include public cloud networks (Alibaba Cloud, Amazon Cloud, Microsoft Cloud, Kingsoft Cloud), enterprise intranet, enterprise private network, open Internet and home broadband network.

On the basis of technical stability and shaping, Ultrain’s main task in 2020 is to realize the commercial implementation of blockchain technology. In the second half of 2019, we spent a lot of energy exploring and designing business models with our many business partners, and we have a full understanding of the advantages and disadvantages of blockchain technology in business competition:”Blockchain Business and Technology Status and Development Trend Outlook”. On this basis, we have determined the business model that we hope to be empowered by Ultrain technology in 2020: in a fully competitive industry, establish a mutual trust franchise business model at low cost.

In order to achieve this goal, Ultrain’s technology needs to be further upgraded from the following aspects in 2020:

Compliance with business compliance requirements: In recent months, various ministries and commissions have issued normative guidelines related to blockchain technology, such as the “Financial Distributed Ledger Technical Security Specification” issued by the Central Bank. These specifications will become the basic threshold for the application of enterprises in the future. In order to meet the requirements of these specifications and achieve commercial compliance, Ultrain needs to conduct further research and development in many aspects;

Consensus innovation: The franchise business model has two characteristics, one is that there are many franchisees, and the other is that the geographical distribution of franchisees is very scattered. This mainly brings a variety of technical challenges, including the different network environments of franchisees, and the need for users to automatically adapt to different networks without perception. There are many network nodes, and the online time of franchisees is not fixed. How to maintain the stability of the blockchain network in the face of a dynamic network. As an open network, how to ensure the security of the network; these aspects are the technical challenges we need to solve this year;

Blockchain privacy protection: In the business environment, privacy protection is the bottom line requirement for system operation. The “Personal Financial Information Protection Technical Specification” issued by the central bank at the beginning of this year can be used as a reference. Ultrain has a deep accumulation of blockchain privacy protection solutions. This year we will form a commercial solution to export and provide services;

The above are the three technical routes of Ultrain in 2020. We have further divided this technical route:

The above is the technology roadmap of Ultrain in 2020, which contains a number of world-leading technological breakthroughs. We will further publish the technical implementation details at each step and share our progress with you. Hope that Ultrain's breakthrough in technology can contribute to the commercial landing of blockchain technology.

read more

Industry dynamics and latest news about blockchain and currency

Ultrain Monthly Report(03/16–04/12)
B

Ultrain Monthly Report(03/16–04/12)

Following is the monthly report on the progress of the project from Mar. 16th -Apr. 12th, which contains two items: project development progress and community dynamic update. It is for the community members to check. Thank you for your attention.

Technology Update from Ultrain (3/16–4/12)
Ultrain’s Core Technology

According to the Central Bank’s “Financial Distributed Ledger Technical Security Specification” compliance check and improve the node code;

The node code adds national secret algorithm support to the transaction account;

Establish an on-chain data table to support miners’ daily reward data on-chain storage;

Optimize the historical data query code and improve the browser query response speed;

Calculate the Merkel tree hash of the world state change data to provide world state data verification.

Ultrain’s Ecosystem

A new version of the user relationship diagram, store settings and other functions are launched on the backstage of the merchant, which completes the development of funds management, product management, store opening help and other pages, and is scheduled to go online at the end of April;

The new version of the Hyper-physical APP is launched, optimizing the rich text display on the product detail page, optimizing the homepage effect and other functions;

Optimize the merchant entry process, complete function development such as shop reward activities and shop package purchase, and plan to go online after passing the test in early May.

Ultrain Developer Kit

U3 SDK adds national secret algorithm support;

Optimize the Ultrain One wallet wealth page to support reading on the miner reward data chain;

Optimize Ultrain One wallet transfer code to improve transfer response speed.

Ultrain’s Latest Community & Event Update

Ultrain overseas ambassadors synchronized the development of the blockchain industry around the world

In March, due to multiple factors, the global financial market was in crisis. But at the same time, in this special period, emerging technologies such as blockchain have also accelerated. Ultrain’s overseas ambassadors conducted a survey to provide you with an in-depth understanding of the development of the blockchain industry around the world.

Ultrain wished community members a happy April Fools’ Day!

Ultrain launched the technology roadmap of 2020

The Ultrain mainnet has been running steadily for a year since it was launched on 2019.4.15. On the basis of technical stability and shaping, Ultrain ’s main task in 2020 is to achieve the commercial implementation of blockchain technology, and it has clarified the business model that hopes to be empowered by Ultrain technology in 2020: in a fully competitive industry To establish a mutual trust franchise business model through low cost.

In order to achieve this goal, Ultrian’s technology needs to be further upgraded from the following aspects in 2020: 1. Compliance with business compliance requirements; 2. Consensus innovation; 3. Blockchain privacy protection. We have further divided the technical route.

The above is the progress report of Ultrain from Mar 16th to Apr 12th, looking forward to more exciting contents after that!

read more

hacker marathon and regular meetup or online game

One article to fully understand the Ultrain blockchain certificate management system
B

Cryptography technology is the cornerstone of information technology. Blockchain uses a lot of technological achievements of modern information security and cryptography, mainly including: hash algorithm, symmetric encryption, asymmetric encryption, digital signature, digital certificate and so on. The hash algorithm solves the problem of information integrity verification, the symmetric algorithm improves the efficiency of encryption operations, the asymmetric algorithm solves the problem of symmetric key transfer, and the digital certificate is endorsed by the public key owner, which solves the problem of the public key holder's proof , PKI / CA system has formed a complete solution to solve information security, information confidentiality, integrity and non-repudiation.

The current mainstream blockchain technology in China is called an open license chain. What is a license chain? It is the owner of all the nodes that make up the license chain. Their identities are authenticated, and they can only join the blockchain network after being authorized by the license.

In this scenario, the network is open to authorized organizations or institutions, and there is a collaborative relationship between the participants on the chain, with an access mechanism. As a complete solution, the PKI / CA system can provide identity authentication certificates for each participant in the license chain to realize access control. It can be said that the certificate mechanism is the cornerstone of the permission chain network security. After the necessary description of the basic concepts of PKI / CA, this article elaborated the Ultrain certificate management system in detail.

01 Public key infrastructure

Public Key Infrastructure (PKI) is a collection of hardware, software, and policies, which is used to complete the generation, management, storage, distribution, and revocation of keys and certificates based on public key cryptosystem system.

1.1 PKI system

The PKI system includes a certificate authority CA (Certificate Of Authority, certification center), a registration authority RA and a corresponding PKI repository. CA is used to issue and manage certificates; RA can be used as a part of CA, or it can be independent. Its functions include personal identity verification, CRL management, key generation, and key pair backup. The PKI repository includes LDAP (Lightweight Directory Access Protocol, LDAP). Lightweight Directory Access Protocol) directory server and common database, used to store and manage user applications, certificates, keys, CRL (Certificate revocation lists) and logs, and provide certain query functions.

1.2 Certificate application process

• User application:

The user generates his own public key and private key, submits the public key and his own identity information to the security server, and the security server transmits the user's application information to the RA server.

• RA audit:

The user proves his identity to the RA, and the RA checks after receiving the user's application. If the RA agrees with the user's request for a certificate, digitally sign the certificate application information; otherwise, the user's application is rejected.

• CA issued certificate:

The RA transmits the user application and the RA signature to the CA. The CA authenticates the RA digital signature. If the verification is passed, the CA agrees to the user request, issues a certificate, and then outputs the certificate. If the verification fails, the certificate application is rejected.

• RA forwarding certificate:

The RA obtains a new certificate from the CA, first outputs the certificate to the LDAP server to provide directory browsing, then notifies the user of the successful issuance of the certificate, informs the certificate of the serial number, and downloads the certificate to the specified website.

• User certificate acquisition:

The user uses the certificate serial number to specify the website to download his digital certificate.

1.3 X.509 certificate format

The mainstream certificate format is X.509 format. The X.509 standard stipulates what information a certificate can contain and explains how to record the information.

X.509 structure includes Version Number, Serial Number, Signature Algorithm, Issuer, Validity, Subject, Subject Public Key Information (Subject Public) Key Info), subject public key algorithm (Public Key Algorithm), subject public key (Subject Public Key), certificate signature algorithm (Certificate Signature Algorithm) and certificate signature (Certificate Signature).

1.4 Certificate verification principle

Use the same hash function for the plain text in the certificate to get the digest value H1.

Use the CA root certificate to verify the signature validity of the client certificate, that is, the signature in the certificate is de-signed with the public key of the CA root certificate, and the de-signed result is compared with H1 in step 1. If they are consistent, the certificate is trusted The root certificate is issued, and the contents of the certificate have not been tampered with.

Check whether the client certificate is valid (the current time is within the validity period defined in the certificate structure).

Check whether the client certificate is invalid (OCSP method or CRL method).

Verify the purpose of the certificate in the client certificate structure.

All the above information is verified, then the public key information of the client in the certificate can be used in subsequent operations.

02 Ultrain Certificate Management System

The authorized nodes of the permission chain form an alliance to share and access data. The PKI system is a complete and mature system for user auditing, identity management and privacy protection. Ultrain defines a set of top-down certificate management processes to achieve permission management and access control of license chain nodes.

2.1 Ultrain certificate system

Ultrain uses a CA-oriented access mechanism to implement authentication and dynamic management based on X.509 format certificates. According to the existing business scenario, the certificate system is shown in Figure 2, and includes the following types from top to bottom: root certificate, chain certificate, node certificate, and user certificate.

Root certificate: The root certificate is a self-signed certificate, which is the root of all certificates, and the corresponding private key file is jointly managed by the alliance committee.

Chain certificate: In a multi-chain architecture, a single chain management agency generates a chain private key and generates a request file chain.csr to send to the alliance committee. After the alliance committee passes the review, the chain certificate chain.crt is issued.

Node certificate: The node certificate is issued by a chain certificate. The node generates and saves its own private key file node.key, and generates a request file node.csr and sends it to the chain management agency. After the chain management agency passes the verification, it issues a node certificate node.crt. The node certificate is the identity certificate of the node. The node with the node certificate can establish an SSL link with the node in the blockchain network to achieve encrypted communication between the nodes.

User certificate: The user certificate is issued by the node that provides the chain access interface. The user generates and saves his own private key file sdk.key, and generates a request file sdk.csr and sends it to the node management organization that needs to be accessed. After the node management organization passes the verification, the user certificate sdk.crt is issued. The user certificate is the client's identity credential, and the client with the user certificate can access the link port normally.

Ultrain provides a set of certificate application issuance management procedures to facilitate the application, verification and issuance of certificates at all levels.

2.2 Certificate usage scenarios and verification

The root certificate is jointly managed by the Ultrain Alliance Committee. At present, it uses a self-signed certificate. It can also be connected to a commercial certificate issuing agency and use a certificate issued by an authority. When the business needs to establish a new side chain, the side chain management agency submits the certificate request file, and the alliance committee uses the root certificate to issue the chain certificate after the alliance committee passes the review; the chain certificate is managed by the chain management committee, and the chain management committee receives the alliance member to become the operation The node certificate request file is issued by the committee after the committee passes the review; the alliance members use the node certificate to access the side chain node network before they can send and receive consensus and transaction information normally. If the node provides an on-chain data access interface, a user certificate needs to be issued to the client for use; the client uses the user certificate issued by a specific node to access the data interface provided by the node for data reading, transaction sending, etc. operating.

Node certificate verification

Node certificates are used when building chains between nodes. After the link based on certificate verification is established, the node can form a P2P network, so as to achieve the spread of consensus protocol information and transaction information. The following figure shows the process of using the node certificate.

When a node is started, carrying its own node certificate can establish an SSL secure link with a node that also has the node certificate. When the certificate expires and is tampered with, it cannot be added to the P2P network, so the data on the chain cannot be shared and propagated.

In Ultrain's certificate revocation (CRL) management system, the revocation of the certificate is completed by the certificate issuing authority. Nodes can periodically obtain the CRL list from the CA Management Center. Heartbeat messages between nodes need to carry their own node certificates. When the node certificate is not carried or the carried certificate is in the CRL list, the heartbeat message detection end will actively tear down the link with the detected end to achieve real-time access management control .

User certificate verification

When the client accesses the link port provided by the node, it can choose to verify the node certificate to verify the identity of the node. In this case, a certificate chain composed of a root certificate and a chain certificate needs to be used to verify the node certificate. In addition, the client needs to provide the user certificate to the node. The node's HTTPS service will verify the user certificate provided by the client (using the root certificate, chain certificate and node certificate to form the certificate chain for verification), and will also check the CRL revocation list , When the verification is passed and the user certificate is not in the CRL list, the SSL link is successfully established for normal communication, otherwise the link cannot be established, thereby ensuring the security of communication between the client and the node.

read more

Dapp develop tools and high-quality application recommendations

How to build an end-to-end DApp on Ultrain - 2
R

Step2:Write DApp

There are two Dapps to be written, one is MiningDapp, the other is UDapp. We use the Javascript SDK U3.js to write the DApps. To be simple, we create the two DApps in one project.

Written by DApp

In WebStorm, create a new project -> Node.js Express App-> Template select Pug (Jade); modify the project name to CarbonDApp;

Click ‘Create’ to create a project

Import project dependent class library

Copy all the directories in node_modules in CarbonProject to the node_modules directory of CarbonDApp, and repeat the directory skipping without copying;
Copy the CarbonDApp/node_modules/u3.js/dist/u3.js file to the CarbonDApp/public/javascripts directory.

Modify the DApp server port

Since the default 3000 port is already occupied, you need to modify the server port of the DApp.

Open the bin/www file and find var port = normalizePort(process.env.PORT || '3000'); change 3000 to 3001

Create an account information browsing page

Create an index.html page in the public directory and add the following code to the page:

<html> <head> <meta charset="UTF-8"> <title>test</title> <link rel="stylesheet" href="/stylesheets/style.css"> <script src="./javascripts/u3.js"></script> <script> let u3 = U3.createU3({ httpEndpoint: 'http://127.0.0.1:8888', httpEndpoint_history: 'http://127.0.0.1:3000', broadcast: true, debug: false, sign: true, logger: { log: console.log, error: console.error, debug: console.log }, chainId:'2616bfbc21e11d60d10cb798f00893c2befba10e2338b7277bb3865d2e658f58', symbol: 'UGAS' }); async function getBalanceInfo() { let SYMBOL = 'CARB'; let account = 'ben'; const ben_balance = await u3.getCurrencyBalance({ code:'ben', symbol: SYMBOL, account: account }); document.getElementById("carbon_balance").innerHTML = '账户余额:'+ben_balance; const bob_balance = await u3.getCurrencyBalance({ code:'ben', symbol: SYMBOL, account: 'bob' }); document.getElementById("bob_balance").innerHTML = '账户余额:'+ bob_balance; const tom_balance = await u3.getCurrencyBalance({ code:'ben', symbol: SYMBOL, account: 'tom' }); document.getElementById("tom_balance").innerHTML = '账户余额:'+tom_balance; const tony_balance = await u3.getCurrencyBalance({ code:'ben', symbol: SYMBOL, account: 'tony' }); document.getElementById("tony_balance").innerHTML = '账户余额:'+tom_balance; const jerry_balance = await u3.getCurrencyBalance({ code:'ben', symbol: SYMBOL, account: 'jerry' }); document.getElementById("jerry_balance").innerHTML = '账户余额:'+tom_balance; const jack_balance = await u3.getCurrencyBalance({ code:'ben', symbol: SYMBOL, account: 'jack' }); document.getElementById("jack_balance").innerHTML = '账户余额:'+tom_balance; } getBalanceInfo(); //transfer(); </script> </head> <body> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>CarbonCoin发行方</h1> <p>账户:ben</p> <p>描述:进行CarbonCoin发行的发行方,持有所有未分配的CarbonCoin</p> <p id="carbon_balance"></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>节能设备1</h1> <p>账户:bob</p> <p>描述:通过节能产生CarbonCoin的节能设备1</p> <p id="bob_balance"></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>节能设备2</h1> <p>账户:tom</p> <p>描述:通过节能产生CarbonCoin的节能设备2</p> <p id="tom_balance"></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>航空公司C</h1> <p>账户:tony</p> <p>描述:大型航空公司,化石能源使用大户</p> <p id="tony_balance"></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>汽车制造商D</h1> <p>账户:jerry</p> <p>描述:大型汽车制造商,化石能源使用大户</p> <p id="jerry_balance"></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>CarbonCoin销毁账户</h1> <p>账户:jack</p> <p>描述:用于CarbonCoin销毁的账户,持有所有销毁的CarbonCoin</p> <p id="jack_balance"></p> </div> </body> </html> Start the DApp service, test the page
In the npm interface, double click the start button

After the server is successfully started, visit http://127.0.0.1:3001/index.html and the following page appears:

It can be seen that the issuer ben account holds 10 million of all CARB Tokens issued; other accounts have not yet held CARB Token;

Create a mining.html page

Mining.html page, energy-saving device 1 and energy-saving device 2 send the calorie value generated in the first 30 seconds to the energy smart contract every 30 seconds, and redeem CarbonCoin;

Create a mining.html page in the public directory, enter the following code:

<html> <head> <meta charset="UTF-8"> <title>test</title> <link rel="stylesheet" href="/stylesheets/style.css"> <script src="./javascripts/u3.js"></script> <script> let u3_bob = U3.createU3({ httpEndpoint: 'http://127.0.0.1:8888', httpEndpoint_history: 'http://127.0.0.1:3000', broadcast: true, debug: false, sign: true, logger: { log: console.log, error: console.error, debug: console.log }, chainId:'2616bfbc21e11d60d10cb798f00893c2befba10e2338b7277bb3865d2e658f58', keyProvider: '5JoQtsKQuH8hC9MyvfJAqo6qmKLm8ePYNucs7tPu2YxG12trzBt',//bob's private_key symbol: 'CARB' }); let u3_tom = U3.createU3({ httpEndpoint: 'http://127.0.0.1:8888', httpEndpoint_history: 'http://127.0.0.1:3000', broadcast: true, debug: false, sign: true, logger: { log: console.log, error: console.error, debug: console.log }, chainId:'2616bfbc21e11d60d10cb798f00893c2befba10e2338b7277bb3865d2e658f58', keyProvider: '5KXYYEWSFRWfNVrMPaVcxiRTjD9PzHjBSzxhA9MeQKHPMxWP8kU',//tom's private_key symbol: 'CARB' }); function wait(ms = 0) { return new Promise(res => setTimeout(res, ms)); } function randomFrom(lowerValue,upperValue) { return Math.floor(Math.random() * (upperValue - lowerValue + 1) + lowerValue); } async function mining() { let owner_account = 'ben'; const tr_bob = await u3_bob.contract(owner_account); const tr_tom = await u3_tom.contract(owner_account); // let amount = U3.format.UDecimalPad(2000,4); let heat_bob = randomFrom(15000,20000); let heat_tom = randomFrom(15000,20000); await tr_bob.recordHeat(heat_bob,{ authorization: [`bob@active`] }); await tr_tom.recordHeat(heat_tom,{ authorization: [`tom@active`] }); var d=new Date(); var t=d.toLocaleTimeString(); document.getElementById("bob_log").innerHTML = 'time :'+t+', heat value :'+ heat_bob; document.getElementById("tom_log").innerHTML = 'time :'+t+', heat value :'+ heat_tom; } mining(); var int=self.setInterval("mining()",30*1000); </script> </head> <body> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>节能设备1</h1> <p>账户:bob</p> <p>描述:通过节能产生CarbonCoin的节能设备1</p> <p id="bob_log"></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>节能设备2</h1> <p>账户:tom</p> <p>描述:通过节能产生CarbonCoin的节能设备2</p> <p id="tom_log"></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <button onclick="int=window.clearInterval(int)">stop</button> </div> </body> </html>

Go to http://127.0.0.1:3001/mining.html and the following page appears:

There are two things to note here.

When sending data to the energy smart contract, you need to hold the private key of the account before you can sign and send it. In order to simplify the programming, the private key is directly written to the webpage. In the actual program, the private key needs to be protected and hidden.

To simplify the writing, the Bob and tom DApp programs are written directly to a page. Actually, they should be two DApp program instances, which are running on two devices respectively.

Now our energy-saving equipment can already send data to the smart contract, and after the energy smart contract receives the data, it will pass the data to the operator server, and the operator server will call the energy smart contract again to exchange carboncoin. So we need to establish EnergyServer;

Step3: EnergyServer

Establish event monitor and handle events

In this section, we will deal with the above calorific value data upload event.

1.1 Establish listener event server code

In the bin directory of the CarbonDApp project, create a new file msgBroker.js and enter the following code.

const { createU3 , format} = require('u3.js/src'); const http = require('http'); const port = 3002; let u3 = createU3({ httpEndpoint: 'http://127.0.0.1:8888', httpEndpoint_history: 'http://127.0.0.1:3000', broadcast: true, debug: false, sign: true, logger: { log: console.log, error: console.error, debug: console.log }, chainId:'2616bfbc21e11d60d10cb798f00893c2befba10e2338b7277bb3865d2e658f58', keyProvider:'5JbedY3jGfNK7HcLXcqGqSYrmX2n8wQWqZAuq6K7Gcf4Dj62UfL',//ben's private key symbol: 'UGAS' }); let server = http.createServer((request, response) => { const { headers, method, url } = request; console.log(method); console.log(url); let body = []; request.on('error', (err) => { console.error(err); }).on('data', (chunk) => { body.push(chunk); }).on('end', () => { body = Buffer.concat(body).toString(); console.log("received msg:", body); if (body != null && body.trim()!="") { var obj = JSON.parse(body); let heatValue = JSON.parse(obj[1]).heat.split(",")[0]; let account = JSON.parse(obj[1]).heat.split(",")[1]; exchangeCarbonCoin(account,heatValue); } response.on('error', (err) => { console.error(err); }); response.statusCode = 200; response.setHeader('Content-Type', 'application/json'); response.write("ok"); response.end(); }); }); server.keepAliveTimeout = 0; server.timeout = 0; server.listen(port, function () { console.log((new Date()) + " Server is listening on port " + port); }); function wait(ms = 0) { return new Promise(res => setTimeout(res, ms)); } async function exchangeCarbonCoin(account,heat) { let SYMBOL = 'CARB'; let code = 'ben'; const tr = await u3.contract(code); let heatValue = format.DecimalPad(heat,4); const result = await tr.exchangeCarbonCoin('ben', account, heatValue+' ' + SYMBOL, 'test', { authorization: [`ben@active`] }); let tx = await u3.getTxByTxId(result.transaction_id); while (!tx.irreversible) { await wait(1000); tx = await u3.getTxByTxId(result.transaction_id); if (tx.irreversible) { console.log(tx); break; } } }

The code establishes a service on port 3002. After the energy-saving device uploads its calorific value, the smart contract will send the energy-saving device to the service to upload the calorific value data. The service calls the exchangeCarbonCoin method of the energy smart contract to exchange the CarbonCoin.

1.2 Establish a listener event server startup script

Open the CarbonDApp/package.json file and add the following code to the scripts property: "event": "node ./bin/msgBroker"

1.3 Start the listening server

Refresh the npm window with the ‘event’ option

Double-click event to complete server startup

1.4 Register event monitoring mechanism on the chain

Query the internal network address of the machine through the ifconfig command, for example: 10.20.8.32

In the CarbonProject/test directory, create the registerEvent.js file; enter the following code in the file

const U3Utils = require('u3-utils/dist/es5'); const { createU3, format, listener } = require('u3.js/src'); const config = require('../config'); const chai = require('chai'); require('chai') .use(require('chai-as-promised')) .should(); const should = chai.should(); const expect = chai.expect; const assert = chai.assert; describe('Test cases', function() { it('event register', async () => { let account = 'ben'; const u3 = createU3(config); await u3.registerEvent(account, 'http:// 10.20.8.32:3002'); U3Utils.wait(1000); }); it('event unregister', async () => { let account = 'ben'; const u3 = createU3(config); await u3.unregisterEvent(account, ' http:// 10.20.8.32:3002'); U3Utils.wait(1000); }); });

Note that the registered address is modified to be the internal network address of the machine, and 127.0.0.1 cannot be used.
Run the event register test case to complete the event registration;

1.5 Test calorie value for CarbonCoin function

Visit http://127.0.0.1:3001/mining.html page, every 30 seconds, both bob and tom will randomly send a random value between 15000 and 20000 as the calorific value to convert the smart contract to CarbonCoin;
Visit and refresh the http://127.0.0.1:3001/index.html page, you can find that the CarbonCoin account of bob and tom is increasing every 30 seconds;

Step4:Improve DApp functionality

Add transfer function

After the energy-saving equipment acquires CarbonCoin, it can sell CarbonCoin to the enterprise, such as airlines, etc. The simple embodiment is that the equipment account can be transferred to the corporate company account;

Open the /CarbonDApp/index.html page and add the code

1.1 U3 object used when establishing the transfer

let u3_bob = U3.createU3({ keyProvider:'5JoQtsKQuH8hC9MyvfJAqo6qmKLm8ePYNucs7tPu2YxG12trzBt',//bob's private key }) let u3_tom = U3.createU3({ keyProvider:'5KXYYEWSFRWfNVrMPaVcxiRTjD9PzHjBSzxhA9MeQKHPMxWP8kU',//tom's private key })

1.2 Add the js code of the transfer to call the corresponding smart contract method

async function sendCoin(from,to){ let SYMBOL = 'CARB'; let code = 'ben'; let coins = U3.format.DecimalPad(this.randomFrom(100,500),4); if (from == 'bob'){ const tr = await u3_bob.contract(code); const result = await tr.transfer(from, to, coins + ' ' + SYMBOL, 'sendCoin', { authorization: [`bob@active`] }); let tx = await u3_bob.getTxByTxId(result.transaction_id); while (!tx.irreversible) { await wait(1000); tx = await u3_bob.getTxByTxId(result.transaction_id); if (tx.irreversible) { alert("bob send coin success:"+ coins); break; } } } else if (from == 'tom'){ const tr = await u3_tom.contract(code); const result = await tr.transfer(from, to, coins + ' ' + SYMBOL, 'sendCoin', { authorization: [`tom@active`] }); let tx = await u3_tom.getTxByTxId(result.transaction_id); while (!tx.irreversible) { await wait(1000); tx = await u3_tom.getTxByTxId(result.transaction_id); if (tx.irreversible) { alert("tom send coin success:"+ coins); break; } } } }

1.3 Add a call to the sendcoin() method on the page, update the following code

<div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>节能设备1</h1> <p>账户:bob</p> <p>描述:通过节能产生CarbonCoin的节能设备1</p> <p id="bob_balance"></p> <p><a href="#" OnClick="sendCoin('bob','tony')">给航空公司C转账</a></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>节能设备2</h1> <p>账户:tom</p> <p>描述:通过节能产生CarbonCoin的节能设备2</p> <p id="tom_balance"></p> <p><a href="#" OnClick="sendCoin('tom','jerry')">给汽车制造商D转账</a></p> </div>

1.4 Access the page and test the function

Visit: http://127.0.0.1:3001/index.html, click the "Transfer to the airline C" button, wait for a period of time (up to about 10 seconds, confirm the time for the Ultrain transaction), the following prompt appears, indicating the transfer success.

Add a company to convert CarbonCoin to a charity point function

By converting CarbonCoin into charitable points, the company makes its own contribution to reducing carbon emissions and enhances its reputation:

Open the /CarbonDApp/index.html page and add the code

2.1 U3 object used when establishing point redemption

let u3_tony = U3.createU3({ keyProvider:'5KbHvFfDXovPvo2ACNd23yAE9kJF7Mxaws7srp6VapjMr7TrHZB',//tony's private key }) let u3_jerry = U3.createU3({ keyProvider:'5JFz7EbcsCNHrDLuf9VpHtnLdepL4CcAEXu7AtSUYfcoiszursr',//jerry's private key })

2.2 Add the redeemed js code to call the corresponding smart contract method

async function exchangeScore(account){ let SYMBOL = 'CARB'; let code = 'ben'; let to = 'jack'; let coins = U3.format.DecimalPad(this.randomFrom(10,50),4); if (account == 'tony'){ const tr = await u3_tony.contract(code); const result = await tr.exchangeScore(account, to, coins + ' ' + SYMBOL, 'sendCoin', { authorization: [`tony@active`] }); let tx = await u3_tony.getTxByTxId(result.transaction_id); while (!tx.irreversible) { await wait(1000); tx = await u3_tony.getTxByTxId(result.transaction_id); if (tx.irreversible) { alert("tony buy score success:"+ coins); break; } } } else if (account == 'jerry'){ const tr = await u3_jerry.contract(code); const result = await tr.exchangeScore(account, to, coins + ' ' + SYMBOL, 'sendCoin', { authorization: [`jerry@active`] }); let tx = await u3_jerry.getTxByTxId(result.transaction_id); while (!tx.irreversible) { await wait(1000); tx = await u3_jerry.getTxByTxId(result.transaction_id); if (tx.irreversible) { alert("jerry buy score success:"+ coins); break; } } } }

2.3 Add a call to the exchangeScore() method on the page, update the following code

<div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>航空公司C</h1> <p>账户:tony</p> <p>描述:大型航空公司,化石能源使用大户</p> <p id="tony_balance"></p> <p><a href="#" OnClick="exchangeScore('tony');return false;">购买公益积分</a></p> </div> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>汽车制造商D</h1> <p>账户:jerry</p> <p>描述:大型汽车制造商,化石能源使用大户</p> <p id="jerry_balance"></p> <p><a href="#" OnClick="exchangeScore('jerry');return false;">购买公益积分</a></p> </div>

2.4 Access the page and test the function

Visit: http://127.0.0.1:3001/index.html, click the "Buy Charity Points" button, wait for a period of time (up to about 10 seconds, confirm the time for the Ultrain transaction), the following prompt appears, indicating that the points are successfully redeemed. At the same time, you can see the number of CarbonCoins destroyed in the CarbonCoin destruction account at the bottom of the page.

Query the public welfare points exchange history

By enquiring the redemption history of charity points, we can establish a ranking of corporate charity points.

3.1 Creating a page

In the CarbonDApp/public/ directory, create a new leaderboard.html and enter the following code:

<html> <head> <meta charset="UTF-8"> <title>leaderboard</title> <link rel="stylesheet" href="/stylesheets/style.css"> <script src="./javascripts/u3.js"></script> <script> let u3 = U3.createU3({ httpEndpoint: 'http://127.0.0.1:8888', httpEndpoint_history: 'http://127.0.0.1:3000', broadcast: true, debug: false, sign: true, logger: { log: console.log, error: console.error, debug: console.log }, chainId:'2616bfbc21e11d60d10cb798f00893c2befba10e2338b7277bb3865d2e658f58', symbol: 'UGAS' }); function wait(ms = 0) { return new Promise(res => setTimeout(res, ms)); } async function getLeaderboard() { let owner_account = 'ben'; const tr = await u3.contract(owner_account); const result = await u3.getAllTxs(1,10000000,{"actions.name":"exchangeScore"},{_id:-1}); //console.log(result); let content = ''; for ( let i = 0 ;i< result.results.length;i++){ content = content + '<tr><td>'+ result.results[i].actions[0].data.from+":"+result.results[i].actions[0].data.quantity +'</td></tr>'; } document.getElementById("leaderboard").innerHTML = content; } getLeaderboard(); </script> </head> <body> <div style="padding:8px;border:1px solid #96c2f1;background:#eff7ff"> <h1>leaderboard</h1> <table id="leaderboard"> </table> </div> </body> </html>

We use the u3.getAllTxs(1,10000000,{"actions.name":"exchangeScore"},{_id:-1}); method to query all redemption transactions and print their specific data to the page.

3.2 Run page

Visit http://127.0.0.1:3001/leaderboard.html and you can see the following page:

Here is a history of all points redemption.

Summary

This tutorial system describes how to write an end-to-end web version of the DApp application. Although it has been simplified in the process of writing, it generally describes the overall picture of DApp application development, developers can do the basis of this framework. Enrich and improve your DApp application.

About developing DApp on iOS and Android, you can integrate u3.js into the corresponding hybrid Native development framework, and the principle is the same as the web version DApp.

read more