Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

96-韩博文-五六课 #524

Open
wants to merge 132 commits into
base: 96-韩博文
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
a5691df
Merge pull request #1 from linjie-1/master
linjie-2 Dec 18, 2017
d0eddfd
Create 【测试】第一课作业
linjie-2 Dec 18, 2017
5c804ee
Merge pull request #1 from linjie-2/master
linjie-1 Dec 18, 2017
e695901
Create 测试
public2018 Dec 27, 2017
388575e
Merge pull request #1 from linjie-1/master
zli25 Jan 7, 2018
d2a8fa5
Merge pull request #32 from public2018/master
public2018 Jan 8, 2018
d2c795d
Update README.md
linjie-1 Jan 8, 2018
040a107
Update README.md
linjie-1 Jan 8, 2018
b3be527
Update README.md
linjie-1 Jan 8, 2018
f06e298
Update README.md
linjie-1 Jan 8, 2018
b90d86f
payroll homework
Jan 8, 2018
0c1e86f
Merge branch '91-Chris' of https://github.com/taojing10/guigulive-ope…
Jan 8, 2018
8512a0c
remove orginal address
Jan 8, 2018
36dd3f1
Update README.md
Jan 8, 2018
3dd59ce
Update README.md
Jan 8, 2018
293161a
Update README.md
linjie-1 Jan 8, 2018
81bd092
Delete 测试
Jan 8, 2018
e4e5383
将课程表的图片替换成markdown实现
lsdlinshunda Jan 8, 2018
d60b6b0
第一次作业
yangfan3211 Jan 8, 2018
901d828
first homework
seanxwzhang Jan 9, 2018
db44ac5
Revert "first homework"
seanxwzhang Jan 9, 2018
7952c08
第一次作业
BitEveryXW Jan 9, 2018
2874dfb
Merge pull request #2 from linjie-1/master
steven672 Jan 9, 2018
27587f6
Create 第一课作业
steven672 Jan 9, 2018
04d95b4
Delete 第一课作业
steven672 Jan 9, 2018
3040b06
Update yours.sol
steven672 Jan 9, 2018
503a54a
拆分函数
yangfan3211 Jan 9, 2018
371670a
.
yangfan3211 Jan 9, 2018
da27d33
.
yangfan3211 Jan 9, 2018
ce541bd
优化
yangfan3211 Jan 9, 2018
c6032c2
Merge pull request #1 from linjie-1/master
zl777 Jan 10, 2018
1d31ebb
Update README.md
linjie-1 Jan 10, 2018
d64d000
Update README.md
linjie-1 Jan 10, 2018
c30b7c5
Update README.md
linjie-1 Jan 10, 2018
b8802e3
Update README.md
linjie-1 Jan 10, 2018
46f2a72
Create README.md
linjie-1 Jan 10, 2018
b6414d5
Create README.md
linjie-1 Jan 10, 2018
6a024e5
Update README.md
linjie-1 Jan 10, 2018
1452883
Create README.md
linjie-1 Jan 10, 2018
2b8da80
Update README.md
linjie-1 Jan 10, 2018
f98dcab
Create yours.sol
linjie-1 Jan 10, 2018
529ef5a
Update README.md
linjie-1 Jan 10, 2018
39b2136
Delete yours.sol
linjie-1 Jan 10, 2018
a298b92
Create yours.sol
linjie-1 Jan 10, 2018
65f8dc3
Delete yours.sol
linjie-1 Jan 10, 2018
758a324
Create yours.sol
lsdlinshunda Jan 10, 2018
602f1c1
Update yours.sol
zl777 Jan 10, 2018
5483f5e
lesson 2
modong Jan 10, 2018
ca137ac
Merge remote-tracking branch 'upstream/master'
yangfan3211 Jan 10, 2018
3af7f4f
调整课程表中课程更新时间
lsdlinshunda Jan 10, 2018
9ee0a7b
第一次作业 第二次提交 @1/12/18
BitEveryXW Jan 12, 2018
61681d3
Merge pull request #145 from BitEveryXW/XW_dev
BitEveryXW Jan 12, 2018
e164779
Revert "Xw dev"
BitEveryXW Jan 12, 2018
67064fd
Merge pull request #146 from linjie-1/revert-145-XW_dev
BitEveryXW Jan 12, 2018
10b864f
根据要求加了require 函数, 并更新了源代码的基本function。 还请老师在看下~
steven672 Jan 12, 2018
60f2dcd
update
steven672 Jan 12, 2018
8a87868
update
steven672 Jan 12, 2018
adbbd41
Merge remote-tracking branch 'upstream/master'
yangfan3211 Jan 13, 2018
9923178
Merge pull request #1 from linjie-1/master
zyzlouis Jan 13, 2018
7852900
Merge pull request #170 from zli25/master
zli25 Jan 13, 2018
31eeb02
第二课作业
yangfan3211 Jan 13, 2018
d07ab7f
Update yours.sol
zl777 Jan 13, 2018
b99b727
Merge pull request #217 from linjie-1/zl777-patch-1
hezhihua81 Jan 13, 2018
55fac2b
Merge pull request #3 from linjie-1/master
steven672 Jan 13, 2018
5b96d76
revert last mis-checkin...
hezhihua81 Jan 13, 2018
31621b6
Update
steven672 Jan 13, 2018
2e095ae
update hw2
steven672 Jan 13, 2018
dbff9b0
创建第三课目录
lsdlinshunda Jan 14, 2018
78fa6e7
添加第三课说明
lsdlinshunda Jan 14, 2018
4d8f45b
添加第三课作业说明
lsdlinshunda Jan 14, 2018
afdae0c
Merge remote-tracking branch 'upstream/master'
yangfan3211 Jan 15, 2018
c85308b
第三课
yangfan3211 Jan 15, 2018
bd71370
第三课
yangfan3211 Jan 15, 2018
718e0e6
第三课
yangfan3211 Jan 15, 2018
1010b85
Merge branch 'master' into master
steven672 Jan 17, 2018
80e53bb
delete hw2
steven672 Jan 17, 2018
ec1f212
restore
steven672 Jan 17, 2018
e52488a
Merge pull request #2 from linjie-1/master
zyzlouis Jan 17, 2018
20e9d21
hw-2
Jan 17, 2018
68df86a
Merge pull request #304 from zl777/master
zl777 Jan 17, 2018
bf357cf
Create README.md
linjie-1 Jan 17, 2018
50c15e3
Create README.md
linjie-1 Jan 17, 2018
83e2b9b
Create payroll.sol
linjie-1 Jan 17, 2018
b38d0ff
Create README.md
linjie-1 Jan 17, 2018
953eab2
Create yours.sol
linjie-1 Jan 17, 2018
e28b1b3
Delete yours.sol
linjie-1 Jan 17, 2018
b72fc45
Create yours.sol
linjie-1 Jan 17, 2018
c66e0cc
Update yours.sol
linjie-1 Jan 17, 2018
159bd42
Revert "第3课的代码"
lsdlinshunda Jan 17, 2018
cdece6b
Merge pull request #315 from linjie-1/revert-304-master
lsdlinshunda Jan 17, 2018
656972c
Merge branch 'master' of https://github.com/linjie-1/guigulive-operation
Jan 17, 2018
d355bf4
HW-3
Jan 17, 2018
15f22fd
Merge pull request #321 from zyzlouis/master
zyzlouis Jan 18, 2018
e8a7a93
Revert "Get 第四课"
lsdlinshunda Jan 18, 2018
e8c390c
Merge pull request #327 from linjie-1/revert-321-master
lsdlinshunda Jan 18, 2018
08dd48c
修改附加题
yangfan3211 Jan 19, 2018
3f5d92f
增加代码
yangfan3211 Jan 20, 2018
d4860f1
修改作业
yangfan3211 Jan 20, 2018
7617e21
Merge branch 'master' of https://github.com/linjie-1/guigulive-operation
yangfan3211 Jan 20, 2018
064653a
forth homework
Jan 20, 2018
386acd7
Merge pull request #316 from taojing10/master
LeapM Jan 20, 2018
e026572
修改作业
yangfan3211 Jan 21, 2018
88acde5
.
yangfan3211 Jan 21, 2018
3ec4c1e
Revert "91_HW-3"
lsdlinshunda Jan 22, 2018
1c6c8df
Merge pull request #396 from linjie-1/revert-316-master
lsdlinshunda Jan 22, 2018
e834fa8
添加第五课目录
lsdlinshunda Jan 22, 2018
6aa2351
whatever
Jan 22, 2018
b224d03
.
yangfan3211 Jan 24, 2018
1cf87df
Merge branch 'master' of https://github.com/yangfan1992/guigulive-ope…
yangfan3211 Jan 24, 2018
d4e113b
Merge branch 'master' of https://github.com/linjie-1/guigulive-operat…
yangfan3211 Jan 24, 2018
5c8bac9
第五课作业
yangfan3211 Jan 24, 2018
c5669e8
创建第六、七课目录
lsdlinshunda Jan 25, 2018
962e58f
.
yangfan3211 Jan 26, 2018
a60310a
Merge branch 'master' of https://github.com/yangfan1992/guigulive-ope…
yangfan3211 Jan 26, 2018
d88202a
Merge branch 'fifth_homework' of https://github.com/yangfan1992/guigu…
yangfan3211 Jan 26, 2018
a841e2f
修改
yangfan3211 Jan 26, 2018
9bc0cae
修改作业
yangfan3211 Jan 27, 2018
f9fbe17
修改作业
yangfan3211 Jan 27, 2018
223a6e8
修改
yangfan3211 Jan 28, 2018
791bcb9
解决冲突
yangfan3211 Jan 28, 2018
0276f7a
解决冲突
yangfan3211 Jan 28, 2018
076e71b
Merge pull request #488 from yangfan1992/fifth_homework
washingweb Jan 29, 2018
7e0bf0b
commit files
Jan 30, 2018
38b56ee
Merge branch 'master' of github.com:linjie-1/guigulive-operation
Jan 30, 2018
89f79ce
Merge branch 'master' into 96-韩博文
Jan 30, 2018
803b329
修改第三课作业格式
Jan 30, 2018
276aa20
copy lesson3 code
Jan 30, 2018
4392414
Revert "54_陈扬帆_第五次作业(冲突已解决)"
washingweb Jan 31, 2018
9d2ec7d
Merge pull request #507 from linjie-1/revert-488-fifth_homework
washingweb Jan 31, 2018
e640004
提交第四课作业
Jan 31, 2018
ffc238e
Merge branch 'master' of github.com:linjie-1/guigulive-operation into…
Jan 31, 2018
d0fb056
提交第五第六课
Feb 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Lesson2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 硅谷live以太坊智能合约频道官方地址

