Hyperledger Fabric v1.4(LTS) 系列(5.2):Developing Applications-Analysis

Hyperledger Fabric v1.4(LTS) 系列(5.2):Developing Applications-Analysis

Analysis

Audience: Architects, Application and smart contract developers, Business professionals
受众:架构师、应用程序和智能合约开发人员、业务专业人员。

Let’s analyze commercial paper in a little more detail. PaperNet participants such as MagnetoCorp and DigiBank use commercial paper transactions to achieve their business objectives – let’s examine the structure of a commercial paper and the transactions that affect it over time. We will also consider which organizations in PaperNet need to sign off on a transaction based on the trust relationships among the organizations in the network. Later we’ll focus on how money flows between buyers and sellers; for now, let’s focus on the first paper issued by MagnetoCorp.

让我们更详细地分析一下商业票据。像MagnetoCorp和Digibank这样的PaperNet参与者使用商业票据交易来实现他们的业务目标——让我们来看看商业票据的结构以及在全程作用于商业票据的交易。我们还将考虑PaperNet中的哪些组织需要根据网络中组织之间的信任关系签署交易。稍后,我们将重点讨论资金如何在买卖双方之间流动;现在,让我们重点讨论MagnetoCorp发行的第一张票据。

Commercial paper lifecycle

A paper 00001 is issued by MagnetoCorp on May 31. Spend a few moments looking at the first state of this paper, with its different properties and values:

MagnetoCorp于5月31日发行了编号00001的票据。该票据的第一个状态有不同的属性和值:

Issuer = MagnetoCorp
Paper = 00001
Owner = MagnetoCorp
Issue date = 31 May 2020
Maturity = 30 November 2020
Face value = 5M USD
Current state = issued

This paper state is a result of the issue transaction and it brings MagnetoCorp’s first commercial paper into existence! Notice how this paper has a 5M USD face value for redemption later in the year. See how the Issuer and Owner are the same when paper 00001 is issued. Notice that this paper could be uniquely identified as MagnetoCorp00001 – a composition of the Issuer and Paper properties. Finally, see how the property Current state = issued quickly identifies the stage of MagnetoCorp paper 00001 in its lifecycle.

票据状态是issue交易的结果,它使MagnetoCorp的第一份商业票据得以存在!请注意,今年晚些时候,该票据的面值为500万美元。请注意在发行00001号票据时IssuerOwner 是相同的。请注意,该票据可以以 MagnetoCorp00001 为唯一标识,它由 Issuer and Paper 的属性组成。最后,查看属性Current state = issued 如何快速标识Magnetorp Paper 00001在其生命周期中的阶段。

Shortly after issuance, the paper is bought by DigiBank. Spend a few moments looking at how the same commercial paper has changed as a result of this buy transaction:
发行后不久,Digibank收购了该票据。看看同一商业票据是如何因这次buy交易而该改变:

Issuer = MagnetoCorp
Paper = 00001
Owner = DigiBank
Issue date = 31 May 2020
Maturity date = 30 November 2020
Face value = 5M USD
Current state = trading

The most significant change is that of Owner – see how the paper initially owned by MagnetoCorp is now owned by DigiBank. We could imagine how the paper might be subsequently sold to BrokerHouse or HedgeMatic, and the corresponding change to Owner. Note how Current state allow us to easily identify that the paper is now trading.
最显著的变化是Owner ,最初由MagnetoCorp 拥有的票据现在由DigiBank.拥有。我们可以想象该票据随后是如何出售给经纪公司或对冲公司的,以及相应的Owner的变化。请注意,Current state 如何使我们能够轻松地识别出票据现在处于 trading状态。

After 6 months, if DigiBank still holds the the commercial paper, it can redeem it with MagnetoCorp:
6个月后,如果DigiBank仍持有商业票据,则可以要求MagnetoCorp赎回:

Issuer = MagnetoCorp
Paper = 00001
Owner = MagnetoCorp
Issue date = 31 May 2020
Maturity date = 30 November 2020
Face value = 5M USD
Current state = redeemed

This final redeem transaction has ended the commercial paper’s lifecycle – it can be considered closed. It is often mandatory to keep a record of redeemed commercial papers, and the redeemed state allows us to quickly identify these. The value of Owner of a paper can be used to perform access control on the redeem transaction, by comparing the Owner against the identity of the transaction creator. Fabric supports this through the getCreator() chaincode API.
最终redeem交易结束商业票据的生命周期——可以认为它已经结束。通常强制保留已赎回商业票据的记录, redeemed 状态允许我们快速识别这些票据。票据的Owner 值可用于对redeem交易实行访问控制,方法是将Owner 与交易创建者的身份进行比较。Fabric通过 getCreator() chaincode API支持此功能。

