BONESDAO 开发公会 #10 任务需求文档
-
一屏式吐槽场所
-
顶部栏带有 BONESDAO 的 LOGO 展示及项目名称 BONESDAO,还要有下拉选框,选框内是 ONBOARD、BONESPay 和 BONES,以及最新和热门帖子的筛选,钱包连接按钮
-
在页面竖直方向的黄金分割处放置文本输入区,并且搭配发送按钮,UI需美观、大气,整体配色由开发者自行决定
-
同时每一次的发帖需和链上合约进行交互,发帖不收取任何费用
-
在页面下方会有不同用户的留言信息,并且是随机出现,不做任何的筛选,每一条留言后面均有点赞、复制和打赏的三个按钮,首期打赏允许使用 LAT、USDT、USDC 三类链上代币,等到 BONESPay 上线 memecoin 一键铸币功能后,吐槽场所将支持使用 memecoin 进行打赏
-
钱包连接按钮点击后是连接钱包,连接完成后鼠标悬停则会出现下拉,包含我的发布、复制地址、断开连接
Solidity 合约参考
pragma solidity ^0.4.11;
// References: https://github.com/yep/eth-tweet
contract TweetAccount {
// data structure of a single tweet
struct Tweet {
uint timestamp;
string tweetString;
}
// "array" of all tweets of this account: maps the tweet id to the actual tweet
mapping (uint => Tweet) _tweets;
// total number of tweets in the above _tweets mapping
uint _numberOfTweets;
// "owner" of this account: only admin is allowed to tweet
address _adminAddress;
// constructor
function TweetAccount() {
_numberOfTweets = 0;
_adminAddress = msg.sender;
}
// returns true if caller of function ("sender") is admin
function isAdmin() constant returns (bool isAdmin) {
return msg.sender == _adminAddress;
}
// create new tweet
function tweet(string tweetString) returns (int result) {
if (!isAdmin()) {
// only owner is allowed to create tweets for this account
result = -1;
} else if (bytes(tweetString).length > 160) {
// tweet contains more than 160 bytes
result = -2;
} else {
_tweets[_numberOfTweets].timestamp = now;
_tweets[_numberOfTweets].tweetString = tweetString;
_numberOfTweets++;
result = 0; // success
}
}
function getTweet(uint tweetId) constant returns (string tweetString, uint timestamp) {
// returns two values
tweetString = _tweets[tweetId].tweetString;
timestamp = _tweets[tweetId].timestamp;
}
function getLatestTweet() constant returns (string tweetString, uint timestamp, uint numberOfTweets) {
// returns three values
tweetString = _tweets[_numberOfTweets - 1].tweetString;
timestamp = _tweets[_numberOfTweets - 1].timestamp;
numberOfTweets = _numberOfTweets;
}
function getOwnerAddress() constant returns (address adminAddress) {
return _adminAddress;
}
function getNumberOfTweets() constant returns (uint numberOfTweets) {
return _numberOfTweets;
}
// other users can send donations to your account: use this function for donation withdrawal
function adminRetrieveDonations(address receiver) {
if (isAdmin()) {
receiver.send(this.balance);
}
}
function adminDeleteAccount() {
if (isAdmin()) {
suicide(_adminAddress); // this is a predefined function, it deletes the contract and returns all funds to the owner's address
}
}
}