### 第二课《智能合约设计进阶-多员工薪酬系统》

目录结构
<br/>|
<br/>|--orgin 课程初始代码
<br/>|
<br/>|--assignment 课程作业提交代码
<br/>
### 本节知识点
第2课:智能合约设计进阶-多员工薪酬系统
- 动态静态数组的不同
- 函数输入参数检查 revert
- 循环与遍历的安全性
- 程序运行错误检查和容错:assert与require
10 changes: 10 additions & 0 deletions Lesson2/assignment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 硅谷live以太坊智能合约 第二课作业
这里是同学提交作业的目录

### 第二课:课后作业
完成今天的智能合约添加100ETH到合约中
- 加入十个员工,每个员工的薪水都是1ETH
每次加入一个员工后调用calculateRunway这个函数,并且记录消耗的gas是多少?Gas变化么?如果有 为什么?
- 如何优化calculateRunway这个函数来减少gas的消耗?
提交:智能合约代码,gas变化的记录,calculateRunway函数的优化

1 change: 1 addition & 0 deletions Lesson2/assignment/yours.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*作业请提交在这个目录下*/
3 changes: 3 additions & 0 deletions Lesson2/orgin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 硅谷live以太坊智能合约 第二课《智能合约设计进阶-多员工薪酬系统》

