consensus and smart contract development

Ultrain Launches Enterprise Mainnet Monitoring & Round Two of Testnet Participant Selection
R

Dear Ultrain community members,

We are excited to announce the launch of Ultrain’s mainnet monitoring page! Click the following link to see the operational status of our permitted mainnet including mining profitability, real-time consensus visualization, and existing mainnet users: https://www.ultrain.io/miner-registration

The addition of this visibility feature will further explain Ultrain’s consensus procedure and business model. Please visit the Mainnet Monitoring service (link provided above) and read the supporting article at https://medium.com/ultrain-chain/introduction-to-ultrains-economic-model-74920e1c687f. These resources assist us to comprehend Ultrain’s token economic system, and understand how Ultrain’s model is based on a notion of servicing and empowering the fundamentals of the real economy.

Ultrain business development model is dependable and scalable; as the demand for blockchain services increases, Ultrain’s economic system will grow accordingly to meet the interests of early adopters, as well as ensure the healthy development of the entire business ecosystem.

Since the call went out for Ultrain’s second round of testnet miner recruitment, we received many applications from all over the world. Thank you all once again for the great interest!
The following is the list of successful applicants – welcome to the Ultrain testnet family and enjoy your preview of Ultrain’s technology.

1、[email protected]
2、[email protected]
3、[email protected]
4、[email protected]
5、[email protected]
6、[email protected]
7、[email protected]
8、[email protected]
9、[email protected]
10、[email protected]
11、[email protected]
12、[email protected]

(The list below represents the selected miners since December 26 2018 to January 13,2019)

Ultrain encourages everyone to continue submitting testnet applications, and stay tuned for more updates from the team!

Thank you all for your continued support of Ultrain.

Ultrain Team
2019. January 25th

阅读更多

hacker marathon and regular meetup or online game

Redirect HTTP to HTTPS for whole site?
O

@gtdzx Thank for your warm heart. I tested the links you providered. It automatically redirect to HTTPS.

阅读更多

Industry dynamics and latest news about blockchain and currency

年度盘点 | Ultrain这一年都做了什么?
R

新的一年,Ultrain全体员工在这里携Supernova超新星小象先给大家拜年啦!祝大家在这一年,“猪”事顺利,心想事成!

值此辞旧迎新之际,朋友圈的各位旁友们都开启了一年一度的总结模式,晒九宫格自拍、写2018回忆录、立新年flag,五花八门。而Ultrain作为一家区块链3.0公链项目,在此也要给大家献上我们的年度总结!

这一年我们都经历了些什么呢?

经历了市场情况一片大好,而又急转直下;

经历了有心人的无端诽谤、中伤和猜忌;

经历了社区从零到一的艰难建设... ...

然而在这短短的一年,我们又收获了些什么?

我们打造了3个技术里程碑:

2018年7月

重磅推出Ultrain基于R-PoS共识机制的概念验证网络、开发者友好的DApp集成开发框架Robin

2018年10月

重磅发布公开测试网络、准入制主网,及定制化零知识证明、真随机数生成器、抗量子钱包这三个核心链上中间件和多个链上DApp展示

2019年1月

正式开启Ultrain准入制公网的对外商用服务

完成了2轮融资:

2018年5月

完成数千万元人民币的天使轮融资

2018年7月

逆市完成2000万美元基石轮融资

获得了2大互联网巨头的有力支持:

2018年8月

入围微软加速器项目

2018年11月

入选亚马逊AWS云创计划

2019年1月

Ultrain商用信任计算服务上线微软Azure市场

签订了2份商业合同:

Ultrain X 电魂Unitopia

Ultrain X YOHO有货旗下UFO飞碟好物

完成了5项发明专利申请:

Ⅰ一种区块链智能合约的分片方法、装置及电子设备

Ⅱ一种基于区块链的智能合约实现方法和装置

Ⅲ一种智能合约处理方法、装置及设备

Ⅳ一种区块链智能合约更新方法、装置及设备

Ⅴ基于区块链智能合约实现的智能防伪装置及溯源防伪方法

举办了共计12场线下社区活动:

2018年5月

海外首场社区活动纽约Grand Meetup

德国慕尼黑Grand Meetup

2018年6月

法国巴黎Grand Meetup

美国伯克利大学留学生 X Ultrain Meetup

美国硅谷Draper University Meetup

2018年11月

德国柏林技术见面会

首期国内技术见面会-浙江大学站

2018年12月

越南胡志明Grand Meetup

韩国首尔Grand Meetup

国内技术见面会-南京大学站

2019年1月

国内技术见面会-西南大学站

国内技术见面会-重庆大学站

受邀参与/协办12个重磅活动:

2018年5月

