Random numbers are widely used in numerical computing, statistical simulation, random sampling, etc. At present, the mechanism for generating random numbers by computers is at risk of being attacked. In some cases, generated random numbers may be predicted. However, current RNGs used in blockchain are not sufficient enough to handle attacks. Therefore, it is necessary to improve the security of random numbers. This paper improves the random number generator and designs a secure random number generator based on blockchain (BCsRNG). In practice, an encapsulated function algorithm of the secure random number is developed with the smart contract. Moreover, an API is provided to facilitate input and output. The experimental results show that the random numbers generated by BCsRNG are difficult to decipher and have higher randomness and security.INDEX TERMS Random number, Blockchain, Smart contract, Security, Random number generator I. INTRODUCTION