这里是每一课的初始代码,有需要的同学可以参考
50 changes: 50 additions & 0 deletions Lesson2/orgin/payroll.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
pragma solidity ^0.4.14;

contract Payroll {
struct Employee {
address id;
uint salary;
uint lastPayday;
}

uint constant payDuration = 10 seconds;

address owner;
Employee[] employees;

function Payroll() {
owner = msg.sender;
}

function _partialPaid(Employee employee) private {
}

function _findEmployee(address employeeId) private returns (Employee, uint) {
}

function addEmployee(address employeeId, uint salary) {
}

function removeEmployee(address employeeId) {
}

function updateEmployee(address employeeId, uint salary) {
}

function addFund() payable returns (uint) {
}

function calculateRunway() returns (uint) {
uint totalSalary = 0;
for (uint i = 0; i < employees.length; i++) {
totalSalary += employees[i].salary;
}
return this.balance / totalSalary;
}

function hasEnoughFund() returns (bool) {
}

function getPaid() {
}
}
16 changes: 16 additions & 0 deletions Lesson3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 硅谷live以太坊智能合约频道官方地址

### 第三课《智能合约后端优化和产品化》

目录结构
<br/>|
<br/>|--orgin 课程初始代码
<br/>|
<br/>|--assignment 课程作业提交代码
<br/>
### 本节知识点
第3课:智能合约后端优化和产品化
- 如何通过数据结构优化降低合约执行成本
- 合约的继承
- 巧用modifier
- 以太坊函数库的使用和基本介绍
14 changes: 14 additions & 0 deletions Lesson3/assignment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## 硅谷live以太坊智能合约 第三课作业
这里是同学提交作业的目录

