Code Monkey home page Code Monkey logo

Comments (8)

3dkrender avatar 3dkrender commented on July 30, 2024 1

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.

NKCSS avatar NKCSS commented on July 30, 2024

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.

includenull avatar includenull commented on July 30, 2024

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.

rakeden avatar rakeden commented on July 30, 2024

PR for updated content has been merged: https://developer.wax.io/en/tutorials/create-wax-rng-smart-contract/rng_basics

from wax-developer.

rakeden avatar rakeden commented on July 30, 2024

code sample changed in #85

from wax-developer.

includenull avatar includenull commented on July 30, 2024

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.

3dkrender avatar 3dkrender commented on July 30, 2024

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.

rakeden avatar rakeden commented on July 30, 2024

closing this issue

from wax-developer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.