SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "lotto777.html")
31 STORE("descrHdr", "Play to Be a Grandmaster")
32 STORE("iconURLHdr", "e4401ed6ee269b228109bc154e93c504cd056f369f90e40f43de87e8a5e0cc97")
33 STORE("dURL", "lotto777")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "2a89d20e444e181d80c3485e24484a8e60b7ef4baa1b10165803494aba98c209")
37 STORE("fileCheckS", "14524c1ecb2e406a2fe55b8b16e177211e097a444d029806685e8a45657c5674")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
<!DOCTYPE html>
<html>
<head>
<title>LOTTO777 - Play to Be a Grandmaster</title>
</head>
<body>
<pre id="connectionStatus">Waiting to connect... if connecting to remote node, disable https only in your browser</pre>
<button id="connectLocal">Connect to local node: 127.0.0.1:10102</button>
<button id="connectRemote">Connect to remote node: node.derofoundation.org:11012</button>
<div id="node-info1"></div>
<div id="node-info2"></div>
<script>
// Replace with your connection URLs
const connectionURL1 = 'ws://127.0.0.1:10102/ws';
const connectionURL2 = 'ws://node.derofoundation.org:11012/ws';
let socket; // Declare socket as a global variable
// Function to attempt connection
function attemptConnection(url) {
socket = new WebSocket(url); // Initialize global socket variable with new WebSocket
// Add event listeners for connection status and handle accordingly
socket.addEventListener('open', function(event) {
fetchNodeData();
setInterval(fetchNodeData, 7777); // Call fetchNodeData every 7.777 seconds (change interval if needed)
});
// Handle incoming messages
socket.addEventListener('message', function(event) {
const data = JSON.parse(event.data);
if (data.id == "1") {
const header = data.result.block_header;
const height = header.height;
const nodeInfo1 = document.getElementById('node-info1');
nodeInfo1.innerHTML = `<pre><strong>DERO Block Height: ${height}</strong></pre>`;
nodeInfo1.innerHTML += `<pre><h1>P l a y t o B e a G r a n d m a s t e r !</h1></pre>`;
} else if (data.id == "2") {
const variables = data.result.stringkeys;
const desiredKeys = ["Grandmaster1", "Grandmaster2", "Grandmaster3", "Grandmaster4", "Grandmaster5", "Grandmaster6", "Grandmaster7", "decimals", "totalsupply", "minted", "7lottery_pool", "77lottery_pool", "777lottery_pool", "winner_address", "withdrawal_fee"];
const nodeInfo2 = document.getElementById('node-info2'); // Add this line
nodeInfo2.innerHTML = `<pre><strong><a href="#info">Real-time Info</a> <a href="#how_to_play">How to Play with ENGRAM</a> <a href="#sc_code">DVM-BASIC SC Code</a></strong></pre>`;
nodeInfo2.innerHTML += `<pre><strong>LOTTO777 scid: f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6</strong></pre>`;
nodeInfo2.innerHTML += `<img src="lotto777.svg" alt="LOTTO 777">`;
nodeInfo2.innerHTML += `<pre><h2 id="info"><strong>LOTTO777 Real-time Info</strong></h2></pre>`;
desiredKeys.forEach(key => {
const value = variables[key];
if (value !== undefined) {
const pre = document.createElement('pre');
const span = document.createElement('span');
if (key.match(/^Grandmaster/) || key.match(/^winner_address/)) {
// Convert hexadecimal to ASCII
const asciiValue = value.match(/../g)
.map(byte => String.fromCharCode(parseInt(byte, 16))).join('');
span.innerHTML = `<strong>🍀 ${key}:</strong> ${asciiValue}`;
} else {
span.innerHTML = `<strong>${key}:</strong> ${value}`;
}
pre.appendChild(span);
nodeInfo2.appendChild(pre);
}
});
nodeInfo2.innerHTML += `<br><pre><h3><strong>Basic Info</strong></h3></pre>`;
nodeInfo2.innerHTML += `<pre>winner_address is the latest winning address from one of the three lottery pools</pre>`;
nodeInfo2.innerHTML += `<pre>withdrawal_fee in % (1-5)</pre>`;
nodeInfo2.innerHTML += `<pre>total supply is 7.7+ Mil. LOTTOs</pre><br>`;
nodeInfo2.innerHTML += `<pre>Pay_777_LOTTO__Game_7_rounds needs 7 entries, each of 777 LOTTOs until 5439 LOTTOs are reached in the pool.</pre>`;
nodeInfo2.innerHTML += `<pre>Pay_77_LOTTO__Game_77_rounds needs 77 entries, each of 77 LOTTOs until 5929 LOTTOs are reached in the pool.</pre>`;
nodeInfo2.innerHTML += `<pre>Pay_7_LOTTO__Game_777_rounds needs 777 entries, each of 7 LOTTOs until 5439 LOTTOs are reached in the pool.</pre><br>`;
nodeInfo2.innerHTML += `<pre>After a lottery pool reaches its limit, a winner of the pool is randomly chosen.</pre>`;
nodeInfo2.innerHTML += `<pre>Players (addresses) with the most won LOTTOs become Grandmasters.</pre>`;
nodeInfo2.innerHTML += `<pre>Grandmaster status of an address is lost after withdrawing its LOTTOs and needs to be earned again. <strong>Grandmasters do not pay withdrawal fees and earn fees when other players withdraw their LOTTOs.</strong></pre><br><hr>`;
nodeInfo2.innerHTML += `<pre><h2 id="how_to_play"><strong>How to play LOTTO777 with ENGRAM smart wallet?</strong></h2></pre>`;
nodeInfo2.innerHTML += `<pre>0. open your ENGRAM smart wallet</pre>`;
nodeInfo2.innerHTML += `<pre>1. <u>Slect Module</u> - <u>Asset Explorer</u> - paste the LOTTO scid: <strong>f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6</strong></pre>`;
nodeInfo2.innerHTML += `<pre>2. scroll down</pre>`;
nodeInfo2.innerHTML += `<pre>3. <u>Select one</u> - choose one of the three games to play: <strong><u>Pay_777_LOTTO__Game_7_rounds</u></strong>, or <strong><u>Pay_77_LOTTO__Game_77_rounds</u></strong>, or <strong><u>Pay_7_LOTTO__Game_777_rounds</u></strong></pre>`;
nodeInfo2.innerHTML += `<pre>4. type correct LOTTO amount you want to pay: Pay_<strong>777</strong>_LOTTO__Game_7_rounds type: <strong>777</strong>, or </pre><pre> Pay_<strong>77</strong>_LOTTO__Game_77_rounds type: <strong>77</strong>, or </pre><pre> Pay_<strong>7</strong>_LOTTO__Game_777_rounds type: <strong>7</strong></pre>`;
nodeInfo2.innerHTML += `<pre>5. and Execute</pre><br><hr>`;
const code = data.result.code;
nodeInfo2.innerHTML += `<pre><h2 id="sc_code">LOTTO777 DVM-BASIC SC Code:</h2>${code}</pre>`;
nodeInfo2.innerHTML += `<pre><strong><a href="">️⬆️ Go UP ️⬆️</a></strong></pre>`;
nodeInfo2.innerHTML += `<hr><pre> N O W A R R A N T I E S , P L A Y A T Y O U R O W N R I S K !</pre>`;
}
});
// Add event listeners for connection status and handle accordingly
socket.addEventListener('open', function(event) {
console.log('Connection opened successfully with: ' + url);
// Update connection status message
if (url === connectionURL1) {
// Update connection status message for local node
document.getElementById('connectionStatus').innerHTML = '<pre style="color:green;"><strong>🔒 Connected to local node: ' + url + '</strong></pre>';
} else if (url === connectionURL2) {
// Update connection status message for remote node
document.getElementById('connectionStatus').innerHTML = '<pre><strong>🔓 </strong>Connected to remote node: ' + url + '</pre>';
}
});
socket.addEventListener('error', function(error) {
console.error('Connection error: ' + error);
// Attempt to connect using the second URL on error
attemptConnection(connectionURL2);
});
}
// Attach click event listeners to the buttons
document.getElementById('connectLocal').addEventListener('click', function() {
attemptConnection(connectionURL1);
});
document.getElementById('connectRemote').addEventListener('click', function() {
attemptConnection(connectionURL2);
});
function fetchNodeData() {
// Define JSON RPC requests
const data1 = JSON.stringify({
"jsonrpc": "2.0",
"id": "1",
"method": "DERO.GetLastBlockHeader"
});
socket.send(data1);
const data2 = JSON.stringify({
"jsonrpc": "2.0",
"id": "2",
"method": "DERO.GetSC",
"params": {
"scid": "f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6",
"code": true,
"variables": true
}
});
socket.send(data2);
}
</script>
</body>
</html>
*/ |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "lotto777.html")
31 STORE("descrHdr", "Play to Be a Grandmaster")
32 STORE("iconURLHdr", "e4401ed6ee269b228109bc154e93c504cd056f369f90e40f43de87e8a5e0cc97")
33 STORE("dURL", "lotto777")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "2a89d20e444e181d80c3485e24484a8e60b7ef4baa1b10165803494aba98c209")
37 STORE("fileCheckS", "14524c1ecb2e406a2fe55b8b16e177211e097a444d029806685e8a45657c5674")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
<!DOCTYPE html>
<html>
<head>
<title>LOTTO777 - Play to Be a Grandmaster</title>
</head>
<body>
<pre id="connectionStatus">Waiting to connect... if connecting to remote node, disable https only in your browser</pre>
<button id="connectLocal">Connect to local node: 127.0.0.1:10102</button>
<button id="connectRemote">Connect to remote node: node.derofoundation.org:11012</button>
<div id="node-info1"></div>
<div id="node-info2"></div>
<script>
// Replace with your connection URLs
const connectionURL1 = 'ws://127.0.0.1:10102/ws';
const connectionURL2 = 'ws://node.derofoundation.org:11012/ws';
let socket; // Declare socket as a global variable
// Function to attempt connection
function attemptConnection(url) {
socket = new WebSocket(url); // Initialize global socket variable with new WebSocket
// Add event listeners for connection status and handle accordingly
socket.addEventListener('open', function(event) {
fetchNodeData();
setInterval(fetchNodeData, 7777); // Call fetchNodeData every 7.777 seconds (change interval if needed)
});
// Handle incoming messages
socket.addEventListener('message', function(event) {
const data = JSON.parse(event.data);
if (data.id == "1") {
const header = data.result.block_header;
const height = header.height;
const nodeInfo1 = document.getElementById('node-info1');
nodeInfo1.innerHTML = `<pre><strong>DERO Block Height: ${height}</strong></pre>`;
nodeInfo1.innerHTML += `<pre><h1>P l a y t o B e a G r a n d m a s t e r !</h1></pre>`;
} else if (data.id == "2") {
const variables = data.result.stringkeys;
const desiredKeys = ["Grandmaster1", "Grandmaster2", "Grandmaster3", "Grandmaster4", "Grandmaster5", "Grandmaster6", "Grandmaster7", "decimals", "totalsupply", "minted", "7lottery_pool", "77lottery_pool", "777lottery_pool", "winner_address", "withdrawal_fee"];
const nodeInfo2 = document.getElementById('node-info2'); // Add this line
nodeInfo2.innerHTML = `<pre><strong><a href="#info">Real-time Info</a> <a href="#how_to_play">How to Play with ENGRAM</a> <a href="#sc_code">DVM-BASIC SC Code</a></strong></pre>`;
nodeInfo2.innerHTML += `<pre><strong>LOTTO777 scid: f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6</strong></pre>`;
nodeInfo2.innerHTML += `<img src="lotto777.svg" alt="LOTTO 777">`;
nodeInfo2.innerHTML += `<pre><h2 id="info"><strong>LOTTO777 Real-time Info</strong></h2></pre>`;
desiredKeys.forEach(key => {
const value = variables[key];
if (value !== undefined) {
const pre = document.createElement('pre');
const span = document.createElement('span');
if (key.match(/^Grandmaster/) || key.match(/^winner_address/)) {
// Convert hexadecimal to ASCII
const asciiValue = value.match(/../g)
.map(byte => String.fromCharCode(parseInt(byte, 16))).join('');
span.innerHTML = `<strong>🍀 ${key}:</strong> ${asciiValue}`;
} else {
span.innerHTML = `<strong>${key}:</strong> ${value}`;
}
pre.appendChild(span);
nodeInfo2.appendChild(pre);
}
});
nodeInfo2.innerHTML += `<br><pre><h3><strong>Basic Info</strong></h3></pre>`;
nodeInfo2.innerHTML += `<pre>winner_address is the latest winning address from one of the three lottery pools</pre>`;
nodeInfo2.innerHTML += `<pre>withdrawal_fee in % (1-5)</pre>`;
nodeInfo2.innerHTML += `<pre>total supply is 7.7+ Mil. LOTTOs</pre><br>`;
nodeInfo2.innerHTML += `<pre>Pay_777_LOTTO__Game_7_rounds needs 7 entries, each of 777 LOTTOs until 5439 LOTTOs are reached in the pool.</pre>`;
nodeInfo2.innerHTML += `<pre>Pay_77_LOTTO__Game_77_rounds needs 77 entries, each of 77 LOTTOs until 5929 LOTTOs are reached in the pool.</pre>`;
nodeInfo2.innerHTML += `<pre>Pay_7_LOTTO__Game_777_rounds needs 777 entries, each of 7 LOTTOs until 5439 LOTTOs are reached in the pool.</pre><br>`;
nodeInfo2.innerHTML += `<pre>After a lottery pool reaches its limit, a winner of the pool is randomly chosen.</pre>`;
nodeInfo2.innerHTML += `<pre>Players (addresses) with the most won LOTTOs become Grandmasters.</pre>`;
nodeInfo2.innerHTML += `<pre>Grandmaster status of an address is lost after withdrawing its LOTTOs and needs to be earned again. <strong>Grandmasters do not pay withdrawal fees and earn fees when other players withdraw their LOTTOs.</strong></pre><br><hr>`;
nodeInfo2.innerHTML += `<pre><h2 id="how_to_play"><strong>How to play LOTTO777 with ENGRAM smart wallet?</strong></h2></pre>`;
nodeInfo2.innerHTML += `<pre>0. open your ENGRAM smart wallet</pre>`;
nodeInfo2.innerHTML += `<pre>1. <u>Slect Module</u> - <u>Asset Explorer</u> - paste the LOTTO scid: <strong>f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6</strong></pre>`;
nodeInfo2.innerHTML += `<pre>2. scroll down</pre>`;
nodeInfo2.innerHTML += `<pre>3. <u>Select one</u> - choose one of the three games to play: <strong><u>Pay_777_LOTTO__Game_7_rounds</u></strong>, or <strong><u>Pay_77_LOTTO__Game_77_rounds</u></strong>, or <strong><u>Pay_7_LOTTO__Game_777_rounds</u></strong></pre>`;
nodeInfo2.innerHTML += `<pre>4. type correct LOTTO amount you want to pay: Pay_<strong>777</strong>_LOTTO__Game_7_rounds type: <strong>777</strong>, or </pre><pre> Pay_<strong>77</strong>_LOTTO__Game_77_rounds type: <strong>77</strong>, or </pre><pre> Pay_<strong>7</strong>_LOTTO__Game_777_rounds type: <strong>7</strong></pre>`;
nodeInfo2.innerHTML += `<pre>5. and Execute</pre><br><hr>`;
const code = data.result.code;
nodeInfo2.innerHTML += `<pre><h2 id="sc_code">LOTTO777 DVM-BASIC SC Code:</h2>${code}</pre>`;
nodeInfo2.innerHTML += `<pre><strong><a href="">️⬆️ Go UP ️⬆️</a></strong></pre>`;
nodeInfo2.innerHTML += `<hr><pre> N O W A R R A N T I E S , P L A Y A T Y O U R O W N R I S K !</pre>`;
}
});
// Add event listeners for connection status and handle accordingly
socket.addEventListener('open', function(event) {
console.log('Connection opened successfully with: ' + url);
// Update connection status message
if (url === connectionURL1) {
// Update connection status message for local node
document.getElementById('connectionStatus').innerHTML = '<pre style="color:green;"><strong>🔒 Connected to local node: ' + url + '</strong></pre>';
} else if (url === connectionURL2) {
// Update connection status message for remote node
document.getElementById('connectionStatus').innerHTML = '<pre><strong>🔓 </strong>Connected to remote node: ' + url + '</pre>';
}
});
socket.addEventListener('error', function(error) {
console.error('Connection error: ' + error);
// Attempt to connect using the second URL on error
attemptConnection(connectionURL2);
});
}
// Attach click event listeners to the buttons
document.getElementById('connectLocal').addEventListener('click', function() {
attemptConnection(connectionURL1);
});
document.getElementById('connectRemote').addEventListener('click', function() {
attemptConnection(connectionURL2);
});
function fetchNodeData() {
// Define JSON RPC requests
const data1 = JSON.stringify({
"jsonrpc": "2.0",
"id": "1",
"method": "DERO.GetLastBlockHeader"
});
socket.send(data1);
const data2 = JSON.stringify({
"jsonrpc": "2.0",
"id": "2",
"method": "DERO.GetSC",
"params": {
"scid": "f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6",
"code": true,
"variables": true
}
});
socket.send(data2);
}
</script>
</body>
</html>
*/'] |