Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Hyperledger-Fabric provide a way to find out who (msg.sender in Ethereum) called the chaincode?

In Hyperledger-Fabric how to get Ethereum like "msg.sender" in chaincode? (also when chaincode A calls chaincode B, will the "msg.sender" be script-address of A (like in Ethereum)?

like image 823
Rupert Redding Avatar asked Apr 25 '17 14:04

Rupert Redding


People also ask

What is chaincode in Hyperledger fabric?

Chaincode is a program, written in Go, node. js, or Java that implements a prescribed interface. Chaincode runs in a secured Docker container isolated from the endorsing peer process. Chaincode initializes and manages ledger state through transactions submitted by applications.

How is chaincode passed around in Hyperledger fabric?

The package format used to pass around the chaincode implementation is called ChaincodeDeploymentSpec , which includes the source code, the policies for instantiating (setting up and running) the chaincode application, and the list of entities that have agreed on the chaincode.

What is chaincode in blockchain?

Chaincode, also referred to as smart contracts, is software that you can use to read and update data on the blockchain ledger. Chaincode can turn business logic into an executable program that is agreed to and verified by all members of the blockchain network.

What transactions deploy new chaincode to the Hyperledger fabric blockchain?

Hyperledger Fabric users often use the terms smart contract and chaincode interchangeably. In general, a smart contract defines the transaction logic that controls the lifecycle of a business object contained in the world state. It is then packaged into a chaincode which is then deployed to a blockchain network.


1 Answers

To add onto Mo-Che Chan's answer:

func (stub *ChaincodeStub) GetCreator() ([]byte, error)

GetCreator returns SignatureHeader.Creator of the signedProposal this Stub refers to.

GetCreator should get signedProposal and proposal.

From the HyperLedger blog:

The Creator field holds x.509 certificate, public key and membership service provided (MSP) who issued these identity to the client. The Nonce field contains some random bytes.

type SignatureHeader struct {   
    Creator []byte 
    Nonce []byte 
}

And from another post on the same blog, a diagram of the block structure. It has a section in each transaction (see row 4) for

Creator Identity (certificate, public key) - Client

It seems as if yes, this would be the equivalent of msg.sender in Solidity.

Block structure

like image 158
k26dr Avatar answered Oct 06 '22 00:10

k26dr