169 похожих чатов

Hello everyone, I am just faced with unique identifiers in

solidity. In my project users should be able to register themselves and later user should be able to add a car post. So both user entity and car entity should have a unique Id.
And I am tried to research in the internet how to generate a unique id’s in solidity and as I understand there are 3 main options:

1) Just create a function that will increment an ID and return it’s value each time a new entity will be created.(But this method is too primitive)

2) Hash some data about entity(like email) with keccak256() + abi.encode function to make the result more protected. Or instead of entity info I saw a lot of examples that use a block.timestamp and block.difficulty. —> But as I understood, by using these methods, I will generate not a truly random ID, and it is not a safe way by multiple reasons.

3) I also read about VRF Chainlink random number generator, that this is the best way to generate a random number(like for casino, or lottery).

I understand that ID should be a unique, but I am not sure that to generate an ID I should use VRF from Chainlink.
The question: maybe someone can recommend me what is the best way to generate a random number for ID’s in Solidity?

Thanks!

2 ответов

21 просмотр

have a nonce, increment it, hash that number with some unique detail of the product and done you should get a semi random number that's somewhat safe

Tony- Автор вопроса

Похожие вопросы

Обсуждают сегодня

а зачем этот вопрос для удаления из чата?
Mёdkinson Medvezhkin
63
Эх кто-то пришел и весь праздник испортил :( You need complex FBX scene importing setup to change things on import? good luck with that. You need navigation and pathfinding? g...
Serg Gini
5
Всем привет! Подскажите. Я написал приложение на Delphi 10.2 Tokyo под Windows 10. И передо мной стал вопрос о том чтобы сделать это приложение кроссплатформенным (под Linux и...
Дмитрий Завгородний
24
Почему стало ломаться на D11? "739002.86400000' is not a valid timestamp" function IncDateTime(aStamp:TTimeStamp;aKind:TTriggerKind;aInterval:Integer):TDateTime; //aStamp = 2...
Катерина Свиридова
8
Привет всем. Подскажите где можно посмотреть, какая версия электрон, поддерживает версии windows? Некий changelog. Мне бы желательно, поддержку 7,8,10... latest, как понимаю и...
Anonym Squad
21
думаешь я не смогу также сделать? мне это просто не удобно
int 💳 𝙖𝙞𝙧 𝙗𝙞𝙜 𝙗𝙤𝙗 🔫 check bio / spam block / AFK / nohello.com / GMT+3
9
Портфолио: Зовут меня Александр, мне 36 лет. Город Пушкино. Общий рабочий стаж: ~14 лет Уровень квалификации: Senior Full-stack developer Где прочесть мой код? https://github....
Magic
10
Ребят, чет я уже не догоняю... Крч в коде на асм там происходит нечто вроде a+число (a+1, a+2 и т.д.). Но почему строка lea ecx, [edx+1] работает как a+1?? В edx берется адрес...
Alan 🔝 Бэброу
3
Есть ли смысл устраиваться на 1с ? Даст это плюс в дальнейшем трудоустройстве на php? Просто у меня в городе вакансий на пхп нету. Или лучше удаленно искать. Опыта работы нету...
Azamat
14
hi im a cs student. i need some advice from people who have enough experience in Embedded Software. I need to know whether this profession is suitable for me. I have watched s...
Sahand 🏔️
8
Карта сайта