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)?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With