Comments (8)
Indeed, the use of a 256-bit hash is not the best example. More information is missing. I have interacted a lot with this smart contract. I will try to improve the content of this tutorial in the coming days.
from wax-developer.
update: the first 64-bits of the tx apparently are not the part that have the block number, etc 😅so as soon as I try to submit a tx with similar data, it returns a duplicate number, so I'll have to see what the tx structure is to at least get the part that does change with every execution 😅
update2: had a bug in the code; updated the snippet and it now works (ran a bunch of tests).
from wax-developer.
I have always used this without any issues, its the same method the atomicpacks contract uses.
uint64_t generate_signing_value() {
size_t size = transaction_size();
char buf[size];
uint32_t read = read_transaction(buf, size);
check(size == read, string("read_transaction() has failed.").c_str());
checksum256 tx_id = sha256(buf, read);
uint64_t signing_value;
memcpy(&signing_value, &tx_id, sizeof(signing_value));
return signing_value;
}
Although the atomicpacks contract also has an extra step of checking if the signing_value was already used which should not be done, its not intended use and the table its checking might go away soon.
from wax-developer.
PR for updated content has been merged: https://developer.wax.io/en/tutorials/create-wax-rng-smart-contract/rng_basics
from wax-developer.
code sample changed in #85
from wax-developer.
I still don't think advising to check the signvals table is a good idea.
This is part of the old RNG system and could be removed in future updates.
from wax-developer.
Yep. This is only an example of use. Obviously in the future anything can change due to future updates. When that happens it will be necessary to revise the examples.
I didn't want to introduce more actors but, if someone asks me, I would recommend using an NFT ID as signing_value instead of trying to generate a unique and valid one.
I would also recommend developing a customised and complete system, including Oracle. It's been proven that relying on external services can leave your application hanging.
But this is all at another level and this tutorial is at a basic level.
from wax-developer.
closing this issue
from wax-developer.
Related Issues (20)
- Content: Request Client Development Guides
- Contribution Guidelines HOT 4
- Content: Persona Definition HOT 1
- Presentation of Docs HOT 1
- Migrate to Vuepress HOT 1
- Layout and Styling Tasks HOT 4
- Docs: General Stylings HOT 1
- Content Backlog
- Repo: Contributer Guide and Wiki
- Content: Merge PRs HOT 1
- Content: About WAX HOT 1
- Docs: Host Development Preview HOT 2
- Content: Add ChildToC to overviews HOT 1
- Content: Update Links to docs.eosnetwork.com HOT 1
- Content: Frontpage Content HOT 1
- Content: Locales & Content transfer
- Fix: Post-Launch HOT 1
- Repo: Readme
- I want to join your team
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wax-developer.