How hyperledger generates random number for smart contract?


Kimheng SOK
 

Dear all,

I wonder how hyperledger generates random number for smart contract?

As in Ethereum, they can the random number from chain link in to their smart contract.

Bests


inzamam ansari <inzamam8526@...>
 

Hi Kimheng,

As per my experience don't create random number on chaincode, cause chaincode runs on every endorsing peers

and it generates different numbers in every peer 

so the read write set of each endorsing peer will be different so the committing peers refuse to commit the state on ledger.

Solution:-
Create a random number in SDK of hyperledger fabric and pass it to chaincode function. 

I think it will solve the problem, cause read and write set will be the same from many endorsing peers. 

On Sat, May 7, 2022, 19:28 Kimheng SOK <sok.kimheng@...> wrote:
Dear all,

I wonder how hyperledger generates random number for smart contract?

As in Ethereum, they can the random number from chain link in to their smart contract.

Bests