diff --git a/201908-Shenzhen/Bithacks/README.md b/201908-Shenzhen/Bithacks/README.md deleted file mode 100755 index 1f16d6dae..000000000 --- a/201908-Shenzhen/Bithacks/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# DeFiDefender - -基于分布式身份的微贷联合风控平台 -团队: 李其柄、林泽培、高天尧、王兵、应昊 - -## 项目背景 - -金融的核心是风控。近年来互联网金融科技的爆发,特别是网络信贷业务的快速增长,一方面降低了金融领域的信息不对称性,推动了普惠金融的发展,另一方面也滋生了诸多新型的欺诈手段,金融欺诈风险不断升级。在征信体系和数字身份体系不健全的背景下,用户逾期率、多头借贷率不断攀升,身份冒用和团伙欺诈等黑产问题频出,严重威胁了借贷平台的运营。不同借贷主体出于商业竞争关系等因素各自为营,无法共享彼此的客户信用数据,导致共债问题比较明显,一个用户可能在多家机构借贷,使得风险积累。即使客户集可以被共享,特征数据的质量和来源也无法得到有效的验证,这限制了借贷平台的风险刻画和个性化定价能力(如利率)。更为关键的是,用户隐私保护和身份主权意识逐渐觉醒,相关法案和协议也正在推行(例如欧洲隐私条例GDPR和W3C DID身份标准),揭示了未来机构间共享用户数据的难度。 - -为了在隐私合规的情况下实现多平台数据的互联互通,建立反欺诈联合数据库,分布式身份体系的引入是至关重要的。本项目将基于FISCO BCOS、WeIdentity和代理重加密技术,构建可多方验证的用户网络自主身份,保证相关数据的隐私存储、授权共享和可信溯源,并以小额借贷的贷前身份识别和风险管理作为切入点,探讨新技术背景下的借贷反欺诈联合模型。 - -## 技术架构 -多方诉求的本质是对新型网络金融基础设施的需求。我们从底层出发,将系统划分为三层架构: 底层把数据主权归还用户,中层形成统一的用户网络身份标识符和凭证验证标准,上层进行金融的联合风控。每一层所使用的技术栈如下: - -![tech_relation](assets/tech_relation2.png) - -技术方案如下: - -![tech_solution](assets/tech_solution.png) - -ps: 我们在北京DoraHacks大赛实现了链下代理重加密/联邦学习和链上存证/权限管理的对接,并完成了医疗数据市场/AI市场的demo,获得了最佳创意项目奖。同时团队的两位同学也分别是身份项目Blockstack和隐私计算项目Enigma在中国区的技术大使。这次微众金融科技大赛会更多侧重于WeIdentity同代理重加密的整合,实现自主身份及其数据的分布式密钥管理,并将整套系统有效适配到借贷场景下,实现贷前身份管理和联合反欺诈。 - -## 功能模块 - -![functions](assets/tech_functions.png) - -## 交互流程 - -1. 注册DID:生成用户、借贷平台、权威机构的DID并注册到FISCO-BCOS链上,设置相关属性; -2. 注册授权机构:把生成好的DID注册成授权机构,信息登记在链上; -3. 注册CPT:生成身份证CPT模版和银行流水CPT模版(claim带DID属性),信息登记在链上; -4. 链下生成凭证:借贷用户向公安局和银行申请身份证凭证和银行流水凭证,附带自己的DID标识符由授权机构签名; -5. 匿名凭证生成:用户可以选择隐藏claim里的部分字段,如姓名,选择性披露并生成新的凭证; -6. 凭证存证上链/密文存储:用户将凭证哈希后存证上链,再用私钥加密凭证存入IPFS,密文索引写入DID服务端口; -7. 用户发起借贷:用户根据借贷平台公钥和自己私钥生成重加密钥匙,并将其同凭证密文索引地址(链上也有)发给平台方; -8. 平台校验身份:平台用重加密钥匙解开凭证内容,验证存证哈希、授权机构的签名和用户claim的DID(链上有signer); -9. 平台反欺诈查询:平台可调用反欺诈接口,将借贷用户标示符加密后发给其他平台,其他平台也对自己本地的标识符集进行加密,隐私保护下(FHE)返回多头借贷详情,即是否有多头借贷行为和具体金额; -10. 行业欺诈库维护:平台可以将虚假恶意的借贷行为上链,维护链上黑名单,记录下DID,并联合授权机构追溯DID对应的现实实体; -11. 联邦数据/AI市场:平台间的联合建模,联邦学习可在数据不出企业下传输计算图和梯度(Syft,我们实现了联邦数据集); -12. 借贷隐私合约:在时间允许下,采用Enigma二层隐私计算网络为借贷企业部署隐私合约,FISCO-BCOS做计算步骤的存证。 - -![functions](assets/functions.jpg) - -## 应用场景 - -如前所述,本项目希望在确保平台数据及用户隐私安全的前提下,通过联盟链、分布式身份、密文云存储、隐私计算和联邦学习等多项技术,将数据主权归还给用户,并通过统一的身份标识符,在数据验证和计算层面实现借贷行业的互联互通,为各平台提供贷前身份认证(防范虚假信息和身份冒用)、反欺诈(反多头借贷、行业黑名单)、可信数据溯源(欺诈实体追溯、催收)、AI风险定价等风控服务。我们认为该方案具有很好的可移植性,各项技术在物联网和医疗行业也具有广阔的应用场景。 - -## 产品设计 - -在该项目中,WeIdentity用以实现分布式身份管理、电子凭证发行和验证,从而引入权威机构来标识借款人的数字身份,并支持凭证信息的选择性披露;代理重加密(Proxy Re-encryption)用以支持分布式密钥管理,联合IPFS构建密文云,实现身份凭证的隐私存储和分享;FISCO BCOS联盟链用以支持凭证数据的存证和授权流通,并维护行业欺诈库。 - -借款人可最小化隐私泄漏,如在保留权威机构签名可验证的情况下,隐藏身份证凭证和银行流水凭证上的姓名字段。通常情况下,用户会尽可能快地将权威机构颁发的凭证存证上链,经由合约检测判断该存证未被预先上链,这样可以确保身份凭证的主权。具体的凭证数据加密后存入存储系统,分享时分发重加密钥匙即可。借贷平台也无需为了防止身份冒用和信息造假而过度采集客户资料,可通过对比借款人提供的身份标识(WeIdentity DID)及身份凭证(WeIdentity Credential,包含权威机构的签名)和链上的凭证哈希及存证的签名方(signer),来快速验证凭证已被权威机构和借贷发起人所签名,该过程可在链下进行。一种比较极端的情况是,恶意分子截取了刚颁发的凭证并提前将其上链,随后就可以仿冒用户身份进行借贷。为了避免这种情况,一种解决方案是在凭证的声明(claim)里增加身份标识字段,由权威机构认证该凭证属于特定的DID,在借贷时要求用户必须揭示该字段。 - -此外,为了准确识别多头借贷行为,共享多方黑名单,需要统一的用户身份标识符,也可以采用以上方案。在欺诈行为发生时,例如逾期多个月,平台可通过DID向权威机构查询,从而追溯到现实的个人主体,并将相关恶意行为上链,形成行业反欺诈库。该项目还将设计反多头借贷查询接口,通过输入具体的身份标识符来查询该用户在多少平台上发生过多少金额的借贷行为。考虑到链上数据透明性所带来的隐私限制,借贷行为往往发生在链下,而不是由合约控制,各借贷平台的数据沉淀行为将无可避免。这种情况下,要建立联盟内借贷平台间的互信,关键在于安全多方计算(MPC),即在各平台不泄漏自己持有信息的同时,又能协同执行某个计算任务。具体地,在不透露各平台的用户凭证集下,计算任务可以定义为:统计某个标示符在所有平台的凭证数据中的出现次数和相应金额,并验证凭证是由权威机构所颁发。MPC的性能在近几年已经得到了显著提升,但当前的工程实践还是围绕安全两方计算(计算时间大约为明文十倍计算水平),多方计算的通信复杂度较大。尽管我们认为对于简单的安全多方统计任务是可以专门设计电路来保证可用的性能,但本次参赛我们先采用了同态加密来走通流程:当借贷平台A输入身份标识符查询时,会先对标识符加密,再分别发送给借贷平台B、C、D等,各平台也会将自己沉淀的凭证数据转为加密形式,二者将在密文形式下进行匹配;这样不会泄漏A待查询的新用户,其他平台的数据也不用出本地计算,缺点在于A查询次数多了后可能会掌握其他平台的统计规律,即用户集,为此也需要制定适当的数据贡献激励。 - -除了身份验证和反欺诈外,借贷平台也需要对用户进行风险定价,从而给出个性化的利率。实际的限制是,单平台所拥有的客户信用数据集的规模往往较小,此时可以通过平台级的联邦学习来训练联合风险定价模型,把模型带到数据侧。最后,随着layer2隐私计算公链的技术发展(例如Enigma结合TEE实现了隐私合约的隐私状态存储),借贷行为和各平台的风控规则也将可以部署为隐私合约,由合约自动给出通过、不通过、升费率、记录恶意名单等等选择。平台的数据沉淀行为将可以避免,真正实现用户DID控制下的身份主权。届时,用户级/边缘级的联邦学习将在构造隐私保护的数据市场上发挥至关重要的作用。 diff --git a/201908-Shenzhen/Bithacks/assets/architecture.png b/201908-Shenzhen/Bithacks/assets/architecture.png deleted file mode 100755 index 7c1599fb7..000000000 Binary files a/201908-Shenzhen/Bithacks/assets/architecture.png and /dev/null differ diff --git a/201908-Shenzhen/Bithacks/assets/functions.jpg b/201908-Shenzhen/Bithacks/assets/functions.jpg deleted file mode 100755 index 1fdbf1884..000000000 Binary files a/201908-Shenzhen/Bithacks/assets/functions.jpg and /dev/null differ diff --git a/201908-Shenzhen/Bithacks/assets/risk_modeling.png b/201908-Shenzhen/Bithacks/assets/risk_modeling.png deleted file mode 100644 index 4edec9057..000000000 Binary files a/201908-Shenzhen/Bithacks/assets/risk_modeling.png and /dev/null differ diff --git a/201908-Shenzhen/Bithacks/assets/tech_functions.png b/201908-Shenzhen/Bithacks/assets/tech_functions.png deleted file mode 100644 index 8510a3022..000000000 Binary files a/201908-Shenzhen/Bithacks/assets/tech_functions.png and /dev/null differ diff --git a/201908-Shenzhen/Bithacks/assets/tech_relation.png b/201908-Shenzhen/Bithacks/assets/tech_relation.png deleted file mode 100755 index 3dca308d7..000000000 Binary files a/201908-Shenzhen/Bithacks/assets/tech_relation.png and /dev/null differ diff --git a/201908-Shenzhen/Bithacks/assets/tech_relation2.png b/201908-Shenzhen/Bithacks/assets/tech_relation2.png deleted file mode 100644 index ae27e4957..000000000 Binary files a/201908-Shenzhen/Bithacks/assets/tech_relation2.png and /dev/null differ diff --git a/201908-Shenzhen/Bithacks/assets/tech_solution.png b/201908-Shenzhen/Bithacks/assets/tech_solution.png deleted file mode 100644 index 9ecc3a7f1..000000000 Binary files a/201908-Shenzhen/Bithacks/assets/tech_solution.png and /dev/null differ diff --git "a/201908-Shenzhen/Bithacks/assets/\345\220\216\347\253\257\346\216\245\345\217\243.png" "b/201908-Shenzhen/Bithacks/assets/\345\220\216\347\253\257\346\216\245\345\217\243.png" deleted file mode 100755 index 310adabbe..000000000 Binary files "a/201908-Shenzhen/Bithacks/assets/\345\220\216\347\253\257\346\216\245\345\217\243.png" and /dev/null differ diff --git a/201908-Shenzhen/RXL/README.md b/201908-Shenzhen/RXL/README.md new file mode 100644 index 000000000..be8a5046d --- /dev/null +++ b/201908-Shenzhen/RXL/README.md @@ -0,0 +1,79 @@ +# 融信链 +微众比赛的融信链项目,通过区块链赋能教育证书和诚信评估 + +### 1.项目背景 + +#### 1.1 社会发展与人才培养 + +​ 改社会发展日新月异革开放以来,我国政治、经济、文化和和社会发展日新月异。随着国家经济发展进入新的阶段,政府机构和社会组织越来越需要大量高质量的人才。 + +#### 1.2 **学历教育** + +​ 我国人才培养体系的基础和核心,因此以学位证书和学历证书为代表的各类文凭和证书在升学及就业中拥有了越来越重要的地位 + +#### 1.3 电子学历证书存在问题 + +- 证书真伪问题 + +证书数据和高校教务数据安全可靠性不可保证,相关部门缺少监管数据来源的通道等 + +- 评价维度问题 + +证书仅是教育部和学校颁发的学历或学位证明,无学生、企业等社会组织的参与,缺乏对学生能力的多维评价等 + +- 实时性问题 + +学历证书审核颁发、跨国学历认证难等场耗时长等 + +#### 1.4 区块链赋能教育 + + “融信链”针对现有的电子学历证书系统存在的不足,用 `Fisco-Bcos`联盟链记录数据,保证学位学历证书数据来源可靠,公平公正记录学生在校学习经历,打开学校与社会各界开放交流的通道,为学生入职升学和企业招聘人才提供便利,提升跨国学历认证事务办理流程,最终提高教育质量,构建更加可信、开放、公平公正和高效的国际教育新生态。 + +#### 1.5 对存在问题的解决思路 + +- [ ] 证书真伪问题:关键数据上链 +- [ ] 参与度问题:参与方共同建设“融信链” +- [ ] 实时性问题:智能合约简化流程 + +### 2. 程序使用和场景描述 + +##### 项目架构图是: + +![](./img/架构.png) + +##### 场景一: + +![场景1](./img/场景1.png) + +![场景1](./img/场景11.png) +##### 场景二: +![场景2](./img/场景2.png) + +##### 项目具体实现: +本项目使用的编程语言有:Java、Go和Solidity + +Java 端的使用,参见 lrxTest 目录下的介绍 + +Go后端的使用,参见 GoRXL 目录下的介绍 + +### 3. 商业价值和展望 + +#### 3.1 社会效益 + +西电教育改革试点,已与bcos达成合作,有校信息化处参与和校改基金支持,预计明年在西电上线,发布链上学历证书; + +促进多维度电子学历证书系统的建设,作为区块链在教育界实际应用的试点,推进国际教育体系改革。 + +#### 3.2 经济效益 + +有偿信息查询:企业批量个性化查询需要支付一定费用; + +微众银行作为联盟生态的一个节点,将“融信链”上沉淀下来的可信数据作为学生信贷、征信的依据。杜绝不良P2P校园贷,助力普惠金融。 + +### 4. 获奖展示 + +本作品用于参加微众银行举办的`首届金融科技高校大赛`,并获得三等奖名次。 + +##### 可以访问一下网站[了解详情](https://mp.weixin.qq.com/s?__biz=MzU5NTg0MjA4MA==&mid=2247485527&idx=1&sn=7f8351596f38fd0d95c50ad321836d89&chksm=fe6a8d18c91d040ececccb84e2d9400c24a5d233cf0f5bfe44b554b9085faa76518717280517&mpshare=1&scene=1&srcid=&sharer_sharetime=1568618790497&sharer_shareid=c8fa107db2039a2eddc7fabdb6a39c6b&key=a00a174091495fb1c8c39b05357aca51d28937f4ee95b6e0a22ed415bc5746256fad1b13c73264c73553c10640c97f3979d363da2e10191f0d4e1a748c2f9d6ea85f3feb5acce1f8725036e8baa1ab9d&ascene=1&uin=OTg2NTk3NTA2&devicetype=Windows+10&version=62060833&lang=zh_CN&pass_ticket=67jRHxzay8kNrF6b5oXOT%2F23BcbQFUEocIovv06kBzc%2FW6XuWGDX6p%2FV2Rdfpshf) + +![获奖作品](./img/获奖作品.png) \ No newline at end of file diff --git a/201908-Shenzhen/RXL/contrcts/CreditCert.sol b/201908-Shenzhen/RXL/contrcts/CreditCert.sol new file mode 100644 index 000000000..33456b047 --- /dev/null +++ b/201908-Shenzhen/RXL/contrcts/CreditCert.sol @@ -0,0 +1,528 @@ +pragma solidity ^0.4.25; + +contract CreditCert { + + //event + + event stuInfoInitEvent ( + uint64 stuID, + string stuName, + string usName, + string major, + string extInfo, + uint64 registerTime + ); + + event stuInfoUpdateEvent ( + uint64 stuID, + string stuName, + string usName, + string major, + string extInfo, + uint64 updateTime + ); + + event stuGradeRecordEvent ( + uint64 stuID, + string stuName, + uint32 grades, + uint32 averageGrade, + string extInfo, + uint64 recordTime + ); + + event stuGradeUpdateEvent ( + uint64 stuID, + string stuName, + uint32 grades, + uint32 averageGrade, + string extInfo, + uint64 updateTime + ); + + event activityRegisterEvent ( + uint32 actID, + string actName, + string sponsor, + string status, + string extInfo, + uint64 registerTime + ); + + event activityInfoUpdateEvent ( + uint32 actID, + string actName, + string sponsor, + string status, + string extInfo, + uint64 updateTime + ); + + event activityGradeRecodeEvent ( + uint32 actID, + uint64 stuID, + string actName, + string stuName, + string extInfo, + uint64 recordTime, + string actSignature + ); + + event certInfoInitEvent ( + uint64 certID, + uint64 stuID, + string stuName, + string usName, + string studyTime, + uint64 initTime + ); + + event certInfoUpdateEvent ( + uint64 certID, + uint64 stuID, + string stuName, + string usName, + string studyTime, + string certStatus, + uint64 updateTime, + string certSignature + ); + + + //学生初始信息 + struct stuInfo{ + uint64 stuID; //学生唯一ID + string stuName; //学生姓名 + string usName; //所在学校名字 + uint32 usLevel; //学校星级 1-3 + string major; //学生专业 + string extInfo; //附加信息 + uint64 time; //操作时间 + uint32 grades; //学生年级 + + mapping (uint32 => gradeInfo) gradeInfoList; //学期成绩列表 + + mapping (uint32 => activityRecord) activityRecordList; //参与活动列表 + } + + //学期成绩信息,,增加必修学分和选修学分两项,用于展示证书信息审核功能 + struct gradeInfo{ + uint64 stuID; //学生唯一ID + string stuName; //学生姓名 + uint32 grades; //学年,一般为1-4 + uint32 averageGrades; //加权平均成绩 + uint32 obligatoryCredit; //必修学分,新增 + uint32 optionalCredit; //选修学分,新增 + string extInfo; //附加信息 + uint64 time; //操作时间 + } + + //活动发布信息 + struct activityInfo{ + uint32 actID; //活动ID + string actName; //活动名称 + string organizer; //举办方 + string status; //活动状态,一般分为未开始、进行中、已结束3种 + string extInfo; //附加信息 + uint64 time; //操作时间 + + } + + //学生活动记录数据结构 + struct activityRecord{ + uint32 actID; //活动ID + uint64 stuID; //学生ID + string actName; //活动名称 + string stuName; //学生姓名 + string extInfo; //附加信息 + uint64 time; //操作时间 + string actSignature; //参与活动信息签名 + } + //学历证书数据结构 + struct certInfo{ + uint64 certID; //证书ID + uint64 stuID; //学生ID + string stuName; //学生姓名 + string usName; //证书颁发学校名称 + string major; //学生专业 + string studyTime; //在校学习时间 + string certStatus; //证书状态 + string extInfo; //附加信息 + uint64 time; //操作时间 + string certSignature; //证书发布签名 + } + + //学生信息列表:ID到学生信息表的映射 + mapping (uint64 => stuInfo) stuInfoList; + //学历证书信息列表:ID到学历证书信息的映射 + mapping (uint64 => certInfo) certInfoList; + //活动信息列表:ID到结构体的映射 + mapping (uint32 => activityInfo) activityInfoList; + + //学生注册信息初始化 + function stuInfoInit ( + uint64 stuID, + string stuName, + string usName, + uint32 usLevel, + string major, + string extInfo, + uint64 registerTime, + uint32 grades + ) + public + returns (uint32) + { + stuInfoList[stuID] = stuInfo(stuID, stuName, usName, usLevel, major, extInfo, registerTime, grades); + emit stuInfoInitEvent(stuID, stuName, usName, major, extInfo, registerTime); + return 1; + } + + //学生信息更新 + function stuInfoUpdate ( + uint64 stuID, + string stuName, + string usName, + uint32 usLevel, + string major, + string extInfo, + uint64 updateTime, + uint32 grades + ) + public + returns (uint32) + { + assert (stuInfoList[stuID].stuID != 0); + stuInfoList[stuID] = stuInfo(stuID, stuName, usName, usLevel, major, extInfo, updateTime, grades); + emit stuInfoUpdateEvent(stuID, stuName, usName, major, extInfo, updateTime); + return 1; + } + + //学生成绩记录,增加必修学分和选修学分两项 + function stuGradeRecord ( + uint64 stuID, + string stuName, + uint32 grades, + uint32 averageGrade, + uint32 obligatoryCredit, //新增 + uint32 optionalCredit, //新增 + string extInfo, + uint64 recordTime + ) + public + returns (uint32) + { + stuInfoList[stuID].gradeInfoList[grades] = gradeInfo(stuID, stuName, grades, averageGrade, obligatoryCredit, optionalCredit, extInfo, recordTime); + emit stuGradeRecordEvent(stuID, stuName, grades, averageGrade, extInfo, recordTime); + return 1; + } + + // 学生成绩更新 + function stuGradeUpdate ( + uint64 stuID, + string stuName, + uint32 grades, + uint32 averageGrade, + uint32 obligatoryCredit, //新增 + uint32 optionalCredit, //新增 + string extInfo, + uint64 updateTime + ) + public + returns (uint32) + { + assert (stuInfoList[stuID].gradeInfoList[grades].stuID != 0); + stuInfoList[stuID].gradeInfoList[grades] = gradeInfo(stuID, stuName, grades, averageGrade, obligatoryCredit, optionalCredit, extInfo, updateTime); + emit stuGradeUpdateEvent(stuID, stuName, grades, averageGrade, extInfo, updateTime); + return 1; + } + + // 活动发布 + function activityRegister ( + uint32 actID, + string actName, + string organizer, + string status, + string extInfo, + uint64 registerTime + ) + public + returns (uint32) + { + activityInfoList[actID] = activityInfo(actID, actName, organizer, status, extInfo, registerTime); + emit activityRegisterEvent(actID, actName, organizer, status, extInfo, registerTime); + return 1; + } + + // 活动信息更新 + function activityInfoUpdate ( + uint32 actID, + string actName, + string organizer, //此处我把sponsor改为了organizer,之前各处也都修改了 + string status, + string extInfo, + uint64 updateTime + ) + public + returns (uint32) + { + assert (activityInfoList[actID].actID != 0); + activityInfoList[actID] = activityInfo(actID, actName, organizer, status, extInfo, updateTime); + emit activityInfoUpdateEvent(actID, actName, organizer, status, extInfo, updateTime); + return 1; + } + + // 活动成绩记录 + function activityGradeRecode ( + uint32 actID, + uint64 stuID, + string actName, + string stuName, + string extInfo, + uint64 recordTime, + string actSignature + ) + public + returns (uint32) + { + assert (stuInfoList[stuID].stuID != 0); + stuInfoList[stuID].activityRecordList[actID] = activityRecord(actID, stuID, actName, stuName, extInfo, recordTime, actSignature); + emit activityGradeRecodeEvent(actID, stuID, actName, stuName, extInfo, recordTime, actSignature); + return 1; + } + + //学生获得学分查询,新增 + function allCreditQuery(uint64 stuID) + public + constant + returns(uint32, uint32, uint32) + { + assert (stuInfoList[stuID].stuID != 0); + uint32 tempOblgCredits; + uint32 tempOptCredits; + uint32 i = 1; + while(stuInfoList[stuID].gradeInfoList[i].stuID != 0) + { + tempOblgCredits += stuInfoList[stuID].gradeInfoList[i].obligatoryCredit; + tempOptCredits += stuInfoList[stuID].gradeInfoList[i].optionalCredit; + i++; + } + uint32 tempSum = tempOblgCredits + tempOptCredits; + return (tempSum, tempOblgCredits, tempOptCredits); + } + + //学分信息审核,新增 + function creditInfoCheck (uint64 stuID) + public + constant + returns(uint32) + { + assert (stuInfoList[stuID].stuID != 0); + uint32 allOblgCredits; + uint32 allOptCredits; + uint32 sum; + (sum, allOblgCredits, allOptCredits) = allCreditQuery(stuID); + if(sum < 150 || allOblgCredits < 90 || allOptCredits < 60) + { + return 0; + } + + return 1; + } + + // 证书信息发布 + function certInfoInit ( + uint64 certID, + uint64 stuID, + string stuName, + string usName, + string major, + string studyTime, + string certStatus, + string extInfo, + uint64 initTime, + string certSignature + ) + public + returns (uint32) + { + certInfoList[certID] = certInfo(certID, stuID, stuName, usName, major, studyTime, certStatus, extInfo, initTime, certSignature); + emit certInfoInitEvent(certID, stuID, stuName, usName, studyTime,initTime); + return 1; + } + + //证书信息更新 + function certInfoUpdate ( + uint64 certID, + uint64 stuID, + string stuName, + string usName, + string major, + string studyTime, + string certStatus, + string extInfo, + uint64 updateTime, + string certSignature + ) + public + returns (uint32) + { + assert (certInfoList[certID].certID != 0); + certInfoList[certID] = certInfo(certID, stuID, stuName, usName, major, studyTime, certStatus, extInfo, updateTime, certSignature); + emit certInfoUpdateEvent(certID, stuID, stuName, usName, studyTime, certStatus, updateTime, certSignature); + return 1; + } + + // 学生信息查询 + function stuInfoQuery (uint64 stuID) + public + constant + returns (uint64, string, string, uint32, string, string, uint64, uint32) + { + assert (stuInfoList[stuID].stuID != 0); + stuInfo tempStuInfo = stuInfoList[stuID]; + return ( + tempStuInfo.stuID, + tempStuInfo.stuName, + tempStuInfo.usName, + tempStuInfo.usLevel, + tempStuInfo.major, + tempStuInfo.extInfo, + tempStuInfo.time, + tempStuInfo.grades); + } + + // 学生成绩查询 + function stuGradeQuery (uint64 stuID, uint32 grades) + public + constant + returns (uint64, string, uint32, uint32, string, uint64) + { + assert (stuInfoList[stuID].gradeInfoList[grades].stuID != 0); + gradeInfo tempGradeInfo = stuInfoList[stuID].gradeInfoList[grades]; + return ( + tempGradeInfo.stuID, + tempGradeInfo.stuName, + tempGradeInfo.grades, + tempGradeInfo.averageGrades, + tempGradeInfo.extInfo, + tempGradeInfo.time); + } + + // 学生活动查询 + function stuActQuery (uint64 stuID, uint32 actID) + public + constant + returns (uint32, uint64, string, string, string, uint64, string) + { + assert (stuInfoList[stuID].activityRecordList[actID].stuID != 0); + activityRecord tempActRecord = stuInfoList[stuID].activityRecordList[actID]; + return ( + tempActRecord.actID, + tempActRecord.stuID, + tempActRecord.actName, + tempActRecord.stuName, + tempActRecord.extInfo, + tempActRecord.time, + tempActRecord.actSignature); + } + + // 学生证书查询 + function stuCertQuery (uint64 certID) + public + constant + returns (uint64, uint64, string, string, string, string, string, string, uint64) + // returns (uint64, uint64, string, string, string, string, string, string, uint64, string) + { + assert (certInfoList[certID].certID != 0); + certInfo tempCertInfo = certInfoList[certID]; + return ( + tempCertInfo.certID, + tempCertInfo.stuID, + tempCertInfo.stuName, + tempCertInfo.usName, + tempCertInfo.major, + tempCertInfo.studyTime, + tempCertInfo.certStatus, + tempCertInfo.extInfo, + tempCertInfo.time + // tempCertInfo.certSignature + ); + } + + // 活动信息查询 + function actInfoQuery (uint32 actID) + public + constant + returns (uint32, string, string, string, string, uint64) + { + assert (activityInfoList[actID].actID != 0); + activityInfo tempActInfo = activityInfoList[actID]; + return ( + tempActInfo.actID, + tempActInfo.actName, + tempActInfo.organizer, + tempActInfo.status, + tempActInfo.extInfo, + tempActInfo.time); + } + + // 学历证书签名查询,新增,用于证书认证 + function certSignatureQuery(uint64 certID) + public + constant + returns(string, string) + { + assert (certInfoList[certID].certID != 0); + return (certInfoList[certID].certSignature, certInfoList[certID].extInfo); + } + + //总平均成绩查询 + function averageGradeQuery(uint64 stuID) public returns(uint32){ + uint32 averageGrade = 0; + uint32 sumGrade = 0; + for(uint32 i = stuInfoList[stuID].grades; i > 0; i--){ + sumGrade = sumGrade + stuInfoList[stuID].gradeInfoList[i].averageGrades; + } + averageGrade = sumGrade/stuInfoList[stuID].grades; + return averageGrade; + } + + //信用评估 + function creditEvaluation(uint64 stuID) public constant returns(uint32, uint32, uint32, uint32){ + assert (stuInfoList[stuID].stuID != 0); + uint32 score = getM1(stuID) + getM2(stuID) + getM3(stuID); + return ( + getM1(stuID), //学校等级得分 + getM2(stuID), //平均成绩得分 + getM3(stuID), //年级得分 + score //总信用评分 + ); + } + + //学校等级得分 + function getM1(uint64 stuID) public returns(uint32){ + uint32 usLevel = stuInfoList[stuID].usLevel; + if(usLevel == 3) + return 70; + else if(usLevel == 2) + return 80; + else if(usLevel == 1) + return 90; + else + return 60; + } + //平均成绩得分 + function getM2(uint64 stuID) public returns(uint32){ + uint32 averageGrade = averageGradeQuery(stuID); + return averageGrade; + } + //年级得分 + function getM3(uint64 stuID) public returns(uint32){ + uint32 grades= stuInfoList[stuID].grades; + uint32 M3 = grades * 10 + 50; + return M3; + } + +} + diff --git "a/201908-Shenzhen/RXL/contrcts/\345\220\210\347\272\246Word\347\211\210.docx" "b/201908-Shenzhen/RXL/contrcts/\345\220\210\347\272\246Word\347\211\210.docx" new file mode 100644 index 000000000..5e9ce282b Binary files /dev/null and "b/201908-Shenzhen/RXL/contrcts/\345\220\210\347\272\246Word\347\211\210.docx" differ diff --git "a/201908-Shenzhen/RXL/contrcts/\345\255\246\345\216\206\350\257\201\344\271\246\345\214\272\345\235\227\351\223\276\347\263\273\347\273\237\346\216\245\345\217\243\346\226\207\346\241\243.docx" "b/201908-Shenzhen/RXL/contrcts/\345\255\246\345\216\206\350\257\201\344\271\246\345\214\272\345\235\227\351\223\276\347\263\273\347\273\237\346\216\245\345\217\243\346\226\207\346\241\243.docx" new file mode 100644 index 000000000..1408efb0a Binary files /dev/null and "b/201908-Shenzhen/RXL/contrcts/\345\255\246\345\216\206\350\257\201\344\271\246\345\214\272\345\235\227\351\223\276\347\263\273\347\273\237\346\216\245\345\217\243\346\226\207\346\241\243.docx" differ diff --git a/201908-Shenzhen/RXL/img/README.md b/201908-Shenzhen/RXL/img/README.md new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/201908-Shenzhen/RXL/img/README.md @@ -0,0 +1 @@ + diff --git "a/201908-Shenzhen/RXL/img/\345\234\272\346\231\2571.png" "b/201908-Shenzhen/RXL/img/\345\234\272\346\231\2571.png" new file mode 100644 index 000000000..e49ecc154 Binary files /dev/null and "b/201908-Shenzhen/RXL/img/\345\234\272\346\231\2571.png" differ diff --git "a/201908-Shenzhen/RXL/img/\345\234\272\346\231\25711.png" "b/201908-Shenzhen/RXL/img/\345\234\272\346\231\25711.png" new file mode 100644 index 000000000..015882a16 Binary files /dev/null and "b/201908-Shenzhen/RXL/img/\345\234\272\346\231\25711.png" differ diff --git "a/201908-Shenzhen/RXL/img/\345\234\272\346\231\2572.png" "b/201908-Shenzhen/RXL/img/\345\234\272\346\231\2572.png" new file mode 100644 index 000000000..fcfd567af Binary files /dev/null and "b/201908-Shenzhen/RXL/img/\345\234\272\346\231\2572.png" differ diff --git "a/201908-Shenzhen/RXL/img/\346\236\266\346\236\204.png" "b/201908-Shenzhen/RXL/img/\346\236\266\346\236\204.png" new file mode 100644 index 000000000..14f29b2ea Binary files /dev/null and "b/201908-Shenzhen/RXL/img/\346\236\266\346\236\204.png" differ diff --git "a/201908-Shenzhen/RXL/img/\350\216\267\345\245\226\344\275\234\345\223\201.png" "b/201908-Shenzhen/RXL/img/\350\216\267\345\245\226\344\275\234\345\223\201.png" new file mode 100644 index 000000000..224bfdf54 Binary files /dev/null and "b/201908-Shenzhen/RXL/img/\350\216\267\345\245\226\344\275\234\345\223\201.png" differ diff --git a/201908-Shenzhen/SCNUTank/README.md b/201908-Shenzhen/SCNUTank/README.md deleted file mode 100644 index 9da2d9c25..000000000 --- a/201908-Shenzhen/SCNUTank/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# 紫荆路Tank团:排污权许可区块链交易平台 - -# 作品简介 - -本作品旨在通过区块链构建排污权许可证交易平台,配合交易纠纷仲裁,黑名单,监督审计等链上机制健全活化市场。实现企业、政府、公众对于环保排污的三权制衡、多元共治,辅助排污政策制定,共建污水治理生态循环。 - -# 方案介绍 - -## 方案架构 - -![](./img/1-1.png) - -## 技术架构 - -![](./img/3.png) - -## 排污交易流程 - -![](./img/2.png) diff --git a/201908-Shenzhen/SCNUTank/contracts/AuctionSewage.sol b/201908-Shenzhen/SCNUTank/contracts/AuctionSewage.sol deleted file mode 100644 index b453d97b7..000000000 --- a/201908-Shenzhen/SCNUTank/contracts/AuctionSewage.sol +++ /dev/null @@ -1,63 +0,0 @@ -import "./TokenSewage.sol"; -pragma solidity ^0.4.25; - -contract AuctionSewage{ - TokenSewage tokenSewage; - uint256 public ident; - address public owner; - uint256 public auction_token; - uint public auction_end; - address public highestBidder; - uint256 public highestBid; - bool ended; - uint256 public deadline; - uint256 public bank_serials_number; - - event HighestBidIncreased(address bidder, uint amount); - event AuctionEnded(address winner, uint amount); - - constructor() public{ - owner = msg.sender; - } - - function start_auction(uint256 _auction_token, uint _biddingTime) public { - require(msg.sender == owner); - require(tokenSewage.transferFrom(owner, this, _auction_token)); - auction_token = _auction_token; - auction_end = now + _biddingTime; - } - - function bid(uint256 value) public{ - require(now <= auction_end, "Auction already ended."); - require(value > highestBid, "There already is a higher bid."); - - highestBidder = msg.sender; - highestBid = value; - emit HighestBidIncreased(msg.sender, value); - } - - - function auctionEnd() public { - require(now >= auction_end, "Auction not yet ended."); - require(!ended, "auctionEnd has already been called."); - ended = true; - deadline = now + 7 days; - emit AuctionEnded(highestBidder, highestBid); - } - - function pay(uint256 _bank_serials_number) public { - require(msg.sender == highestBidder && ended); - require(now < deadline); - require(_bank_serials_number > 0); - bank_serials_number = _bank_serials_number; - require(tokenSewage.transferTo(highestBidder, auction_token)); - } - - function refund() public { - require(msg.sender == owner); - require(highestBid == 0); - uint256 amount = tokenSewage.balanceOf(this); - require(amount > 0); - require(tokenSewage.transferTo(msg.sender, amount)); - } -} \ No newline at end of file diff --git a/201908-Shenzhen/SCNUTank/contracts/B2CSewage.sol b/201908-Shenzhen/SCNUTank/contracts/B2CSewage.sol deleted file mode 100644 index 337b6b56c..000000000 --- a/201908-Shenzhen/SCNUTank/contracts/B2CSewage.sol +++ /dev/null @@ -1,79 +0,0 @@ -import "./TokenSewage.sol"; -pragma solidity ^0.4.25; - -contract B2CSewage{ - - struct Buyer_Info{ - uint256 sewage_token; - uint256 bank_serials_number; - uint256 deadline; - bool flag; - } - - TokenSewage tokenSewage; - address public owner; - mapping(address => mapping(uint256 => Buyer_Info)) public buyers; - uint256 public sewage_token; - uint256 public unit_price; - uint256 public remaining_sewage_token; - uint256 state; - event Transaction_msg(uint256 indexed t); - - constructor(address _tokenSewage) public { - owner = msg.sender; - tokenSewage = TokenSewage(_tokenSewage); - } - - function sell(uint256 _sewage_token) public{ - require(msg.sender == owner); - require(tokenSewage.transferFrom(msg.sender, this, _sewage_token)); - sewage_token = _sewage_token; - remaining_sewage_token = _sewage_token; - state = 1; - emit Transaction_msg(0); - } - - function purchase_phase1(uint256 ledger_id, uint256 _sewage_token) public{ - require(state == 1); - require(remaining_sewage_token > 0); - require(remaining_sewage_token >= _sewage_token); - remaining_sewage_token -= _sewage_token; - buyers[msg.sender][ledger_id] = Buyer_Info(_sewage_token, 0, now + 7 days, false); - emit Transaction_msg(0); - } - - function purchase_phase2(uint256 ledger_id, uint256 _bank_serials_number) public{ - require(state == 1); - require(buyers[msg.sender][ledger_id].deadline >= now && _bank_serials_number > 0); - buyers[msg.sender][ledger_id].bank_serials_number = _bank_serials_number; - require(tokenSewage.transferTo(msg.sender, buyers[msg.sender][ledger_id].sewage_token)); - emit Transaction_msg(0); - } - - function interrupt_order(uint256 ledger_id) public{ - require(buyers[msg.sender][ledger_id].deadline >= now); - remaining_sewage_token += buyers[msg.sender][ledger_id].sewage_token; - buyers[msg.sender][ledger_id].flag = true; - emit Transaction_msg(0); - } - - function interrupt_deadline(address _buyer,uint256 ledger_id) public returns(bool){ - require(state == 1); - require(msg.sender == owner); - if(buyers[_buyer][ledger_id].deadline < now){ - remaining_sewage_token += buyers[_buyer][ledger_id].sewage_token; - return true; - } - else{ - return false; - } - } - - function interrupt_sell() public{ - require(msg.sender == owner); - uint256 amount = tokenSewage.balanceOf(this); - require(tokenSewage.transferTo(msg.sender, amount)); - state = 2; - emit Transaction_msg(0); - } -} \ No newline at end of file diff --git a/201908-Shenzhen/SCNUTank/contracts/Blacklist.sol b/201908-Shenzhen/SCNUTank/contracts/Blacklist.sol deleted file mode 100644 index 90df6f5be..000000000 --- a/201908-Shenzhen/SCNUTank/contracts/Blacklist.sol +++ /dev/null @@ -1,118 +0,0 @@ -pragma solidity ^0.4.25; -pragma experimental ABIEncoderV2; - - -contract Blacklist { - address admin; - struct info{ - string enterpriseId; - string enterpriseName; - string illegalNum; - string illegalRatio; - string totalBalance; - // uint length; - string isDeleted; - // detail[] details; - - } - - // struct detail{ - // address orderAddress; - // int128 value; - // string time; - // string reason; - // } - - mapping(address=>info) public illegalEnterprises; - - - function Blacklist(){ - admin = msg.sender; - } - - function add(address _enterprise, - string _enterpriseName, - string _enterpriseId, - string _illegalNum, - string _illegalRatio, - string _totalBalance) public returns(bool success){ - // require(msg.sender == admin); - illegalEnterprises[_enterprise].enterpriseId = _enterpriseId; - illegalEnterprises[_enterprise].enterpriseName = _enterpriseName; - illegalEnterprises[_enterprise].illegalNum = _illegalNum; - illegalEnterprises[_enterprise].illegalRatio = _illegalRatio; - illegalEnterprises[_enterprise].totalBalance = _totalBalance; - // illegalEnterprises[_enterprise].length = _length; - illegalEnterprises[_enterprise].isDeleted = "0"; - - // detail info; - // info.orderAddress = _orderAddress; - // info.value = _value; - // info.time = _time; - // info.reason = _reason; - // uint length = illegalEnterprises[_enterprise].length; - // illegalEnterprises[_enterprise].details[length] = info; - // illegalEnterprises[_enterprise].length += 1; - return true; - } - - - - function query(address _enterprise) public view returns(string _info){ - // _info = illegalEnterprises[_enterprise]; - string memory _enterpriseId = illegalEnterprises[_enterprise].enterpriseId; - string memory _enterpriseName = illegalEnterprises[_enterprise].enterpriseName; - string memory _illegalNum = illegalEnterprises[_enterprise].illegalNum; - string memory _illegalRatio = illegalEnterprises[_enterprise].illegalRatio; - string memory _totalBalance = illegalEnterprises[_enterprise].totalBalance; - string isDeleted = illegalEnterprises[_enterprise].isDeleted; - // string aa = "test" + "ee" - // string memory infoConcat = strConcat("123", "456"); - string memory temp = strConcat(_enterpriseId, "#", _enterpriseName, "#"); - string memory temp1 = strConcat(temp, _illegalNum, "#",""); - string memory temp2 = strConcat(temp1, _illegalRatio, "#",""); - string memory temp3 = strConcat(temp2, _totalBalance, "#",""); - string memory temp4 = strConcat(temp3, "0","",""); - - // - return temp4; - // uint _length = illegalEnterprises[_enterprise].length; - // return info(_enterpriseId, , _illegalNum, _illegalRatio, _totalBalance, false); - } - function strConcat(string _a, string _b, string _c, string _d) internal returns (string){ - bytes memory _ba = bytes(_a); - bytes memory _bb = bytes(_b); - bytes memory _bc = bytes(_c); - bytes memory _bd = bytes(_d); - string memory ret = new string(_ba.length + _bb.length + _bc.length + _bd.length); - bytes memory bret = bytes(ret); - uint k = 0; - for (uint i = 0; i < _ba.length; i++)bret[k++] = _ba[i]; - for (i = 0; i < _bb.length; i++) bret[k++] = _bb[i]; - for (i = 0; i < _bc.length; i++) bret[k++] = _bc[i]; - for (i = 0; i < _bd.length; i++) bret[k++] = _bd[i]; - return string(ret); - } - - - - // function update(address _enterprise, - // string _enterpriseName, - // uint256 _enterpriseId, - // uint128 _value, - // string _time, - // string _reason) public returns(bool success){ - // require(msg.sender == admin); - // illegalEnterprises[_enterprise].enterpriseName = _enterpriseName; - // illegalEnterprises[_enterprise].enterpriseId = _enterpriseId; - // illegalEnterprises[_enterprise].enterpriseName = _enterpriseName; - // illegalEnterprises[_enterprise].enterpriseName = _enterpriseName; - // illegalEnterprises[_enterprise].enterpriseName = _enterpriseName; - // } - - function remove(address _entAddress) public returns(bool success){ - require(msg.sender == admin); - illegalEnterprises[_entAddress].isDeleted = "1"; - return true; - } -} \ No newline at end of file diff --git a/201908-Shenzhen/SCNUTank/contracts/EnterpriseManager.sol b/201908-Shenzhen/SCNUTank/contracts/EnterpriseManager.sol deleted file mode 100644 index 861a34d55..000000000 --- a/201908-Shenzhen/SCNUTank/contracts/EnterpriseManager.sol +++ /dev/null @@ -1,113 +0,0 @@ -pragma solidity ^0.4.25; - -contract EnterpriseManager { - - struct Enterprise { - address enterpriseAddress; // enterprise address in the blockchain - string name; // enterprise name - string realid; // enterprise identity in the real world - uint index; // enterprise index - bool isdeleted; // flag for deleted - } - - mapping(address => Enterprise) public enterprises; - address[] public enterpriseAddresses; - - // enterprise is exited or not - function IsExitAddress(address _enterAddress) - public - constant - returns(bool isExited) - { - if(enterpriseAddresses.length == 0) return false; - return (enterpriseAddresses[enterprises[_enterAddress].index] == _enterAddress); - } - - // add a new enterprise - function AddEnterprise( - address _entAddress, - string _name, - string _realid) - public - returns(uint index) - { - require(IsExitAddress(_entAddress) == true, "Enterprise is not exited"); - enterpriseAddresses.push(_entAddress); - enterprises[_entAddress].enterpriseAddress = _entAddress; - enterprises[_entAddress].name = _name; - enterprises[_entAddress].realid = _realid; - enterprises[_entAddress].index = enterpriseAddresses.length-1; - enterprises[_entAddress].isdeleted = false; - return enterpriseAddresses.length-1; - } - - // update an enterprise - function UpdateEnterprise(address _entAddress, string key, string value) - public - returns(bool success) - { - require(IsExitAddress(_entAddress) == true, "Enterprise is not exited"); - if(keccak256(abi.encodePacked(key)) == keccak256(abi.encodePacked("name"))) { - enterprises[_entAddress].name = value; - return true; - } - if(keccak256(abi.encodePacked(key)) == keccak256(abi.encodePacked("realid"))) { - enterprises[_entAddress].realid = value; - return true; - } - return false; - } - - // delete an enterprise - function DeleteEnterprise(address _entAddress) public returns (bool isSuccess) { - if(!IsExitAddress(_entAddress)) return false; - enterprises[_entAddress].isdeleted = true; - return true; - } - - // find an enterprise by address - function GetEnterprise(address _entAddress) - public - constant - returns(string name, string realid, uint index) - { - require(IsExitAddress(_entAddress) == true, "Enterprise is not exited"); - return( - enterprises[_entAddress].name, - enterprises[_entAddress].realid, - enterprises[_entAddress].index); - } - - // find an enterprise by index - function GetEnterpriseByIndex(uint index) - public - constant - returns(address entAddress, string name, string realid) - { - require(index < 0 || index >= enterpriseAddresses.length, "index is out of range"); - return( - enterpriseAddresses[index], - enterprises[enterpriseAddresses[index]].name, - enterprises[enterpriseAddresses[index]].realid); - } - - // returns the count of the enterpises - function GetEnterpriseCount() - public - constant - returns(uint count) - { - return enterpriseAddresses.length; - } - - // check an enterprise had been deleted or not - function IsDeleted(address _entAddress) - public - constant - returns(bool isDeleted) - { - require(IsExitAddress(_entAddress) == true, "Enterprise is not exited"); - return enterprises[_entAddress].isdeleted; - } - -} diff --git a/201908-Shenzhen/SCNUTank/contracts/P2PSewage.sol b/201908-Shenzhen/SCNUTank/contracts/P2PSewage.sol deleted file mode 100644 index 96246f40a..000000000 --- a/201908-Shenzhen/SCNUTank/contracts/P2PSewage.sol +++ /dev/null @@ -1,53 +0,0 @@ -import "./TokenSewage.sol"; - -pragma solidity ^0.4.20; - -contract P2PSewage{ - TokenSewage tokenSewage; - uint256 ident; - uint public deadline; - address public owner; - address public buyer; - uint256 public sewage_token; - uint256 public price; - uint256 public bank_serials_number; - uint256 state; - event Transaction_msg(uint256 indexed t); - - constructor(address _tokenSewage, uint256 _ident, uint256 _value) public { - owner = msg.sender; - tokenSewage = TokenSewage(_tokenSewage); - price = _value; - deadline = now + 7 days; - ident = _ident; - } - - function sell(address _buyer, uint256 _sewage_token) public{ - require(msg.sender == owner); - require(tokenSewage.transferFrom(msg.sender, this, _sewage_token)); - require(state == 0); - buyer = _buyer; - sewage_token = _sewage_token; - state += 1; - emit Transaction_msg(0); // send the msg to web3 if the function run to this point, which mean the function execute successfully - } - - function purchase(uint256 _bank_serials_number) public{ - require(msg.sender == buyer); - require(state == 1 || state == 2); - require(bank_serials_number != 0); - require(deadline < now); - bank_serials_number = _bank_serials_number; - require(tokenSewage.transferTo(msg.sender, sewage_token)); - state = 2; - emit Transaction_msg(1); - } - - function interrupt_sell() public{ - require(msg.sender == owner); - require(state == 1); - require(tokenSewage.transferTo(owner, sewage_token)); - state = 3; - } - -} diff --git a/201908-Shenzhen/SCNUTank/contracts/TokenSewage.sol b/201908-Shenzhen/SCNUTank/contracts/TokenSewage.sol deleted file mode 100644 index c430ec5c7..000000000 --- a/201908-Shenzhen/SCNUTank/contracts/TokenSewage.sol +++ /dev/null @@ -1,92 +0,0 @@ -pragma solidity ^0.4.25; - -interface tokenRecipient{function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public;} -contract TokenSewage { - - string public name;//token name - string public symbol; //token symbol - uint8 public decimals = 2; // the smallest token unit - uint256 public totalSupply; // total supply totkens - address admin; //admin address, can't be modified externally - - mapping(address => uint256) public balanceOf; // storage the balance of all accounts - mapping(address => mapping(address => uint256)) public allowance; // - - event Transfer(address indexed from, address indexed to, uint256 value); - event Burn(address indexed from, uint256 value); - - modifier onlyAdmin(){ - require(msg.sender == admin); - _; - } - //construct function - constructor(uint256 initialSupply, string tokenName, string tokenSymbol) public { -// require(admin == msg.sender); - totalSupply = initialSupply * 10 ** uint256(decimals); - balanceOf[msg.sender] = totalSupply; - name = tokenName; - symbol = tokenSymbol; - - } - // token transfer internal function - function _transfer(address _from, address _to, uint256 _value) internal{ - require(_to != 0x0); // address can't be null - require(balanceOf[_from] >= _value); - require(balanceOf[_to] + _value > balanceOf[_to]); - - uint previousBalances = balanceOf[_from] + balanceOf[_to]; - balanceOf[_from] -= _value; - balanceOf[_to] += _value; - emit Transfer(_from, _to, _value); - - assert(balanceOf[_from] + balanceOf[_to] == previousBalances); - - } - // token transfer function, call its internal function - function transferTo(address _to, uint256 _value) public returns(bool success) { - require(_to != 0x0); - _transfer(msg.sender, _to, _value); - return true; - } - - function transferFrom(address _from, address _to, uint256 _value) public returns(bool success){ - require(_value <= allowance[_from][msg.sender]); - allowance[_from][msg.sender] -= _value; - _transfer(_from, _to, _value); - return true; - } - - function approve(address _spender, uint256 _value) public returns (bool success){ - allowance[msg.sender][_spender] = _value; - return true; - } - - function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success){ - tokenRecipient spender = tokenRecipient(_spender); - if(approve(_spender, _value)){ - // inform contract - spender.receiveApproval(msg.sender, _value, this, _extraData); - return true; - } - } - - - function burn(uint256 _value) public returns (bool success) { - require(balanceOf[msg.sender] >= _value); - balanceOf[msg.sender] -= _value; - totalSupply -= _value; - emit Burn(msg.sender, _value); - return true; - - } - - function burnFrom(address _from, uint256 _value) public returns (bool success){ - require(balanceOf[msg.sender] >= _value); - require(_value <= allowance[_from][msg.sender]); - balanceOf[_from] -= _value; - allowance[_from][msg.sender] -= _value; - totalSupply -= _value; - emit Burn(_from, _value); - return true; - } -} diff --git a/201908-Shenzhen/SCNUTank/img/1-1.png b/201908-Shenzhen/SCNUTank/img/1-1.png deleted file mode 100644 index d5509e02a..000000000 Binary files a/201908-Shenzhen/SCNUTank/img/1-1.png and /dev/null differ diff --git a/201908-Shenzhen/SCNUTank/img/2.png b/201908-Shenzhen/SCNUTank/img/2.png deleted file mode 100644 index 1ee4d2837..000000000 Binary files a/201908-Shenzhen/SCNUTank/img/2.png and /dev/null differ diff --git a/201908-Shenzhen/SCNUTank/img/3.png b/201908-Shenzhen/SCNUTank/img/3.png deleted file mode 100644 index dbd5ffbef..000000000 Binary files a/201908-Shenzhen/SCNUTank/img/3.png and /dev/null differ