Skip to content

Commit

Permalink
Merge pull request #1 from linjie-1/master
Browse files Browse the repository at this point in the history
lesson 2
  • Loading branch information
StrangeCloud9 committed Jan 13, 2018
2 parents ca7913b + 5b96d76 commit cb6dc0c
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 13 deletions.
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() {
}
}
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# 老董区块链干货铺
硅谷live以太坊智能合约频道官方地址
# 硅谷live以太坊智能合约频道官方地址

### 一、课程如何更新的呢?(以北京时间为准)

Expand All @@ -8,12 +7,12 @@
| 日期 | 课程 |
| ------ | ------ |
| 1月7号 | 第一课 《智能合约设计初阶-单员工薪酬系统》|
| 1月10号 | 第二课 |
| 1月14号 | 第三课 |
| 1月17号 | 第四课 |
| 1月21号 | 第五课 |
| 1月24号 | 第六课 |
| 1月28号 | 第七课 |
| 1月10号 | 第二课 《智能合约设计进阶-多员工薪酬系统》|
| 1月14号 | 第三课 《智能合约后端优化和产品化》|
| 1月17号 | 第四课 《使用Truffle架构进行前后端交互,测试,部署》|
| 1月21号 | 第五课 《分布式应用前端产品化》|
| 1月24号 | 第六课 《分布式应用前端产品化-进阶》|
| 1月28号 | 第七课 《智能合约的主网部署》|
| 2月4号 | 总答疑 |

每周日上午10点为直播答疑(14、21、28号)
Expand Down Expand Up @@ -92,4 +91,12 @@
- 王鲁明:负责91-100号,同时在社群“开拓者J战队”担任助教

## 四、课程表
![我的图片](https://ws2.sinaimg.cn/large/006tNc79ly1fn97890w5aj30ox085aaf.jpg)

北京时间 | 星期一 | 星期二 | 星期三 | 星期四 | 星期五 | 星期六 | 星期天
:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
09:00 | 鲸打卡 | 鲸打卡 | 鲸打卡 | 鲸打卡 | 鲸打卡 | 鲸打卡 | 鲸打卡
10:00 | | | | | | live分享会 | 直播答疑
11:00 | | | | | | | 课程更新
12:00 | | | 疑难知识点汇总和解析 | | | 疑难知识点汇总和解析 | |
21:00 | 每日复盘 | 每日复盘 | 每日复盘 | 每日复盘 | 每日复盘 | 每日复盘 | 每日复盘
22:00 | | | 周日课程作业截止/<br/>课程更新 | | 课外知识点拓展 | 周三课程作业截止 |
2 changes: 1 addition & 1 deletion lesson1/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 老董区块链干货铺
## 硅谷live以太坊智能合约频道官方地址

### 第一课《智能合约设计初阶-单员工薪酬系统》

Expand Down
2 changes: 1 addition & 1 deletion lesson1/assignment/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 老董区块链干货铺 第一课作业
## 硅谷live以太坊智能合约 第一课作业
这里是同学提交作业的目录

### 第一课:课后作业
Expand Down
2 changes: 1 addition & 1 deletion lesson1/orgin/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 老董区块链干货铺 第一课《智能合约设计初阶-单员工薪酬系统》
## 硅谷live以太坊智能合约 第一课《智能合约设计初阶-单员工薪酬系统》

这里是每一课的初始代码,有需要的同学可以参考
1 change: 0 additions & 1 deletion 测试

This file was deleted.

0 comments on commit cb6dc0c

Please sign in to comment.