If golang is used as a chaincode language, the client identity chaincode library can be used to retrieve additional attributes of the transaction creator.
如果用golang作链码语言,则可以使用 client identity chaincode library 来检索事务创建者的附加属性。

Transactions

We’ve seen that paper 00001’s lifecycle is relatively straightforward – it moves between issued, trading and redeemed as a result of an issue, buy, or redeem transaction.
我们已经看到00001号票据的生命周期相对简单,由于issuebuyredeem交易,它的状态在issued, trading and redeemed 间变动。

These three transactions are initiated by MagnetoCorp and DigiBank (twice), and drive the state changes of paper 00001. Let’s have a look at the transactions that affect this paper in a little more detail:
这三个交易是由MagnetoCorp和DigiBank(两次)发起的,并推动了00001号票据的状态变化。让我们更详细地了解一下影响该票据的事务:

Issue

Examine the first transaction initiated by MagnetoCorp:
由MagnetoCorp初始化的第一个事务

Txn = issue
Issuer = MagnetoCorp
Paper = 00001
Issue time = 31 May 2020 09:00:00 EST
Maturity date = 30 November 2020
Face value = 5M USD

See how the issue transaction has a structure with properties and values. This transaction structure is different to, but closely matches, the structure of paper 00001. That’s because they are different things – paper 00001 reflects a state of PaperNet that is a result of the issue transaction. It’s the logic behind the issue transaction (which we cannot see) that takes these properties and creates this paper. Because the transaction creates the paper, it means there’s a very close relationship between these structures.
请参阅issue事务具有怎样的属性和值的结构。这种事务结构不同于,但与票据00001的结构密切匹配。这是因为它们是不同的东西——票据00001反映了由于issue交易而带来的票据网络状态。正是issue事务背后的逻辑(我们看不到)接受了这些属性并创建了票据。因为事务creates票据,这意味着这些结构之间有非常密切的关系。

The only organization that is involved in the issue transaction is MagnetoCorp. Naturally, MagnetoCorp needs to sign off on the transaction. In general, the issuer of a paper is required to sign off on a transaction that issues a new paper.
参与issue交易的唯一组织是MagnetoCorp。自然,MagnetoCorp需要在交易上签字。一般来说,票据发行人必须在发行新票据的交易上签字。

Buy

Next, examine the buy transaction which transfers ownership of paper 00001 from MagnetoCorp to DigiBank:
接下来,检查buy交易,该交易将票据00001的所有权从MagnetoCorp转移到DigiBank:

Txn = buy
Issuer = MagnetoCorp
Paper = 00001
Current owner = MagnetoCorp
New owner = DigiBank
Purchase time = 31 May 2020 10:00:00 EST
Price = 4.94M USD

See how the buy transaction has fewer properties that end up in this paper. That’s because this transaction only modifies this paper. It’s only New owner = DigiBank that changes as a result of this transaction; everything else is the same. That’s OK – the most important thing about the buy transaction is the change of ownership, and indeed in this transaction, there’s an acknowledgement of the current owner of the paper, MagnetoCorp.
buy 交易比票据结束时的属性要少。这是因为这个事务只modifies该票据。只有New owner = DigiBank 会因为这个事务而改变;其他的都是一样的。buy 交易中最重要的是所有权的变更,事实上,在这宗交易中,有一个票据当前所有者MagnetoCorp的ACK声明。

You might ask why the Purchase time and Price properties are not captured in paper 00001? This comes back to the difference between the transaction and the paper. The 4.94 M USD price tag is actually a property of the transaction, rather than a property of this paper. Spend a little time thinking about this difference; it is not as obvious as it seems. We’re going to see later that the ledger will record both pieces of information – the history of all transactions that affect this paper, as well its latest state. Being clear on this separation of information is really important.
你可能会问,Purchase timePrice 属性为什么没有被记录在票据00001中?这又回到了交易和票据之间的区别。494万美元的价格标签实际上是交易的属性,而不是票据的属性。花点时间考虑一下这种差异;它不像看上去那么明显。稍后我们将看到,分类账将记录这两条信息—影响本文的所有交易的历史记录,以及它的最新状态。明确信息的区别是非常重要的。

