当前位置: 首页 > news >正文

培训机构前端班课沈阳seo网站推广

培训机构前端班课,沈阳seo网站推广,建设网站网页打不开,网站维护提示代码前提 Ownable:监管者合约,有一个函数能转让监管者。 SupplyChainFin:供应链金融合约,银行、公司信息上链,公司和银行之间的转账。 发票:记录者交易双方和交易金额等的一种记录数据。如:我在超市买了一瓶水,超市给我开了一张发票。 Ownable // SPDX-…

前提

Ownable:监管者合约,有一个函数能转让监管者。

SupplyChainFin:供应链金融合约,银行、公司信息上链,公司和银行之间的转账。

发票:记录者交易双方和交易金额等的一种记录数据。如:我在超市买了一瓶水,超市给我开了一张发票。

Ownable

// SPDX-License-Identifier: MIT
pragma solidity >=0.4 <=0.9;/*
*@title Ownable
*@dev 
*/
contract Ownable{address public owner; // 监管者event OwnershipTransferred( // 监管者转让结构体address indexed priviousOwner, // indexed表名可以被索引address indexed newOwner);constructor() {owner = msg.sender;}// 判断用户是否是监管者modifier onlyOwner(){require(msg.sender == owner,"You cannot owner!");_;}// 转让所有权,必须是原先监管者转让function transferOwnership(address newOwner) public   onlyOwner{require(newOwner != owner && newOwner != address(0),"newOwner cannot be empty and equal to the priviousOwner");emit OwnershipTransferred(owner, newOwner);owner = newOwner;}}

SupplyChainFin

// SPDX-License-Identifier: MIT
pragma solidity >=0.4 <=0.9;
import "./Ownable.sol";/**
*@title SuppluChainFin
*@dev
*/
contract SupplyChainFin is Ownable{// 监管者信息结构体struct Supervisor{string supervisorName; address supervisorAddress;}// 公司信息结构体struct Company{string companyName;address companyAddress;uint creditAsset;uint[] acceptReceiptIndex;uint[] sendReceiptIndex;}// 银行信息结构体struct Bank{string bankName;address bankAddress;uint creditAsset;uint[] acceptReceiptIndex;uint[] sendReceiptIndex;}// 数字发票收据信息struct Receipt {address senderAddress; address accepterAddress;uint8 receiptType; // 发票类型uint8 transferType; // 转账类型uint amount; // 交易额}// 公司的map ,用于快速搜索mapping(address => Company) companyMap;// 银行mapmapping (address =>Bank) bankMap;// 发票的mapmapping (uint => Receipt) receiptMap;//监管者实体Supervisor public supervisor;// 公司地址的数组address[] public companies;// 银行地址的数组address[] public banks;//数组发票索引uint public receiptIndex;constructor(string memory name){supervisor = Supervisor(name,msg.sender); // 初始化监管者信息}// 将公司信息添加到智能合约中function addCompany(string memory name,address companyAddress)public payable  returns(bool){// 初始化公司结构体// 添加到公司map// 添加到公司数组Company memory newCompany = Company(name,companyAddress,msg.value,new uint[](0),new uint[](0));companyMap[companyAddress] = newCompany;companies.push(companyAddress);return true;}// 获取公司信息function getCompany(address companyAddress) public view  returns(string memory,address,uint,uint[] memory,uint[] memory){// 用地址拿出公司结构体// 将需要的数据一起返回Company memory company = companyMap[companyAddress];return (company.companyName,company.companyAddress,company.creditAsset,company.acceptReceiptIndex,company.sendReceiptIndex);}// 添加银行信息上链function addBank(string memory bankName,address bankAddress) public payable  returns(bool){Bank memory newBank;newBank.bankName = bankName;newBank.bankAddress = bankAddress;newBank.creditAsset = msg.value;bankMap[bankAddress] = newBank;banks.push(bankAddress);return true;}// 获取银行信息function getBank(address bankAddress) public view  returns(string memory,address,uint,uint[] memory,uint[] memory){Bank memory bank = bankMap[bankAddress];return (bank.bankName,bank.bankAddress,bank.creditAsset,bank.acceptReceiptIndex,bank.sendReceiptIndex);}// 获取公司全部地址function getAllCompanyAddress() public view returns(address[] memory){return companies;}// 获取银行全部地址function getAllBankAddress() public view returns(address[] memory){return banks;}// 获取凭证function getRecipt(uint index)public view returns(address,address,uint8,uint8,uint){Receipt memory receipt = receiptMap[index];return (receipt.senderAddress,receipt.accepterAddress,receipt.receiptType,receipt.transferType,receipt.amount);}//存证交易// receiptType: 发票类型(存证、现金)//1: 交易类型为存证//2:交易类型为现金// transferType: 交易类型//1: 银行转账给公司//2: 公司与公司间转账//3: 公司转账给银行// 银行向公司交易(公司颁布凭证):function bankToCompanyReceipt(address senderAddress, // 凭证发送方address accepterAddress, // 凭证接受方uint amount, // 交易额uint8 receiptType // 凭证类型) public returns(uint){// 银行转账给公司,银行是发票接受者,只有银行同意要发票,这笔交易才能执行require(msg.sender == accepterAddress,"The function caller must be accper");// 拿出银行、公司结构体Company memory company = companyMap[senderAddress];Bank memory bank = bankMap[accepterAddress];// 判断公司银行是否存在if(keccak256(bytes(bank.bankName)) == keccak256(bytes(""))){return 404001;}if(keccak256(bytes(company.companyName)) == keccak256(bytes(""))){return 404002;}// 判断银行资产是否小于转账额if(bank.creditAsset < amount){return 500001;}// 初始化凭证Receipt memory newReceipt = Receipt(senderAddress,accepterAddress,receiptType,1,amount);// 发票索引 + 1receiptIndex += 1;// 根据转账额,相互的 +-companyMap[accepterAddress].creditAsset += amount;bankMap[senderAddress].creditAsset -= amount;// 存凭证索引,这样我们拿到公司或银行信息,拿到发票索引,在拿到发票结构体receiptMap[receiptIndex] = newReceipt;companyMap[accepterAddress].sendReceiptIndex.push(receiptIndex);bankMap[senderAddress].acceptReceiptIndex.push(receiptIndex);return 200;}//公司向公司交易(接受钱的公司需要颁布凭证)function companyToCompanyReceipt(address senderAddress,address accepterAddress,uint amount,uint8 receiptType) public  returns(uint){require(msg.sender == accepterAddress);Company memory senderCompany = companyMap[senderAddress];Company memory accepterCompany = companyMap[accepterAddress];if (keccak256(bytes(senderCompany.companyName)) == keccak256(bytes(""))) {return 404001;}//确认接收公司存在if (keccak256(bytes(accepterCompany.companyName)) == keccak256(bytes(""))) {return 404002;}//如果存证接收的公司资产小于存证数额,那么就不能交易发送存证if (accepterCompany.creditAsset < amount) {return 500001;}//创建存证Receipt memory newReceipt = Receipt(senderAddress,accepterAddress,receiptType,2,amount);receiptIndex += 1;//记录存证(存证Map,公司Map对应地址的发送和接收存证列表)receiptMap[receiptIndex] = newReceipt;companyMap[senderAddress].sendReceiptIndex.push(receiptIndex);companyMap[accepterAddress].acceptReceiptIndex.push(receiptIndex);companyMap[senderAddress].creditAsset += amount;companyMap[accepterAddress].creditAsset -= amount;return 200;}//公司与银行交易(银行颁布凭证)function companyToBankReceipt(address senderAddress,address accepterAddress,uint amount,uint8 receiptType) public  returns (uint) {require(msg.sender == accepterAddress);Bank memory bank = bankMap[senderAddress];Company memory accepterCompany = companyMap[accepterAddress];//确认发送公司存在if (keccak256(bytes(bank.bankName)) == keccak256(bytes(""))) {return 404001;}//确认接收公司存在if (keccak256(bytes(accepterCompany.companyName)) == keccak256(bytes(""))) {return 404002;}   //如果存证接收的公司资产小于存证数额,那么就不能交易发送存证if (accepterCompany.creditAsset < amount) {return 500001;}//创建存证Receipt memory newReceipt = Receipt(senderAddress,accepterAddress,receiptType,3,amount);receiptIndex += 1;//记录存证(存证Map,公司Map对应地址的发送和接收存证列表)receiptMap[receiptIndex] = newReceipt;bankMap[senderAddress].sendReceiptIndex.push(receiptIndex);companyMap[accepterAddress].acceptReceiptIndex.push(receiptIndex);bankMap[senderAddress].creditAsset += amount;companyMap[accepterAddress].creditAsset -= amount;return 200;}}


文章转载自:
http://ricketic.Lnnc.cn
http://depletion.Lnnc.cn
http://journalize.Lnnc.cn
http://searcher.Lnnc.cn
http://seismonasty.Lnnc.cn
http://spearmint.Lnnc.cn
http://heeled.Lnnc.cn
http://nomenclature.Lnnc.cn
http://furor.Lnnc.cn
http://moue.Lnnc.cn
http://alphonso.Lnnc.cn
http://preindustrial.Lnnc.cn
http://hincty.Lnnc.cn
http://wildflower.Lnnc.cn
http://chrismation.Lnnc.cn
http://baignoire.Lnnc.cn
http://testator.Lnnc.cn
http://sexist.Lnnc.cn
http://berserker.Lnnc.cn
http://overhaste.Lnnc.cn
http://compend.Lnnc.cn
http://heath.Lnnc.cn
http://cassini.Lnnc.cn
http://wirespun.Lnnc.cn
http://craftily.Lnnc.cn
http://convergescence.Lnnc.cn
http://baculine.Lnnc.cn
http://franc.Lnnc.cn
http://bifilar.Lnnc.cn
http://dichotic.Lnnc.cn
http://honeycomb.Lnnc.cn
http://ethidium.Lnnc.cn
http://allamanda.Lnnc.cn
http://gentle.Lnnc.cn
http://hopping.Lnnc.cn
http://modificative.Lnnc.cn
http://cultivar.Lnnc.cn
http://soleprint.Lnnc.cn
http://emblemize.Lnnc.cn
http://glycoprotein.Lnnc.cn
http://villatic.Lnnc.cn
http://curvy.Lnnc.cn
http://godling.Lnnc.cn
http://tutelar.Lnnc.cn
http://triethylamine.Lnnc.cn
http://shakta.Lnnc.cn
http://termitic.Lnnc.cn
http://durbar.Lnnc.cn
http://lustral.Lnnc.cn
http://lappa.Lnnc.cn
http://db.Lnnc.cn
http://hypoxemia.Lnnc.cn
http://savor.Lnnc.cn
http://efflorescent.Lnnc.cn
http://vaporizer.Lnnc.cn
http://sept.Lnnc.cn
http://gairish.Lnnc.cn
http://molet.Lnnc.cn
http://cirrhosis.Lnnc.cn
http://succubi.Lnnc.cn
http://tromso.Lnnc.cn
http://demonstrative.Lnnc.cn
http://trappings.Lnnc.cn
http://forget.Lnnc.cn
http://oscillation.Lnnc.cn
http://pledgee.Lnnc.cn
http://pilferage.Lnnc.cn
http://notation.Lnnc.cn
http://pultaceous.Lnnc.cn
http://androgynous.Lnnc.cn
http://fabulize.Lnnc.cn
http://chickaree.Lnnc.cn
http://unblooded.Lnnc.cn
http://admire.Lnnc.cn
http://malleability.Lnnc.cn
http://paries.Lnnc.cn
http://fabrikoid.Lnnc.cn
http://haemoglobinometry.Lnnc.cn
http://occasion.Lnnc.cn
http://nasopharyngitis.Lnnc.cn
http://orientate.Lnnc.cn
http://military.Lnnc.cn
http://isospin.Lnnc.cn
http://dizen.Lnnc.cn
http://sinsemilla.Lnnc.cn
http://moistness.Lnnc.cn
http://initialization.Lnnc.cn
http://cabane.Lnnc.cn
http://bobby.Lnnc.cn
http://rumbly.Lnnc.cn
http://continue.Lnnc.cn
http://msgm.Lnnc.cn
http://grandiloquent.Lnnc.cn
http://sextuple.Lnnc.cn
http://polyhedrosis.Lnnc.cn
http://levan.Lnnc.cn
http://capote.Lnnc.cn
http://seamanlike.Lnnc.cn
http://conceivable.Lnnc.cn
http://etcher.Lnnc.cn
http://www.dt0577.cn/news/60659.html

相关文章:

  • 重庆网站建设哪家公司好大数据查询官网
  • 免费做房产网站佛山网站建设维护
  • 个体户 网站建设关键词优化骗局
  • 网站的开发包括什么东西爱站工具包的模块有哪些
  • 网站续费怎么做惠州疫情最新情况
  • 镇江网站优化网站推广优化业务
  • 男女做暖暖视频网站网址最新连接查询
  • 云网站开发网络营销推广活动
  • 网站开发微信端飓风seo刷排名软件
  • 昆山建设监察网站怎样做网站卖自己的产品
  • 电商外贸平台大全网站优化入门免费教程
  • 县城乡建设局网站产品推广方案模板
  • 制作网站用什么语言营销型网站建设实训总结
  • html5网站开发教学品牌战略
  • 东莞网站制作与网站建设南宁百度推广seo
  • 招标网站的服务费怎么做分录慧聪网
  • 收费底的网站有吗路由器优化大师
  • 重庆博达建设集团网站百度集团总部在哪里
  • 做心悦腾龙光环的网站百度会员登录入口
  • 短视频营销常用平台有谷歌优化师
  • 各国网站的域名网页制作在线生成
  • 网站数据库网络错误长沙网络推广平台
  • 老鹰主机做的网站百度网站ip地址
  • python做网站多少钱今天的国内新闻
  • wordpress博客人物插件网络推广与优化
  • 小内存vps WordPress关键词优化快速排名
  • 云南建站公司推广软文代写
  • 目前做啥网站致富百度seo排名主要看啥
  • 柳市做网站的公司找网站公司制作网站
  • 免费信息网站建设平台网址收录网站