### 第三课:课后作业
- 第一题:完成今天所开发的合约产品化内容,使用Remix调用每一个函数,提交函数调用截图
- 第二题:增加 changePaymentAddress 函数,更改员工的薪水支付地址,思考一下能否使用modifier整合某个功能
- 第三题(加分题):自学C3 Linearization, 求以下 contract Z 的继承线
- contract O
- contract A is O
- contract B is O
- contract C is O
- contract K1 is A, B
- contract K2 is A, C
- contract Z is K1, K2
83 changes: 83 additions & 0 deletions Lesson3/assignment/yours.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
pragma solidity ^ 0.4.14;
import "./SafeMath.sol";
contract Payroll {
using SafeMath for uint;
struct Employee {
address id;
uint salary;
uint lastPayday;
}
uint constant payDuration = 10 seconds;
address owner;
mapping (address => Employee) employees;

uint totalSalary = 0;

function Payroll() public {
owner = msg.sender;
}

function _partialPaid(Employee employee) private {
uint payment = employee.salary.mul((now.sub(employee.lastPayday)).div(payDuration)) ;
if(payment > 0){
employee.lastPayday = now;
employee.id.transfer(payment);
}
}


modifier requireOwner() {
require(msg.sender == owner);
_;
}

modifier validAddress(address addr) {
require(addr != 0x0);
_;
}

function addEmployee(address employeeId, uint salary) public requireOwner
validAddress(employeeId){
var e = employees[employeeId];
if (e.id != 0x0) revert();
totalSalary = totalSalary.add(salary);
employees[employeeId] = Employee(employeeId, salary, now);
}

function removeEmployee(address employeeId) public payable requireOwner validAddress(employeeId){
var e = employees[employeeId];
if (e.id == 0x0) revert();
_partialPaid(e);
totalSalary-= e.salary;
}

function updateEmployee(address employeeId, uint salary) public requireOwner payable validAddress(employeeId){
var e = employees[employeeId];
if (e.id == 0x0) revert();
e.salary = salary;
}


function addFund() public payable returns(uint)
{
return this.balance;
}



function calculateRunway() public view returns(uint) {
return totalSalary;
}

function hasEnoughFund() public view returns(bool) {
return calculateRunway() > 0;
}

function getPaid(Employee e) internal requireOwner {

var nextPayday = e.lastPayday.add(payDuration);
assert(nextPayday < now);
e.lastPayday = nextPayday;
e.id.transfer(e.salary);
}
}
3 changes: 3 additions & 0 deletions Lesson3/orgin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 硅谷live以太坊智能合约 第三课

这里是每一课的初始代码,有需要的同学可以参考
File renamed without changes.
16 changes: 16 additions & 0 deletions Lesson4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 硅谷live以太坊智能合约频道官方地址

### 第四课《使用Truffle架构进行前后端交互,测试,部署》

目录结构
<br/>|
<br/>|--orgin 课程初始代码
<br/>|
<br/>|--assignment 课程作业提交代码
<br/>
### 本节知识点
第4课:使用Truffle架构进行前后端交互,测试,部署
- 为什么要用Truffle,Truffle的基本概念
- Truffle 的command line 功能
- 初始化项目与Truffle项目目录结构
- 编译部署合约到testrpc
12 changes: 12 additions & 0 deletions Lesson4/assignment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## 硅谷live以太坊智能合约 第四课作业
这里是同学提交作业的目录

### 第四课:课后作业
- 将第三课完成的payroll.sol程序导入truffle工程
- 在test文件夹中,写出对如下两个函数的单元测试:
- function addEmployee(address employeeId, uint salary) onlyOwner
- function removeEmployee(address employeeId) onlyOwner employeeExist(employeeId)
- 思考一下我们如何能覆盖所有的测试路径,包括函数异常的捕捉
- (加分题,选作)
- 写出对以下函数的基于solidity或javascript的单元测试 function getPaid() employeeExist(msg.sender)
- Hint:思考如何对timestamp进行修改,是否需要对所测试的合约进行修改来达到测试的目的?
Loading