It’s also worth remembering that paper 00001 may be bought and sold many times.
Although we’re skipping ahead a little in our scenario, let’s examine what transactions we might see if paper 00001 changes ownership.
要记住,票据00001可能会被买卖多次。尽管在场景中我们略过了一点,但是让我们检查一下票据00001更改所有者时我们might看到的事务。

If we have a purchase by BigFund:
如果BigFund发起一个交易:

Txn = buy
Issuer = MagnetoCorp
Paper = 00001
Current owner = DigiBank
New owner = BigFund
Purchase time = 2 June 2020 12:20:00 EST
Price = 4.93M USD

Followed by a subsequent purchase by HedgeMatic:
紧跟着是HedgeMatic

Txn = buy
Issuer = MagnetoCorp
Paper = 00001
Current owner = BigFund
New owner = HedgeMatic
Purchase time = 3 June 2020 15:59:00 EST
Price = 4.90M USD

See how the paper owners changes, and how in out example, the price changes. Can you think of a reason why the price of MagnetoCorp commercial paper might be falling?
看看票据所有者是如何变化的,以及示例中的价格是如何变化的。你能想到MagnetoCorp商业票据价格下跌的原因吗?

Intuitively, a buy transaction demands that both the selling as well as the buying organization need to sign off on such a transaction such that there is proof of the mutual agreement among the two parties that are part of the deal.
直观地讲,buy交易要求卖方和买方组织都必须在此类交易上签字,以证明交易双方之间达成的共同协议是交易的一部分。

Redeem

The redeem transaction for paper 00001 represents the end of its lifecycle. In our relatively simple example, DigiBank initiates the transaction which transfers the commercial paper back to MagnetoCorp:
票据00001的赎回交易代表其生命周期的结束。在我们相对简单的例子中,DigiBank发起了将商业票据转回Magnetorp的交易:

Txn = redeem
Issuer = MagnetoCorp
Paper = 00001
Current owner = HedgeMatic
Redeem time = 30 Nov 2020 12:00:00 EST

Again, notice how the redeem transaction has very few properties; all of the changes to paper 00001 can be calculated data by the redeem transaction logic: the Issuer will become the new owner, and the Current state will change to redeemed. The Current owner property is specified in our example, so that it can be checked against the current holder of the paper.
同样,请注意redeem交易的属性非常少;对票据00001的所有更改都可以通过赎回交易的逻辑计算:Issuer 将成为新的所有者,Current state 将更改为redeemed·。在我们的示例中指定了Current owner 属性,这样就可以对照票据的当前持有人来检查它。

From a trust perspective, the same reasoning of the buy transaction also applies to the redeem instruction: both organizations involved in the transaction are required to sign off on it.
从信任的角度来看,buy交易的相同推理也适用于redeem指令:参与交易的两个组织都需要在其上签字。

The Ledger

In this topic, we’ve seen how transactions and the resultant paper states are the two most important concepts in PaperNet. Indeed, we’ll see these two fundamental elements in any Hyperledger Fabric distributed ledger – a world state, that contains the current value of all objects, and a blockchain that records the history of all transactions that resulted in the current world state.
在本主题中,我们已经看到了事务和生成的票据状态是PaperNet中最重要的两个概念。事实上,我们将在任何Hyperledger Fabric的分布式账本 中看到这两个基本元素–一个包含所有对象当前值的全局状态,以及一个记录导致当前世界状态的所有交易历史的区块链。

The required sign-offs on transactions are enforced through rules, which are evaluated before appending a transaction to the ledger. Only if the required signatures are present, Fabric will accept a transaction as valid.
所需的交易签名通过规则强制执行,这些规则在将交易附加到分类帐之前进行评估。只有在所需的签名存在时,Fabric才会认为事务有效。

You’re now in a great place translate these ideas into a smart contract. Don’t worry if your programming is a little rusty, we’ll provide tips and pointers to understand the program code. Mastering the commercial paper smart contract is the first big step towards designing your own application. Or, if you’re a business analyst who’s comfortable with a little programming, don’t be afraid to keep dig a little deeper!
你现在可以把一些想法转化成一个智能合约。别担心您有点生疏,我们将提供一些技巧和指针来理解程序代码。掌握商业票据智能合约是设计自己的应用的第一大步。或者,如果你是一个能做点编程的业务分析师,不要害怕继续深入!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值