联合创始人&CEO郭睿受邀参加2018全球技术周暨第四届南京(全球)软件大会

郭睿受邀参加2018中国国际大数据产业博览会并进行分享

2018年6月

Ultrain联合创始人Emma受邀参加3点钟新加坡峰会499区块链“女性力量崛起”专场,并围绕“从古典投资到区块链创业”进行了英文主题演讲

2018年7月

Emma受邀担任中美创投峰会区块链论坛全场特约主持

2018年8月

Ultrain受邀出席2018亚布力论坛夏季高峰会,并于“审视区块链”论坛上与诸位嘉宾共同探讨区块链对金融机构及非金融机构带来的影响

Ultrain受邀出席于硅谷举办的火星区块链峰会暨中美区块链领袖首届高峰对话并参与其公链Panel

2018年11月

Ultrain全程助力Bitfwd悉尼黑客马拉松

2018年12月

Emma受邀参加第四届哥大学商学院北京论坛中的“区块链论坛”并参与圆桌讨论

Emma出席WDAS世界数字资产大会进行个人演讲并参加圆桌会议讨论

Ultrain受邀协办币安于旧金山举办的史上首次黑客马拉松

2019年1月

Ultrain受邀作为重要合作方重磅亮相币安新加坡区块链周

Ultrain顾问、著名宏观经济学家、伦敦政治经济学院终身教授、Richemont历峰集团董事金刻羽代表Ultrain于瑞士出席了达沃斯区块链经济论坛

产出6篇深度技术剖析好文:

Ultrain干货 | 走近全球顶级区块链3.0项目:

https://mp.weixin.qq.com/s?__biz=MzU5MzQ2ODU3MA==&mid=2247484617&idx=1&sn=afb5903dbf35508be595efc3dc0de717&chksm=fe11493cc966c02a1a745f15ee19eba8a9953de0aa291dd48c1a6f43831fb46aee91558672b2&scene=21#wechat_redirect

一文读懂区块链和分布式数据库有什么区别?

https://mp.weixin.qq.com/s?__biz=MzU5MzQ2ODU3MA==&mid=2247485328&idx=1&sn=43c2b2bbfdaf3da04d52db87ad346685&chksm=fe114a65c966c373abbed69eefe8e4f67f7814bcb765788d4f3591311d5787c896f2983cbd18&scene=21#wechat_redirect

Ultrain首席密码学家:随机数的原理与应用:

https://mp.weixin.qq.com/s?__biz=MzU5MzQ2ODU3MA==&mid=2247485393&idx=1&sn=4cc23d556808f46b1414281ba56dd534&chksm=fe114a24c966c3320f408cca10bcda1fc1d4ac38b7279b511af59eaa93a120d9fa1d6e881899&scene=21#wechat_redirect

从业者必读:区块链的核心—智能合约:

https://mp.weixin.qq.com/s?__biz=MzU5MzQ2ODU3MA==&mid=2247485449&idx=1&sn=01839297a6880b4c51987d36f9e79a50&chksm=fe1145fcc966cceafbc9954e2b75ea5e60afbfa712c8870dcc3ba52506ec447d73e266586dbe&scene=21#wechat_redirect

区块链的演进历史与未来:

https://www.chainnews.com/articles/821387136581.htm?from=groupmessage&isappinstalled=0

BM的新想法?Ultrain已经实现了:

https://m.huoxing24.com/newsdetailShare/20181129183300949184.html?from=groupmessage&isappinstalled=0

... ...

过去的一年硕果满满,但也同样有所不足。新的一年,我们对于自己,也将会有更高的要求和更多的期许。

在Ultrain核心团队的眼里,区块链技术是什么?

联合创始人郭睿:“2019年是区块链商业落地的元年,希望在年底我们会看到区块链技术赋能众多行业,看到全新的区块链商业模式的成功应用~”

联合创始人Emma廖志宇:“前沿科技赋能实体经济. 可信,公平,去中心化,做全球第一商业公链. Ultrain.”

联合创始人李宁:“区块技术是一种溯源信任的变革,是数据资产为元数据的商业社会的基础。”

首席架构师沈宇峰:“我觉得一个更好的社会文明的一个标志是社会契约更高效履行,多些市场、少些强权。希望Ultrain网络能运用区块链技术在这个方面对社会文明进步做出贡献。”

首席密码学家Husen王虎森:“区块链让最有意义的事情沉淀下来,在2018这个block header上,经过2019的努力,我们肯定能mine出精彩的新block。”

在这个新兴行业,总有太多浮躁的声音此起彼伏。人们短视,人们焦急,人们恨不得投入的石子能瞬间翻起涟漪滚滚,但太多时候,只是石沉大海。

可我们始终不忘初心,始终敬畏区块链这项技术,热爱这个行业。

