资源下载地址:https://download.csdn.net/download/sheziqiong/86161462
资源下载地址:https://download.csdn.net/download/sheziqiong/86161462

一、 项目背景

中小微企业融资难、融资贵是长久以来我国金融发展过程中需要解决的问题。世界银行、中小企业金融论坛、国际金融公司联合发布的《中小微企业融资缺口:对新兴市场微型、小型和中型企业融资不足与机遇的评估》报告中表示,中国 40%的中小微企业存在信贷困难,或是完全无法从正规金融体系获得外部融资,或是从正规金融体系获得的外部融资不能完全满足融资需求,有 1.9 万亿美元的融资缺口,接近 12 万亿元人民币。

比如以下场景。某知名车企(宝马)消费口碑好,金融机构对其信用评级很高,认为其有很大的风险承担能力。某次交易中,该车企从轮胎公司购买了一批轮胎,但由于资金暂时短缺向轮胎公司签订了1000 万的应收账款单据,承诺一年后归还。由于轮胎公司有宝马的账款单据,金融机构认为其有额能力还款,于是愿意借款给轮胎公司,然而,这种信任关系并不会向下游传递。比如,轮胎公司因资金短缺,向轮毂公司签订了 500 万的应收账款单据,但是当轮毂公司需要贷款时,金融机构因不认可轮胎公司的还款能力,需要对轮胎公司进行详细的信用分析,而这会增加很多的经济成本。很多时候,就是这个原因导致了小微企业的融资失败。

但是,区块链金融可以有效地解决上述问题。将供应链上的每一笔交易和应收账款单据上链,同时引入第三方可信机构来确认这些信息的交易,例如银行,物流公司等,确保交易和单据的真实性。同 时,支持应收账款的转让,融资,清算等,让核心企业的信用可以传递到供应链的下游企业,减小中小企业的融资难度。

二、 方案设计

将供应链上的每一笔交易和应收账款单据上链,同时引入第三方可信机构来确认这些信息的交易, 例如银行,物流公司等,确保交易和单据的真实性。同时,支持应收账款的转让,融资,清算等,让核心企业的信用可以传递到供应链的下游企业,减小中小企业的融资难度。

【存储设计】

将企业的收款单据存储在通过 FISCO BCOS 部署的四节点联盟链上。由于我们要解决的问题是供应链上下游的信息不对等而导致的融资难问题,我们只关注企业间的欠款信息,而忽略企业的余额,这也是本项目的设计思路。

当两个企业签订了应收账款单据,将它们的公司信息、应收数目上链,在必要时,企业间的应收账款可以转移到第三方,比如上例轮毂公司可以拿到宝马的 500 万欠款证明。

【核心功能介绍】

本项目主要实现以下四个功能:

功能一:实现采购商品—签发应收账款交易上链。例如车企从轮胎公司购买一批轮胎并签订应收账款单据。

功能二:实现应收账款的转让上链,轮胎公司从轮毂公司购买一笔轮毂,便将于车企的应收账款单据部分转让给轮毂公司。轮毂公司可以利用这个新的单据去融资或者要求车企到期时归还钱款。

功能三:利用应收账款向银行融资上链,供应链上所有可以利用应收账款单据向银行申请融资。

功能四:应收账款支付结算上链,应收账款单据到期时核心企业向下游企业支付相应的欠款。

核心功能主要体现在部署在区块链上的智能合约。智能合约代码如下:

