# "random()" function in secret contract?

**URL:** https://forum.scrt.network/t/random-function-in-secret-contract/394
**Category:** Secret Contracts and Secret Apps
**Created:** [October 12, 2018, 3:37pm UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394 "2018-10-12T15:37:23Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![niloofar](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@niloofar](https://forum.scrt.network/u/niloofar)
#### Post date: [October 12, 2018, 3:37pm UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394/1 "2018-10-12T15:37:24Z")

</div>

Hello every one.  
I know The requirement for determinism is the reason we won’t see the “random()” function on ethereum smart contract.  
the question is : can we make random numbers in our calculations on enigma secret contract?

---

<div class="post-metadata">

### Author: ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.scrt.network/u/david)
#### Post date: [October 14, 2018, 7:02pm UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394/2 "2018-10-14T19:02:25Z")

</div>

Not yet as right now it runs only EVM opcodes.

They might be able to extend the EVM by creating the E²VM (EnigmaEVM) or e²Wasm

That would include a pseudo-precompiled “contract” that would include a function `def random() public constant returns (uint64)`

But under the hood would be generated by the SGX random generator or some MPC.

---

<div class="post-metadata">

### Author: ![Channel](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/channel/32/177_2.png) [@Channel](https://forum.scrt.network/u/Channel)
#### Post date: [April 2, 2019, 6:13pm UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394/3 "2019-04-02T18:13:26Z")

</div>

What about a random “oracle”. Could we access randomness from somewhere else? [https://www.random.org/clients/](https://www.random.org/clients/) for instance?

---

<div class="post-metadata">

### Author: ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.scrt.network/u/david)
#### Post date: [April 5, 2019, 7:29am UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394/4 "2019-04-05T07:29:02Z")

</div>

> **[Chainlink](https://chain.link/)**
>
> Your smart contracts connected to real world data events and payments.

  
[http://www.town-crier.org/](http://www.town-crier.org/)

they use SGX – Enigma could implement SSL+parsing too.

---

<div class="post-metadata">

### Author: ![Fergal](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/fergal/32/16_2.png) [@Fergal](https://forum.scrt.network/u/Fergal)
#### Post date: [April 5, 2019, 12:18pm UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394/5 "2019-04-05T12:18:33Z")

</div>

Looks cool. Is this something you @david are working on?

---

<div class="post-metadata">

### Author: ![can](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/can/32/596_2.png) [@can](https://forum.scrt.network/u/can)
#### Post date: [April 5, 2019, 4:10pm UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394/6 "2019-04-05T16:10:01Z")

</div>

We can rely on SGX for randomness, i.e. there’s a RNG function inside the enclave that can be used. Would probably be easier than using [random.org](http://random.org) + SSL connection

---

<div class="post-metadata">

### Author: ![can](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/can/32/596_2.png) [@can](https://forum.scrt.network/u/can)
#### Post date: [April 5, 2019, 4:11pm UTC](https://forum.scrt.network/t/random-function-in-secret-contract/394/7 "2019-04-05T16:11:25Z")

</div>

Chainlink is primarily derived from Towncrier ([http://www.town-crier.org/](http://www.town-crier.org/)). Technically speaking, this can be integrated into Enigma protocol.
