# Random Number Generator in Cadence?

**URL:** <https://forum.flow.com/t/random-number-generator-in-cadence/490>\
**Category:** 🏄🏻‍♀️ Cadence\
**Created:** [July 24, 2020, 9:32am UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490 "2020-07-24T09:32:48Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mieszko](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mieszko](https://forum.flow.com/u/mieszko)\
**Post date:** [July 24, 2020, 9:32am UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/1 "2020-07-24T09:32:49Z")

</div>

I did not find it in the language ref so I understand one can’t generate pseudo random numbers. Are there plans to add it?

---

<div class="post-metadata">

**Author:** ![makoto](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/makoto/32/5_2.png) [@makoto](https://forum.flow.com/u/makoto)\
**Post date:** [July 24, 2020, 12:33pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/2 "2020-07-24T12:33:33Z")

</div>

FAQ page says they are working on it.

[https://docs.onflow.org/docs/faq#can-i-generate-random-numbers-in-cadence](https://docs.onflow.org/docs/faq#can-i-generate-random-numbers-in-cadence)

---

<div class="post-metadata">

**Author:** ![mieszko](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mieszko](https://forum.flow.com/u/mieszko)\
**Post date:** [July 24, 2020, 1:05pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/3 "2020-07-24T13:05:22Z")

</div>

Gr8, thx.

---

<div class="post-metadata">

**Author:** ![flowjosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/flowjosh/32/362_2.png) [@flowjosh](https://forum.flow.com/u/flowjosh)\
**Post date:** [July 24, 2020, 7:10pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/4 "2020-07-24T19:10:51Z")

</div>

@mieszko @makoto, there is a pseudo-random number generator in Cadence right now actually. `unsafeRand` is the name of the built in function. We’re a little bit behind on documentation, but we are doing an overhaul of the cadence formal language spec next week to include all of the features that have been added recently.

---

<div class="post-metadata">

**Author:** ![ebreuers](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/ebreuers/32/42_2.png) [@ebreuers](https://forum.flow.com/u/ebreuers)\
**Post date:** [July 24, 2020, 8:11pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/5 "2020-07-24T20:11:39Z")

</div>

Docs UX request - fixed sidebar for section navigation please! 🙏

---

<div class="post-metadata">

**Author:** ![flowjosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/flowjosh/32/362_2.png) [@flowjosh](https://forum.flow.com/u/flowjosh)\
**Post date:** [July 24, 2020, 8:29pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/6 "2020-07-24T20:29:02Z")

</div>

@ebreuers Can you be more specific? What is the problem you are having?

---

<div class="post-metadata">

**Author:** ![ebreuers](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/ebreuers/32/42_2.png) [@ebreuers](https://forum.flow.com/u/ebreuers)\
**Post date:** [July 24, 2020, 8:40pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/7 "2020-07-24T20:40:29Z")

</div>

No worries! I just notice navigating the docs is a little tricky as the anchor links are all at the top of the page. I spend a lot of time jumping back up to the Table of Contents navigation and navigating back and forth.

It would be great to have a fixed sidebar on the left or right side of the screen with anchor links to each section. (ie. so I can jump from “Interfaces” to “Resources”) Does that make more sense?

Moving it into the sidebar would be huge if possible: [https://www.dropbox.com/s/gxvkoizjf8bw3zb/Screen%20Shot%202020-07-24%20at%201.34.48%20PM.png?dl=0](https://www.dropbox.com/s/gxvkoizjf8bw3zb/Screen%20Shot%202020-07-24%20at%201.34.48%20PM.png?dl=0)

---

<div class="post-metadata">

**Author:** ![flowjosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/flowjosh/32/362_2.png) [@flowjosh](https://forum.flow.com/u/flowjosh)\
**Post date:** [July 24, 2020, 9:50pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/8 "2020-07-24T21:50:23Z")

</div>

@MaxStarka Did you implement the sidebar navigation for the language docs in an extension?

Long story short, the current tool we are using for our docs is not very customizable and we are planning on porting the docs to something different and more effective which will have the sidebar navigation.

@ebreuers What other language or tool documentation can you point us to as being docs that are really well organized and easy to understand? It would be great to know what works for you and others so we can improve our own! 😃

---

<div class="post-metadata">

**Author:** ![ebreuers](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/ebreuers/32/42_2.png) [@ebreuers](https://forum.flow.com/u/ebreuers)\
**Post date:** [July 24, 2020, 9:57pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/9 "2020-07-24T21:57:56Z")

</div>

You betcha! I’m sure the community would be willing to help out too 😉

Gatsby JS has some of the best doc swag going right now imo:

> **[Welcome to the Gatsby Way of Building | Gatsby](https://www.gatsbyjs.com/docs)**
>
> Gatsby is a React-based open source framework for creating websites. Whether your site has 100 pages or 100,000 pages — if you care deeply about performance, scalability, and built-in security — you'll love building with us. Start pulling data from...

---

<div class="post-metadata">

**Author:** ![MaxStarka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/maxstarka/32/56_2.png) [@MaxStarka](https://forum.flow.com/u/MaxStarka)\
**Post date:** [July 25, 2020, 8:50pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/10 "2020-07-25T20:50:29Z")

</div>

@ebreuers There is small extension for Chrome:  
[https://chrome.google.com/webstore/detail/flow-documentation-omnibo/mooekomnccgpiaigfphjgacagmbpgcoi?hl=ru&authuser=2](https://chrome.google.com/webstore/detail/flow-documentation-omnibo/mooekomnccgpiaigfphjgacagmbpgcoi?hl=ru&authuser=2)  
and Firefox:

> **[Flow Documentation - Omnibox Search – Get this Extension for 🦊 Firefox (en-US)](https://addons.mozilla.org/en-US/firefox/addon/cadence-omnibox-search/)**
>
> Download Flow Documentation - Omnibox Search for Firefox. Omnibox search with autocomplete filed to help browse through Cadence Documentation

Which will enable “Omnibox Search” overlay, when you press Ctrl+Alt+F (and I suppsoe Cmd+Option+F on Mac)

---

<div class="post-metadata">

**Author:** ![mieszko](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mieszko](https://forum.flow.com/u/mieszko)\
**Post date:** [July 25, 2020, 9:39pm UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/11 "2020-07-25T21:39:37Z")

</div>

@flowjosh My interpreter (flow v.0.5.1 commit: 2cc6bb4142344a65dc3c1481e58a01085390cf23) doesn’t seem to know `unsafeRand` as I’m getting:

> WARN[135592] ERR [4af8be] Execution failed:  
> Checking failed:  
> cannot find variable in this scope: `unsafeRand`. not found in this scope

Also I couldn’t find any mention of it in the `cadence` repo.

---

<div class="post-metadata">

**Author:** ![ebreuers](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/ebreuers/32/42_2.png) [@ebreuers](https://forum.flow.com/u/ebreuers)\
**Post date:** [July 26, 2020, 12:49am UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/12 "2020-07-26T00:49:24Z")

</div>

@MaxStarka another awesome tool, thank you! 🙏

---

<div class="post-metadata">

**Author:** ![bastian](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/bastian/32/183_2.png) [@bastian](https://forum.flow.com/u/bastian)\
**Post date:** [July 27, 2020, 4:24am UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/13 "2020-07-27T04:24:27Z")

</div>

> [@mieszko](#):
>
> doesn’t seem to know `unsafeRand`

The function signature is `fun unsafeRandom(): UInt64`.  
I plan to update the documentation shortly ([Update documentation · Issue #237 · onflow/cadence · GitHub](https://github.com/onflow/cadence/issues/237))

---

<div class="post-metadata">

**Author:** ![mieszko](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mieszko](https://forum.flow.com/u/mieszko)\
**Post date:** [July 27, 2020, 9:01am UTC](https://forum.flow.com/t/random-number-generator-in-cadence/490/14 "2020-07-27T09:01:17Z")

</div>

Thanks, got it thanks to the github issue. For the record it’s actually called

```
unsafeRandom()

```

and not `unsafeRand()`
