@zhenxi
2017-07-22T07:31:33.000000Z
字数 4964
阅读 1698
Asch
目前上面已经有一个dapp,id为97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86。
涉及如下几个账户
dapp注册账户:chalk flame jeans rebuild dutch stone abstract capital lucky pottery raven depend
普通dapp账户: minor borrow display rebel depart core buzz right distance avocado immense push,已经进行过充值、发表了一篇文章以及相关评论、点赞、评论打赏等
需要配合如下文章阅读本文
《内容发布平台dapp》相关合约代码说明:https://github.com/AschPlatform/cctime/issues/1
dapp部署概要:http://282ade8a.wiz03.com/share/s/0EaJWa21dAvM2czQo63zbal23T3ziU0K5Qgc2SLpoz2CjMAE
在dapps目录下:git clone https://github.com/AschPlatform/cctime.git./node_modules/asch-cli/bin/asch-cli registerdapp -f dapps/cctime/dapp.json -e "chalk flame jeans rebuild dutch stone abstract capital lucky pottery raven depend"// 返回结果为dappid97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86mv cctime 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86重启aschd后,dapp即可使用。web地址:http://10.10.30.10:4096/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/,目前该dapp前端ui尚未完成,但可以自行填写参数调用apiapi也可以访问,举例:http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/blocks/height,可以查询dapp高度
./node_modules/asch-cli/bin/asch-cli deposit -e "minor borrow display rebel depart core buzz right distance avocado immense push" -d 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86 -c XAS -a 10000000000// 返回结果为交易id36e1626d5ef30ca1c75a3b96cdf6489984d64336736278d429c2300fd10ff126
在dapp内给A6H9rawJ7qvE2rKwQfdtBHdeYVehB8gFzC转1.0XASz资产./node_modules/asch-cli/bin/asch-cli dapptransaction -e "minor borrow display rebel depart core buzz right distance avocado immense push" -d 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86 -t 3 -f 10000000 -a '["XAS","100000000","A6H9rawJ7qvE2rKwQfdtBHdeYVehB8gFzC"]'// 返回交易id90b85ff532c546ee18e54e0e5d0473fadfa421b29017abcea410245a17e89d35
curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/balances/A6H9rawJ7qvE2rKwQfdtBHdeYVehB8gFzC' && echo// 返回结果{"balances": [{"currency": "XAS","balance": "100000000"}],"success": true}
curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/blocks/height' && echo// 返回结果{"height": 2,"success": true}
./node_modules/asch-cli/bin/asch-cli dapptransaction -e "minor borrow display rebel depart core buzz right distance avocado immense push" -d 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86 -t 1000 -f 10000000 -a '["title-test","","hello world!","tag1,tag2"]'// 返回结果223c29dc490302b81109ecfd71c27edf16bcd182942c289a758256ec27d5cf7b
curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/articles' && echo// 返回结果{"articles": [{"id": "1","tid": "223c29dc490302b81109ecfd71c27edf16bcd182942c289a758256ec27d5cf7b","authorId": "AFUH568CbGC2GPcE4gXHiZhxdYQYfziz2J","timestamp": 33595702,"title": "title-test","url": "","text": "hello world!","tags": "test1,test2,code","votes": 0,"comments": 0,"t_timestamp": 33595702,"t_type": 1000,"t_height": 359,"score": 0}],"success": true}
curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/articles/1' && echo// 返回{"article": {"id": "1", //文章id,评论时的参数"tid": "223c29dc490302b81109ecfd71c27edf16bcd182942c289a758256ec27d5cf7b","authorId": "AFUH568CbGC2GPcE4gXHiZhxdYQYfziz2J","timestamp": 33595702,"title": "title-test","url": "","text": "hello world!","tags": "test1,test2,code","votes": 1, //点赞数"comments": 1, // 评论数"t_timestamp": 33595702,"t_type": 1000, //合约id"t_height": 359 //dapp区块高度},"success": true}
文章列表结果中的对应id的文章"comments"会加1./node_modules/asch-cli/bin/asch-cli dapptransaction -e "minor borrow display rebel depart core buzz right distance avocado immense push" -d 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86 -t 1001 -f 10000000 -a '["1","","content1"]'// 返回交易id674964e3bbb75d31785ff75d56df85f27b5f02a453c462df37e96fc272292898
curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/articles/1/comments' && echo// 返回结果{"comments": [{"id": 1, //comment id,即cid,给评论打赏时会用"tid": "674964e3bbb75d31785ff75d56df85f27b5f02a453c462df37e96fc272292898","authorId": "AFUH568CbGC2GPcE4gXHiZhxdYQYfziz2J","aid": 1, //文章id"pid": 0,"content": "content1","rewards": 0,"t_timestamp": 33597194,"t_type": 1001, //合约id"t_height": 472}],"count": 1,"success": true}
0.001xas使该文章的"votes"加1,即1票,作者和受托人各50%,即0.0005xas
./node_modules/asch-cli/bin/asch-cli dapptransaction -e "minor borrow display rebel depart core buzz right distance avocado immense push" -d 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86 -t 1002 -f 10000000 -a '["1","100000"]'// 返回,3f2a934829dd0301d4cf9e57772f76fa1e3c0b79eab07d59e5344078318ac71c
打赏的xas全部归评论人
./node_modules/asch-cli/bin/asch-cli dapptransaction -e "minor borrow display rebel depart core buzz right distance avocado immense push" -d 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86 -t 1003 -f 10000000 -a '["1","100000000"]'// 返回,打赏1.0 xasa8ecd9b0f80204d4aa1a63e1c18a4b6f582c5f8adc4b6c862246e913be008e2d