There is no need to generate anything as ContractSafe already generates a unique code for every contract that is uploaded.
Just look at the very bottom of the Contract Page. Each number is only used once and is entirely unique.
You can choose to display this number on the Contract List (see how to customize the Contracts List here), export it as part of a report (see how here), or search for a document using this unique number. Just type the number into the search bar at the top of the page and you'll pull up exactly what you're looking for.
Please reach out to support@contractsafe.com for any questions.