[关闭]
@zhenxi 2017-07-22T15:31:33.000000Z 字数 4964 阅读 1567

Dapp相关

Asch


Dapp相关

目前上面已经有一个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

注册dapp

  1. dapps目录下:
  2. git clone https://github.com/AschPlatform/cctime.git
  3. ./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"
  4. // 返回结果为dappid
  5. 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86
  6. mv cctime 97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86
  7. 重启aschd后,dapp即可使用。
  8. web地址:http://10.10.30.10:4096/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/,目前该dapp前端ui尚未完成,但可以自行填写参数调用api
  9. api也可以访问,举例:http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/blocks/height,可以查询dapp高度

充值100 xas到dapp

  1. ./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
  2. // 返回结果为交易id
  3. 36e1626d5ef30ca1c75a3b96cdf6489984d64336736278d429c2300fd10ff126

dapp内部转账

  1. dapp内给A6H9rawJ7qvE2rKwQfdtBHdeYVehB8gFzC1.0XASz资产
  2. ./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"]'
  3. // 返回交易id
  4. 90b85ff532c546ee18e54e0e5d0473fadfa421b29017abcea410245a17e89d35

查询dapp账户余额

  1. curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/balances/A6H9rawJ7qvE2rKwQfdtBHdeYVehB8gFzC' && echo
  2. // 返回结果
  3. {
  4. "balances": [
  5. {
  6. "currency": "XAS",
  7. "balance": "100000000"
  8. }
  9. ],
  10. "success": true
  11. }

查询dapp高度

  1. curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/blocks/height' && echo
  2. // 返回结果
  3. {
  4. "height": 2,
  5. "success": true
  6. }

发布文章

  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 1000 -f 10000000 -a '["title-test","","hello world!","tag1,tag2"]'
  2. // 返回结果
  3. 223c29dc490302b81109ecfd71c27edf16bcd182942c289a758256ec27d5cf7b

文章列表

  1. curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/articles' && echo
  2. // 返回结果
  3. {
  4. "articles": [
  5. {
  6. "id": "1",
  7. "tid": "223c29dc490302b81109ecfd71c27edf16bcd182942c289a758256ec27d5cf7b",
  8. "authorId": "AFUH568CbGC2GPcE4gXHiZhxdYQYfziz2J",
  9. "timestamp": 33595702,
  10. "title": "title-test",
  11. "url": "",
  12. "text": "hello world!",
  13. "tags": "test1,test2,code",
  14. "votes": 0,
  15. "comments": 0,
  16. "t_timestamp": 33595702,
  17. "t_type": 1000,
  18. "t_height": 359,
  19. "score": 0
  20. }
  21. ],
  22. "success": true
  23. }

文章详情

  1. curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/articles/1' && echo
  2. // 返回
  3. {
  4. "article": {
  5. "id": "1", //文章id,评论时的参数
  6. "tid": "223c29dc490302b81109ecfd71c27edf16bcd182942c289a758256ec27d5cf7b",
  7. "authorId": "AFUH568CbGC2GPcE4gXHiZhxdYQYfziz2J",
  8. "timestamp": 33595702,
  9. "title": "title-test",
  10. "url": "",
  11. "text": "hello world!",
  12. "tags": "test1,test2,code",
  13. "votes": 1, //点赞数
  14. "comments": 1, // 评论数
  15. "t_timestamp": 33595702,
  16. "t_type": 1000, //合约id
  17. "t_height": 359 //dapp区块高度
  18. },
  19. "success": true
  20. }

评论

  1. 文章列表结果中的对应id的文章"comments"会加1
  2. ./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"]'
  3. // 返回交易id
  4. 674964e3bbb75d31785ff75d56df85f27b5f02a453c462df37e96fc272292898

获取文章评论列表

  1. curl -X GET 'http://10.10.30.10:4096/api/dapps/97b12583fed2973da179a6484ef15155f49503bc7ce2d45a6574f8e8ab09ff86/articles/1/comments' && echo
  2. // 返回结果
  3. {
  4. "comments": [
  5. {
  6. "id": 1, //comment id,即cid,给评论打赏时会用
  7. "tid": "674964e3bbb75d31785ff75d56df85f27b5f02a453c462df37e96fc272292898",
  8. "authorId": "AFUH568CbGC2GPcE4gXHiZhxdYQYfziz2J",
  9. "aid": 1, //文章id
  10. "pid": 0,
  11. "content": "content1",
  12. "rewards": 0,
  13. "t_timestamp": 33597194,
  14. "t_type": 1001, //合约id
  15. "t_height": 472
  16. }
  17. ],
  18. "count": 1,
  19. "success": true
  20. }

给文章投票

0.001xas使该文章的"votes"加1,即1票,作者和受托人各50%,即0.0005xas

  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 1002 -f 10000000 -a '["1","100000"]'
  2. // 返回,
  3. 3f2a934829dd0301d4cf9e57772f76fa1e3c0b79eab07d59e5344078318ac71c

给评论打赏

打赏的xas全部归评论人

  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 1003 -f 10000000 -a '["1","100000000"]'
  2. // 返回,打赏1.0 xas
  3. a8ecd9b0f80204d4aa1a63e1c18a4b6f582c5f8adc4b6c862246e913be008e2d
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注