为了庆祝Oasis-Eth ParaTime在Oasis网络的正式上线, 官方发起了黑客马拉松活动. 活动链接: https://oasisprotocol.org/ch-oasis-eth-hackathon
这里写一下挑战1的攻略
挑战#1: 构建和部署一个ERC20代币合约(50 ROSE, .5 OETH)
获取钱包地址 进入智能合约开发的Web端网站:http://oasiseth.org/dev
点击左下角钢笔的图形,复制显示的第一个钱包地址:
通过水龙头网站获得测试币 进入水龙头网站: http://faucet.oasiseth.org/ 输入上一步复制的钱包地址获得0.01 OETH测试币
创建ERC-20代币 如果你知道怎么写ERC-20代币的合约,直接跳过这一步。
如果你不知道怎么写合约,复制下面的代码到智能合约开发的Web端网站,修改一下代币的名字和代号就好了。比如我的代币的名字是Shop token,代号是SHOP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 pragma solidity ^0.4.0; contract ERC20 { string public constant name = "代币的名字"; string public constant symbol = "代币的代号"; uint8 public constant decimals = 0; event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event Transfer(address indexed from, address indexed to, uint tokens); mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; uint256 totalSupply_; using SafeMath for uint256; constructor(uint256 total) public { totalSupply_ = total; balances[msg.sender] = totalSupply_; } function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address tokenOwner) public view returns (uint) { return balances[tokenOwner]; } function transfer(address receiver, uint numTokens) public returns (bool) { require(numTokens <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(numTokens); balances[receiver] = balances[receiver].add(numTokens); emit Transfer(msg.sender, receiver, numTokens); return true; } function approve(address delegate, uint numTokens) public returns (bool) { allowed[msg.sender][delegate] = numTokens; emit Approval(msg.sender, delegate, numTokens); return true; } function allowance(address owner, address delegate) public view returns (uint) { return allowed[owner][delegate]; } function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) { require(numTokens <= balances[owner]); require(numTokens <= allowed[owner][msg.sender]); balances[owner] = balances[owner].sub(numTokens); allowed[owner][msg.sender] = allowed[owner][msg.sender].sub(numTokens); balances[buyer] = balances[buyer].add(numTokens); emit Transfer(owner, buyer, numTokens); return true; } } library SafeMath { function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
部署合约 合约写好后,点击上方的“Compile”, 选择”ERC20”, 输入代币的总量,最后点击”Deploy to the chain” 按钮。等待合约部署成功
合约部署成功后,会显示合约的交易id和合约地址。记下合约的地址,填表格的时候需要这个地址
填表格 弄好合约后,如果你不想继续下面的挑战,可以直接填表格。表格链接:https://oasisprotocol.org/ch-oasis-eth-hackathon
在网站的中间那个位置,点击开始
第一个挑战就这样完成了。第二个挑战目前网站上不去,等能上去了再出攻略