package org.fisco.bcos.asset.client;import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.List;
import java.util.Properties;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.fisco.bcos.asset.contract.Asset;
import org.fisco.bcos.asset.contract.Asset.RegisterEventEventResponse;
import org.fisco.bcos.asset.contract.Asset.TransferEventEventResponse;
import org.fisco.bcos.channel.client.Service;
import org.fisco.bcos.web3j.crypto.Credentials;
import org.fisco.bcos.web3j.crypto.Keys;
import org.fisco.bcos.web3j.protocol.Web3j;
import org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService;
import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt;
import org.fisco.bcos.web3j.tuples.generated.Tuple2;
import org.fisco.bcos.web3j.tx.gas.StaticGasProvider;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;public class AssetClient {static Logger logger = LoggerFactory.getLogger(AssetClient.class);private Web3j web3j;private Credentials credentials;public Web3j getWeb3j() {return web3j;}public void setWeb3j(Web3j web3j) {this.web3j = web3j;}public Credentials getCredentials() {return credentials;}public void setCredentials(Credentials credentials) {this.credentials = credentials;}public void recordAssetAddr(String address) throws FileNotFoundException, IOException {Properties prop = new Properties();prop.setProperty("address", address);final Resource contractResource = new ClassPathResource("contract.properties");FileOutputStream fileOutputStream = new FileOutputStream(contractResource.getFile());prop.store(fileOutputStream, "contract address");}public String loadAssetAddr() throws Exception {// load Asset contact address from contract.propertiesProperties prop = new Properties();final Resource contractResource = new ClassPathResource("contract.properties");prop.load(contractResource.getInputStream());String contractAddress = prop.getProperty("address");if (contractAddress == null || contractAddress.trim().equals("")) {throw new Exception(" load Asset contract address failed, please deploy it first. ");}logger.info(" load Asset address from contract.properties, address is {}", contractAddress);return contractAddress;}public void initialize() throws Exception {// init the Service@SuppressWarnings("resource")ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");Service service = context.getBean(Service.class);service.run();ChannelEthereumService channelEthereumService = new ChannelEthereumService();channelEthereumService.setChannelService(service);Web3j web3j = Web3j.build(channelEthereumService, 1);// init CredentialsCredentials credentials = Credentials.create(Keys.createEcKeyPair());setCredentials(credentials);setWeb3j(web3j);logger.debug(" web3j is " + web3j + " ,credentials is " + credentials);}private static BigInteger gasPrice = new BigInteger("30000000");private static BigInteger gasLimit = new BigInteger("30000000");public void deployAssetAndRecordAddr() {try {Asset asset = Asset.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).send();System.out.println(" deploy Asset success, contract address is " + asset.getContractAddress());recordAssetAddr(asset.getContractAddress());} catch (Exception e) {// TODO Auto-generated catch block// e.printStackTrace();System.out.println(" deploy Asset contract failed, error message is  " + e.getMessage());}}public void queryAssetAmount(String assetAccount) {try {String contractAddress = loadAssetAddr();Asset asset = Asset.load(contractAddress, web3j, credentials, new StaticGasProvider(gasPrice, gasLimit));Tuple2<BigInteger, BigInteger> result = asset.select(assetAccount).send();if (result.getValue1().compareTo(new BigInteger("0")) == 0) {System.out.printf(" asset account %s, value %s \n", assetAccount, result.getValue2());} else {System.out.printf(" %s asset account is not exist \n", assetAccount);}} catch (Exception e) {// TODO Auto-generated catch block// e.printStackTrace();logger.error(" queryAssetAmount exception, error message is {}", e.getMessage());System.out.printf(" query asset account failed, error message is %s\n", e.getMessage());}}public void registerAssetAccount(String assetAccount, BigInteger amount) {try {String contractAddress = loadAssetAddr();Asset asset = Asset.load(contractAddress, web3j, credentials, new StaticGasProvider(gasPrice, gasLimit));TransactionReceipt receipt = asset.register(assetAccount, amount).send();List<RegisterEventEventResponse> response = asset.getRegisterEventEvents(receipt);if (!response.isEmpty()) {if (response.get(0).ret.compareTo(new BigInteger("0")) == 0) {System.out.printf(" register asset account success => asset: %s, value: %s \n", assetAccount,amount);} else {System.out.printf(" register asset account failed, ret code is %s \n",response.get(0).ret.toString());}} else {System.out.println(" event log not found, maybe transaction not exec. ");}} catch (Exception e) {// TODO Auto-generated catch block// e.printStackTrace();logger.error(" registerAssetAccount exception, error message is {}", e.getMessage());System.out.printf(" register asset account failed, error message is %s\n", e.getMessage());}}public void transferAsset(String fromAssetAccount, String toAssetAccount, BigInteger amount) {try {String contractAddress = loadAssetAddr();Asset asset = Asset.load(contractAddress, web3j, credentials, new StaticGasProvider(gasPrice, gasLimit));TransactionReceipt receipt = asset.transfer(fromAssetAccount, toAssetAccount, amount).send();List<TransferEventEventResponse> response = asset.getTransferEventEvents(receipt);if (!response.isEmpty()) {if (response.get(0).ret.compareTo(new BigInteger("0")) == 0) {System.out.printf(" transfer success => from_asset: %s, to_asset: %s, amount: %s \n",fromAssetAccount, toAssetAccount, amount);} else {System.out.printf(" transfer asset account failed, ret code is %s \n",response.get(0).ret.toString());}} else {System.out.println(" event log not found, maybe transaction not exec. ");}} catch (Exception e) {// TODO Auto-generated catch block// e.printStackTrace();logger.error(" registerAssetAccount exception, error message is {}", e.getMessage());System.out.printf(" register asset account failed, error message is %s\n", e.getMessage());}}public static void Usage() {System.out.println(" Usage:");System.out.println("\t java -cp conf/:lib/*:apps/* org.fisco.bcos.asset.client.AssetClient deploy");System.out.println("\t java -cp conf/:lib/*:apps/* org.fisco.bcos.asset.client.AssetClient query account");System.out.println("\t java -cp conf/:lib/*:apps/* org.fisco.bcos.asset.client.AssetClient register account value");System.out.println("\t java -cp conf/:lib/*:apps/* org.fisco.bcos.asset.client.AssetClient transfer from_account to_account amount");System.exit(0);}public static void main(String[] args) throws Exception {if (args.length < 1) {Usage();}AssetClient client = new AssetClient();client.initialize();switch (args[0]) {case "deploy":client.deployAssetAndRecordAddr();break;case "query":if (args.length < 2) {Usage();}client.queryAssetAmount(args[1]);break;case "register":if (args.length < 3) {Usage();}client.registerAssetAccount(args[1], new BigInteger(args[2]));break;case "transfer":if (args.length < 4) {Usage();}client.transferAsset(args[1], args[2], new BigInteger(args[3]));break;default: {Usage();}}System.exit(0);}
}

三、 功能测试

首先在WeBase 平台上测试智能合约。

首先,根据不同公司创建用户,一共有:银行(Bank)、汽车厂(CarCompany)、轮胎厂

(TyreCompany)、轮毂厂(HubCompany):

对编写好的合约进行编译、部署:

功能一:实现采购商品—签发应收账款交易上链。

(说明:车企欠轮胎厂 1000 万元) 部署成功会显示相关信息。

(说明:轮胎厂欠轮毂厂 500 万元) 查看链上的交易信息:

说明交易信息成功上链。功能一完成。

功能二:实现应收账款的转让上链。

(说明:车企欠轮胎厂的部分金额,转嫁到轮毂厂)

再次查看链上的交易信息:

现在车企欠轮胎厂和轮毂厂各 500 万元,说明功能二实现。

功能三:利用应收账款向银行融资上链。

(获取轮毂厂的总债务)

轮毂厂向银行借贷:

说明功能三实现。

功能四:应收账款支付结算上链。

(车企还轮胎厂 200 万元)

(车企还欠轮胎厂 300 万元)

车企再还 300 万元给轮胎厂,则抹去链上该条交易信息。以上是智能合约的测试结果。

资源下载地址:https://download.csdn.net/download/sheziqiong/86161462
资源下载地址:https://download.csdn.net/download/sheziqiong/86161462

基于Java实现的区块链供应链金融系统平台设计相关推荐

  1. 泛融等多家业界权威通力合作,联合信通院发布《区块链供应链金融白皮书》

    2018年10月31日下午,区块链政策法律研究组成立会暨<区块链与供应链金融白皮书(2018 年)>发布会在中国信息通信研究院举行.会议当天,来自腾讯.百度.京东金融.泛融科技.SAP.西 ...

  2. 有信用就有明天!区块链+供应链金融助力企业融资的5种方式

    据互链脉搏不完全统计,中国各类机构设立的区块链+供应链项目近百例.疫情期间它们也在发挥作用. 钱荒+疫情,企业尤其是中小企业面临生死大考.除了中央调整货币政策和财政政策纾困,来自民间的力量也多了一种工 ...

  3. 区块链开发:区块链供应链金融

    区块链开发:区块链供应链金融 供应链金融,被视为区块链落地的最佳应用场景之一. 近日,在由万联网主办的 "CSCFIS 2019 第六届中国供应链金融创新高峰论坛 " 上,区块链成 ...

  4. 【区块链】研究报告:区块链+供应链金融

    自2016年区块链在国内掀起热潮以来,整个行业都在不断地探索各类落地场景,真可谓区块链如此多娇,引得无数创业者竞折腰.那么供应链金融这个赛道的优势何在?传统的模式存在哪些痛点?区块链能够创造出哪些新的 ...

  5. 中国青年报:“区块链+供应链金融”为小微企业融资推开一扇窗

    金融科技赋能下,供应链金融成了"香饽饽". 长期以来,小微企业由于自身信用不足.抵质押物相对缺乏.信息不对称等原因导致其融资难.融资贵.融资慢,而供应链金融就是银行围绕核心企业,管 ...

  6. 四股力量逐鹿区块链+供应链金融 纯技术公司靠什么谋得市场?

    文丨互链脉搏·黑珍珠号 未经授权,不得转载! 8月26日,国务院印发6个新设自贸区总体方案,区块链.供应链建设被重点提及.同天,51家央企在北京进行了央企商业承兑汇票互认联盟签约,互认联盟成员单位代表 ...

  7. 基于Java语言构建区块链(四)—— 交易(UTXO)

    基于Java语言构建区块链(四)-- 交易(UTXO) 2018年03月11日 00:48:01 wangwei_hz 阅读数:909 标签: 区块链比特币 更多 个人分类: 区块链 文章的主要思想和 ...

  8. 基于Java语言构建区块链(五)—— 地址(钱包)

    基于Java语言构建区块链(五)-- 地址(钱包) 2018年03月25日 18:02:06 wangwei_hz 阅读数:1292更多 个人分类: 区块链bitcoin比特币 文章的主要思想和内容均 ...

  9. 基于Java语言构建区块链(六)—— 交易(Merkle Tree)

    基于Java语言构建区块链(六)-- 交易(Merkle Tree) 2018年04月16日 10:21:35 wangwei_hz 阅读数:480更多 个人分类: 区块链比特币bitcoin 最终内 ...

最新文章

  1. mysql基于replication实现最简单的M-S主从复制
  2. html 内部浮动外部不,CSS:外部层高度自适应内部浮动层高度的方法
  3. 从一个文件夹下随机抽取一定数量(比例)的图片移动到另一个文件夹 Python3实现
  4. 在java web项目中实现随项目启动的额外操作
  5. 关于Oracle undostat中的2012和ORA-01555问题的自我解答
  6. java 虚拟机类型的卸载_《深入理解Java虚拟机》:类加载和初始化(二)
  7. mysql的错误代码4999_mysql相关错误以及对应解决方法总结
  8. 马化腾最新演讲谈机遇:让所有企业在云端利用AI处理大数据
  9. 聊聊FluxFlatMap的concurrency及prefetch参数
  10. 笔记-delphi7高效数据库程序设计
  11. java list remove 无效_JAVA List使用Remove时的一些问题
  12. 友盟分享失败后有回调吗_友盟分享成功回调问题
  13. Insyde uefi 隐藏设置_Android/iOS QQ 8.1.5测试版同时发布:私密会话可以隐藏
  14. 网线插座接法,网线模块制作及其安装步骤(图解)
  15. word 插入表格,位置不在最左边
  16. 字节的按位逆序 Reverse Bits
  17. 【程序员必修数学课】-基础思想篇-二进制-原码反码补码的数学论证
  18. 找寻自己的哲学世界?
  19. oracle查询练习2(解析+答案)
  20. java jsf 入门_JSF入门实战

热门文章

  1. GardenPlanner 下载,园林绿化设计
  2. 2022年12月电子学会青少年软件编程Scratch(二级)等级考试真题解析
  3. 电脑桌面图标有小黄锁怎么办?
  4. System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
  5. 机器学习(32)之典型相关性分析(CCA)详解 【文末有福利......】
  6. 商品规格表设计_超市商品配置表的管理
  7. CodeGear Rad Studio2007新特性(本人搜集Waiting4you的帖子)
  8. 绝对布局AbsoluteLayout学习笔记
  9. windows jar包按钮启动和开机自启两种方式实现
  10. vc中IP地址控件的使用