我们明白,如今的市场状况是对所有区块链项目来说最好的试金石。当潮水褪去,唯一还能留下的,一定是真正能够为社会带来价值的项目。我们把技术研发当作第一要务,但我们不是只专注理论研究而置实际商用于不顾的项目,也不是本末倒置、只关心区块链金融属性的项目,我们始终牢记赋能实体经济的重要性,也已经成功成为了全球开发进度最快的公链项目之一!

我们相信2019年是区块链技术在商业行业落地的一年,只有真正做好长足准备的公链,才能有效地支撑行业应用的落地。猪年是喜庆的,猪年是美好的,我们希望在这一年里为更多企业实现区块链赋能,创造更多的收入增长,通过一系列标杆商业案例,让更多主流行业领头羊企业们了解到区块链的巨大能量,把主流商业资源更好地对接到区块链当中,使区块链基础设施成为未来主流技术基础设施的一部分。

前方哪怕荆棘丛生,Ultrain的全体同学们仍旧会砥砺前行。在这场行业发展的洪流当中,在这个人人都开始不屑谈理想的时代,我们仍旧要说:我们的理想就是做全球领先的商业公链!新的一年,请大家拭目以待!

摄于2019年1月17日 Ultrain年会摄于2019年1月17日 Ultrain年会

阅读更多

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: [`[email protected]`] }); await tr_tom.recordHeat(heat_tom,{ authorization: [`[email protected]`] }); 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: [`[email protected]`] }); 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: [`[email protected]`] }); 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: [`[email protected]`] }); 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: [`[email protected]`] }); 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: [`[email protected]`] }); 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.

阅读更多

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

Ultrain商用主网监控页面上线 &第二期测试网矿工入选名单公布
R

尊敬的社区成员们:

感谢大家一直以来对于Ultrain的支持!Ultrain正式宣布:商用主网监控页面已上线,各位可通过此页面https://www.ultrain.io/miner-registration查看商业主网的运行数据,了解Ultrain的共识规则和商业模式,并可结合此文https://www.ultrain.io/trends-detail/rk0uOe0gN充分了解Ultrain Token经济体系,明白Ultrain的经济模型建立于服务实体经济的基础之上,是一个更为良性和符合商业发展规律的模型。随着算力购买的商业需求的增长,Ultrain经济体系将会良性发展,保证早期进入者的利益,从而也可以保证整个商业生态的健康发展。

此外,继1月8日发布第二期测试网矿工招募公告后,我们再次收到了大量来自全球各地的申请信息,再次感谢大家对于Ultrain的大力支持,Ultrain于此正式宣布第二期测试网入选名单,欢迎各位加入Ultrain测试网络,提前预览Ultrain技术概貌:

1、[email protected]****.com

2、[email protected]****.com

3、[email protected]****.com

4、[email protected]****.com

5、[email protected]****.com

6、[email protected]****.com

7、[email protected]****.com

8、[email protected]****.com

9、[email protected]****.com

10、[email protected]****.com

11、[email protected]****.com

12、[email protected]****.com

(以下为Ultrain2018年12月26日-2019年1月13日的测试网矿工排名)

欢迎有意向者继续参与我们的下期测试公网矿工申请,也请大家保持对于Ultrain的关注!

ULTRAIN TEAM

2019年1月24日

阅读更多

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

Ultrain大学派·重庆站
B


阅读更多

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

邀请有礼?UltrainOne APP“星”人计划重磅来袭!
R

你有多久没有遇到过一个走心的APP了?

这是一款由Ultrain公链团队独立开发的APP——UltrainOne。

️它可供你在移动端创建Ultrain测试网钱包或导入钱包,简单易用,并可使用助记词、私钥两种钱包备份方案,防丢防盗,还支持ETH钱包内UGAS数量的查询;

️它会实时更新Ultrain官方新闻与资讯,让关心Ultrain的你第一时间了解我们的去向;

️它可供你一目了然地查看区块链相关App及DApp链接;

️它自带积分系统,除日常打卡获得积分外,你可参与不同时期的官方活动获得积分奖励;

️它有着周边商城,你可在商城模块中使用积分兑换Ultrain周边商品,比如可爱的Supernova超新星小象。

——在以上这些原有功能的基础上,Ultrain团队还更新了UltrainOne APP,优化了APP使用体验,并重磅新增了挖矿模块!你可在APP中申请购买矿机;而已购买矿机的用户,则可于APP内查询矿工数据。

你以为惊喜只有这些了吗?

不!我们还有一份新年好礼等着你:

UltrainOne"星"人计划!

进入“积分”页面参与活动️

划重点️:

2000邀请人名额,先到先得,速来!

阅读更多

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

新版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/)给我们留言哦!

阅读更多