DEV Community

Cover image for Building a No-Code Bitcoin Jackpot Inscription with Randomness result
Son Pin
Son Pin

Posted on

1

Building a No-Code Bitcoin Jackpot Inscription with Randomness result

Prerequisite

  1. Familiarize yourself with Chat GPT
  2. Install the latest version of Google Chrome on your computer
  3. Create an account on Xverse Wallet (if you haven't already) to access your cryptocurrency funds.

Let's hack

Ordinals Protocol introduced the ability for anyone to inscribe files fully on-chain onto Bitcoin. These inscriptions are self-contained and unaware of the other files that had been inscribed. With the introduction of recursive inscription that is about to change.

Recursive

With the endpoint /blockhash/<HEIGHT>, we can retrieve the block hash at a given block height, which provides us with a way to obtain a random number using the block height in the future.

Create html template

1. Ask ChatGPT to generate a HTML template

ChatGPT

2. We got the result

<!DOCTYPE html>
<html>
<head>
  <title>Reminder of a uint256 Number</title>
</head>
<body>
  <h1>Reminder of a uint256 Number</h1>
  <div id="reminder"></div>

  <script>
    document.addEventListener("DOMContentLoaded", function() {
      // Fetch the uint256 number from the external API
      fetch("https://api.example.com/getNumber")
        .then(response => response.json())
        .then(data => {
          // Extract the uint256 number from the API response
          var number = data.number;

          // Calculate the reminder of the uint256 number
          var reminder = number % 10;

          // Render the reminder on the HTML page
          var reminderElement = document.getElementById("reminder");
          reminderElement.textContent = "Reminder of the number " + number + " is: " + reminder;
        })
        .catch(error => {
          var reminderElement = document.getElementById("reminder");
          reminderElement.textContent = "Failed to fetch the number from the API.";
        });
    });
  </script>
</body>
</html>

Enter fullscreen mode Exit fullscreen mode

We need to customize HTML template to fetch to the future block height. Example 795999

<!DOCTYPE html>
<html>

<head>
    <title>Jackpot</title>
    <style>
        html,
        body {
            width: 400px;
            height: 400px;
            margin: 0;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #reminder {
            text-align: center;
        }
    </style>
</head>

<body>
    <h1>Lucky number: <div id="reminder"></div></h1>


    <script>
        document.addEventListener("DOMContentLoaded", function () {
            // Fetch the uint256 number from the external API
            fetch("/blockhash/795999")
                .then(response => response.json())
                .then(data => {
                    // Extract the uint256 number from the API response
                    var number = BigInt(data.number); // Parse as BigInt

                    // Calculate the reminder of the uint256 number
                    var reminder = number % BigInt(100); // Perform modulo operation as BigInt

                    // Render the reminder on the HTML page
                    var reminderElement = document.getElementById("reminder");
                    reminderElement.textContent = reminder.toString();
                })
                .catch(error => {
                    var reminderElement = document.getElementById("reminder");
                    reminderElement.textContent = "TBA";
                });
        });
    </script>
</body>

</html>
Enter fullscreen mode Exit fullscreen mode

Save your HMTL code to your computer

3. Go to Unisat website to insribe your HTML

Just connect your wallet with funds, drop HTML file to this area and insribe

Unisat

4. Check your insription at OrdinalScan

https://ordiscan.com/inscription/13550067

Result

Congrats! your insription has minted

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (1)

Collapse
 
luckyholders profile image
Lucky Holders โ€ข

Wow, thank you ๐Ÿงก

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay