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

第三次作业 #491

Open
wants to merge 112 commits into
base: 88-李晨曦
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
e695901
Create 测试
public2018 Dec 27, 2017
ca7f645
Create payroll.sol
Xuefeng-Zhu Jan 7, 2018
8d3f77d
Merge pull request #1 from linjie-1/master
Jan 7, 2018
e55edb6
update lesson folder
Jan 7, 2018
623e1ac
Merge pull request #12 from helloworldblockchain/master
Jan 7, 2018
3319fd5
Delete 软件测试1
Jan 7, 2018
3c04fea
Create yours.sol
Jan 7, 2018
ddc0fb1
Update yours.sol
Jan 7, 2018
76f556b
Create README.md
Jan 7, 2018
ee3a179
Create README.md
Jan 7, 2018
f0ae971
Update README.md
Jan 7, 2018
94e186c
Update README.md
Jan 7, 2018
875e149
Create README.md
Jan 7, 2018
c29a23e
Update README.md
Jan 7, 2018
2c0b136
Update README.md
Jan 7, 2018
55e7427
Update README.md
Jan 7, 2018
251bd4f
Update README.md
Jan 7, 2018
17ceaa5
Update README.md
Jan 7, 2018
388575e
Merge pull request #1 from linjie-1/master
zli25 Jan 7, 2018
dd09e78
Update README.md
linjie-1 Jan 7, 2018
a89e214
Update README.md
linjie-1 Jan 7, 2018
c794e3c
Update and rename lesson1/README.md to 2014/07/23/README.md
linjie-1 Jan 7, 2018
b2d1bd2
changshi xiugai master
Crapulencer Jan 7, 2018
047ed69
chexiaocaozuo
Crapulencer Jan 7, 2018
b777a5f
Rename 2014/07/23/README.md to lesson1/README.md
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
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
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
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
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
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
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
386acd7
Merge pull request #316 from taojing10/master
LeapM Jan 20, 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
c5669e8
创建第六、七课目录
lsdlinshunda Jan 25, 2018
69c6675
assignment 3
spiritlcx Jan 28, 2018
287e181
assignment 4
spiritlcx Jan 29, 2018
0510f4f
assignment 5
spiritlcx Jan 29, 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
Binary file added Lesson3/assignment/shotcut.zip
Binary file not shown.
94 changes: 94 additions & 0 deletions Lesson3/assignment/yours.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*作业请提交在这个目录下*/
pragma solidity ^0.4.14;

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

uint constant payDuration = 10 seconds;
uint totalSalary = 0;

address owner;
mapping (address => Employee) private employees;

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

modifier onlySelf(address employeeId) {
require(employeeId == msg.sender);
_;
}

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

function _partialPaid(Employee employee) private {
uint amount = (now - employee.lastPayday) / payDuration * employee.salary;
employee.id.transfer(amount);
}

function addEmployee(address employeeId, uint salary) public onlyOwner {
var employee = employees[employeeId];
assert(employee.id == 0x0);
employees[employeeId] = Employee(employeeId, salary, now);
totalSalary += salary * 1 ether;
}

function removeEmployee(address employeeId) public onlyOwner {
var employee = employees[employeeId];
assert(employee.id != 0x0);
_partialPaid(employees[employeeId]);
delete employees[employeeId];
totalSalary -= employees[employeeId].salary * 1 ether;
}

function updateEmployee(address employeeId, uint salary) public onlyOwner {
var employee = employees[employeeId];
assert(employee.id != 0x0);
_partialPaid(employee);
totalSalary -= employees[employeeId].salary;
employees[employeeId].salary = salary * 1 ether;
employees[employeeId].lastPayday = now;
totalSalary += salary * 1 ether;
}

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

function calculateRunway() public view returns (uint) {
assert(totalSalary > 0);
return this.balance / totalSalary;
}

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

function checkEmployee(address employeeId) public view returns (uint salary, uint lastPayday) {
var employee = employees[employeeId];
salary = employee.salary;
lastPayday = lastPayday;
}

function getPaid() public {
var employee = employees[msg.sender];
assert(employee.id != 0x0);
uint nextPayday = employees[msg.sender].lastPayday + payDuration;
assert(nextPayday < now);
employees[msg.sender].lastPayday = nextPayday;
employee.id.transfer(employees[msg.sender].salary);
}

function changePaymentAddress(address EmployeeId, address newAddress) public onlySelf(EmployeeId){
var employee = employees[msg.sender];
assert(employee.id != 0x0);
employees[msg.sender].id = newAddress;
}
}
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以太坊智能合约 第三课

这里是每一课的初始代码,有需要的同学可以参考
Empty file added Lesson3/orgin/payroll.sol
Empty file.
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
Loading