SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "index.html")
31 STORE("descrHdr", "Play LOTTO777 Tool")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "play.lotto777")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "50dcc62161d626a711053942f09ab4f3e3845898f44275ab4202535e7924920")
37 STORE("fileCheckS", "d7cb802326b60f3f96d8f2d85cb1df2e1c818b2d4ed0bc3100fc3303fc421e5")
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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LOTTO777 - Play to Be a Grandmaster</title>
<style>
body {
font-family: "Courier New", Courier, monospace;
background-color: black;
color: white;
}
button {
margin: 5px;
padding: 8px;
}
</style>
</head>
<body>
<div>
<img src="lotto777.svg" style="vertical-align: middle;">
<div style="display: inline;">
<button id="connectButton">Connect</button>
<button id="getAddressButton" disabled>My Address</button>
<button id="getBalanceButton" disabled>My LOTTO Balance</button>
<button id="getDeroBalanceButton" disabled>My DERO Balance</button> Play:
<button id="playLotto777Button" disabled>Ticket 🍀 $LOTTO 777.-</button>
<button id="playLotto77Button" disabled>Ticket 🍀 $LOTTO 77.-</button>
<button id="playLotto7Button" disabled>Ticket 🍀 $LOTTO 7.-</button>
<button id="withdrawLottoButton" disabled>Withdraw 💰 LOTTO</button>
<button id="mintLottoButton" disabled>Mint 🆕 LOTTO</button>
<button id="getInfoButton" disabled>Info</button>
</div>
<div style="display: inline;">
<br><pre style="display: inline; color: green;">P l a y t o B e a G r a n d m a s t e r</pre>
</div>
<div id="status"></div>
<pre id="jsonResult"></pre>
<script>
let response;
let socket;
let address;
let currentBalanceRequest = '';
const scid = "f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6";
// XSWD application data
const applicationData = {
id: "d8533279732943d4317f29a11d491a1d41af5de725a0500d6a02c3605ad8fada",
name: "LOTTO777 Playing Tool",
description: "LOTTO777 on TELA, Playing, Minting, Withdrawal",
url: "http://localhost:" + location.port,
};
// Handle web socket connection and listeners
function connectWebSocket() {
if (document.getElementById("connectButton").textContent === "Disconnect") {
return;
}
socket = new WebSocket("ws://localhost:44326/xswd");
socket.addEventListener("open", function(event) {
console.log("Web socket connection established:", event);
typed = 0;
typeWriter("..allow all connection requests");
sendData(applicationData);
});
socket.addEventListener("message", function(event) {
response = JSON.parse(event.data);
console.log("Response received:", response);
if (response.result) {
const res = response.result;
if (res.address) {
address = res.address;
console.log("Connected address:", address);
connecting = false;
typeWriter(`Address: ${address}`);
} else if (res.unlocked_balance !== undefined) {
const bal = "Balance: " + (res.unlocked_balance / 100000).toFixed(5) + " " + currentBalanceRequest;
console.log(bal);
typeWriter(bal);
} else if (res.txid) {
if (response.id === "8") {
typeWriter("You sent txid: " + res.txid);
setTimeout(() => {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
}, 1000);
} else if (response.id === "7") {
typeWriter("You sent txid: " + res.txid);
setTimeout(() => {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
}, 1000);
} else {
typeWriter("You sent txid: " + res.txid);
setTimeout(() => {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
}, 1000);
}
} else if (response.id === '"9"' && res.stringkeys) {
console.log("Processing Info response");
const variables = res.stringkeys;
typeWriter("🍀 🍀 🍀");
// Display lottery pools
typeWriter(`Game 7 LOTTO, 777 Tickets, Pool: ${parseInt(variables['7lottery_pool'])/100000}.-/5439.- LOTTO`);
typeWriter(`Game 77 LOTTO, 77 Tickets, Pool: ${parseInt(variables['77lottery_pool'])/100000}.-/5929.- LOTTO`);
typeWriter(`Game 777 LOTTO, 7 Tickets, Pool: ${parseInt(variables['777lottery_pool'])/100000}.-/5439.- LOTTO`);
// Display total supply and minted
typeWriter(`Total Supply: ${parseInt(variables['totalsupply'])/100000}.- LOTTO`);
typeWriter(`Minted: ${parseInt(variables['minted'])/100000}.- LOTTO, (..time limit between mintings is set to 777 seconds for an address)`);
// Display withdrawal fee
typeWriter(`Withdrawal Fee: ${variables['withdrawal_fee']}% (..doesn't apply to Grandmasters)`);
// Display winner address
try {
const asciiValue = variables['winner_address'].match(/../g)
.map(byte => String.fromCharCode(parseInt(byte, 16)))
.join('');
typeWriter(`Latest Winner: ${asciiValue}`);
} catch (e) {
typeWriter(`Winner Address: ${variables['winner_address']} (hex)`);
}
// Display Grandmasters if they exist
for (let i = 7; i >= 1; i--) {
const key = `Grandmaster${i}`;
if (variables[key]) {
try {
const asciiValue = variables[key].match(/../g)
.map(byte => String.fromCharCode(parseInt(byte, 16)))
.join('');
typeWriter(`${key}: ${asciiValue}`);
} catch (e) {
typeWriter(`${key}: ${variables[key]} (hex)`);
}
}
}
}
} else if (response.error) {
console.error("Error in response:", response.error);
typeWriter("Error: " + response.error.message);
}
});
socket.addEventListener("error", function(event) {
console.error("Web socket error:", event);
typed = 0;
typeWriter(" Web socket error: " + event.target.url.toString());
});
socket.addEventListener("close", function(event) {
console.log("Web socket connection closed:", event.code, event.reason);
});
}
// Send data through the web socket
function sendData(data) {
socket.send(JSON.stringify(data));
}
// Modified type writer effect to stack messages
function typeWriter(text) {
const element = document.getElementById("status");
const newMessage = document.createElement("div");
newMessage.textContent = text;
element.insertBefore(newMessage, element.firstChild);
}
// Button handlers
const connectButton = document.getElementById("connectButton");
const getAddressButton = document.getElementById("getAddressButton");
const getBalanceButton = document.getElementById("getBalanceButton");
const getDeroBalanceButton = document.getElementById("getDeroBalanceButton");
const withdrawLottoButton = document.getElementById("withdrawLottoButton");
const mintLottoButton = document.getElementById("mintLottoButton");
const playLotto777Button = document.getElementById("playLotto777Button");
const playLotto77Button = document.getElementById("playLotto77Button");
const playLotto7Button = document.getElementById("playLotto7Button");
const getInfoButton = document.getElementById("getInfoButton");
connectButton.addEventListener("click", function() {
if (connectButton.textContent === "Connect") {
connectWebSocket();
connectButton.textContent = "Disconnect";
getAddressButton.disabled = false;
getBalanceButton.disabled = false;
getDeroBalanceButton.disabled = false;
withdrawLottoButton.disabled = false;
mintLottoButton.disabled = false;
playLotto777Button.disabled = false;
playLotto77Button.disabled = false;
playLotto7Button.disabled = false;
getInfoButton.disabled = false;
} else {
socket.close();
connectButton.textContent = "Connect";
getAddressButton.disabled = true;
getBalanceButton.disabled = true;
getDeroBalanceButton.disabled = true;
withdrawLottoButton.disabled = true;
mintLottoButton.disabled = true;
playLotto777Button.disabled = true;
playLotto77Button.disabled = true;
playLotto7Button.disabled = true;
getInfoButton.disabled = true;
}
});
getAddressButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "1",
method: "GetAddress"
});
});
getBalanceButton.addEventListener("click", function () {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
});
getDeroBalanceButton.addEventListener("click", function () {
currentBalanceRequest = 'DERO';
sendData({
jsonrpc: "2.0",
id: "6",
method: "GetBalance"
});
});
withdrawLottoButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "7",
method: "scinvoke",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Withdraw_My_LOTTO_balance"
}]
}
});
});
mintLottoButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "8",
method: "scinvoke",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "MintLOTTO"
}]
}
});
});
getInfoButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "9",
method: "DERO.GetSC",
params: {
scid: scid,
variables: true
}
});
});
playLotto777Button.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "3",
method: "transfer",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Pay_777_LOTTO__Game_7_Rounds"
}],
transfers: [{
burn: 77700000,
scid: scid
}]
}
});
});
playLotto77Button.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "4",
method: "transfer",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Pay_77_LOTTO__Game_77_Rounds"
}],
transfers: [{
burn: 7700000,
scid: scid
}]
}
});
});
playLotto7Button.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "5",
method: "transfer",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Pay_7_LOTTO__Game_777_Rounds"
}],
transfers: [{
burn: 700000,
scid: scid
}]
}
});
});
</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", "index.html")
31 STORE("descrHdr", "Play LOTTO777 Tool")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "play.lotto777")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "50dcc62161d626a711053942f09ab4f3e3845898f44275ab4202535e7924920")
37 STORE("fileCheckS", "d7cb802326b60f3f96d8f2d85cb1df2e1c818b2d4ed0bc3100fc3303fc421e5")
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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LOTTO777 - Play to Be a Grandmaster</title>
<style>
body {
font-family: "Courier New", Courier, monospace;
background-color: black;
color: white;
}
button {
margin: 5px;
padding: 8px;
}
</style>
</head>
<body>
<div>
<img src="lotto777.svg" style="vertical-align: middle;">
<div style="display: inline;">
<button id="connectButton">Connect</button>
<button id="getAddressButton" disabled>My Address</button>
<button id="getBalanceButton" disabled>My LOTTO Balance</button>
<button id="getDeroBalanceButton" disabled>My DERO Balance</button> Play:
<button id="playLotto777Button" disabled>Ticket 🍀 $LOTTO 777.-</button>
<button id="playLotto77Button" disabled>Ticket 🍀 $LOTTO 77.-</button>
<button id="playLotto7Button" disabled>Ticket 🍀 $LOTTO 7.-</button>
<button id="withdrawLottoButton" disabled>Withdraw 💰 LOTTO</button>
<button id="mintLottoButton" disabled>Mint 🆕 LOTTO</button>
<button id="getInfoButton" disabled>Info</button>
</div>
<div style="display: inline;">
<br><pre style="display: inline; color: green;">P l a y t o B e a G r a n d m a s t e r</pre>
</div>
<div id="status"></div>
<pre id="jsonResult"></pre>
<script>
let response;
let socket;
let address;
let currentBalanceRequest = '';
const scid = "f22bbe5f6527338ace6eb019ebf971721b9cde81b571b45f94f5a0877d0257f6";
// XSWD application data
const applicationData = {
id: "d8533279732943d4317f29a11d491a1d41af5de725a0500d6a02c3605ad8fada",
name: "LOTTO777 Playing Tool",
description: "LOTTO777 on TELA, Playing, Minting, Withdrawal",
url: "http://localhost:" + location.port,
};
// Handle web socket connection and listeners
function connectWebSocket() {
if (document.getElementById("connectButton").textContent === "Disconnect") {
return;
}
socket = new WebSocket("ws://localhost:44326/xswd");
socket.addEventListener("open", function(event) {
console.log("Web socket connection established:", event);
typed = 0;
typeWriter("..allow all connection requests");
sendData(applicationData);
});
socket.addEventListener("message", function(event) {
response = JSON.parse(event.data);
console.log("Response received:", response);
if (response.result) {
const res = response.result;
if (res.address) {
address = res.address;
console.log("Connected address:", address);
connecting = false;
typeWriter(`Address: ${address}`);
} else if (res.unlocked_balance !== undefined) {
const bal = "Balance: " + (res.unlocked_balance / 100000).toFixed(5) + " " + currentBalanceRequest;
console.log(bal);
typeWriter(bal);
} else if (res.txid) {
if (response.id === "8") {
typeWriter("You sent txid: " + res.txid);
setTimeout(() => {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
}, 1000);
} else if (response.id === "7") {
typeWriter("You sent txid: " + res.txid);
setTimeout(() => {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
}, 1000);
} else {
typeWriter("You sent txid: " + res.txid);
setTimeout(() => {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
}, 1000);
}
} else if (response.id === '"9"' && res.stringkeys) {
console.log("Processing Info response");
const variables = res.stringkeys;
typeWriter("🍀 🍀 🍀");
// Display lottery pools
typeWriter(`Game 7 LOTTO, 777 Tickets, Pool: ${parseInt(variables['7lottery_pool'])/100000}.-/5439.- LOTTO`);
typeWriter(`Game 77 LOTTO, 77 Tickets, Pool: ${parseInt(variables['77lottery_pool'])/100000}.-/5929.- LOTTO`);
typeWriter(`Game 777 LOTTO, 7 Tickets, Pool: ${parseInt(variables['777lottery_pool'])/100000}.-/5439.- LOTTO`);
// Display total supply and minted
typeWriter(`Total Supply: ${parseInt(variables['totalsupply'])/100000}.- LOTTO`);
typeWriter(`Minted: ${parseInt(variables['minted'])/100000}.- LOTTO, (..time limit between mintings is set to 777 seconds for an address)`);
// Display withdrawal fee
typeWriter(`Withdrawal Fee: ${variables['withdrawal_fee']}% (..doesn't apply to Grandmasters)`);
// Display winner address
try {
const asciiValue = variables['winner_address'].match(/../g)
.map(byte => String.fromCharCode(parseInt(byte, 16)))
.join('');
typeWriter(`Latest Winner: ${asciiValue}`);
} catch (e) {
typeWriter(`Winner Address: ${variables['winner_address']} (hex)`);
}
// Display Grandmasters if they exist
for (let i = 7; i >= 1; i--) {
const key = `Grandmaster${i}`;
if (variables[key]) {
try {
const asciiValue = variables[key].match(/../g)
.map(byte => String.fromCharCode(parseInt(byte, 16)))
.join('');
typeWriter(`${key}: ${asciiValue}`);
} catch (e) {
typeWriter(`${key}: ${variables[key]} (hex)`);
}
}
}
}
} else if (response.error) {
console.error("Error in response:", response.error);
typeWriter("Error: " + response.error.message);
}
});
socket.addEventListener("error", function(event) {
console.error("Web socket error:", event);
typed = 0;
typeWriter(" Web socket error: " + event.target.url.toString());
});
socket.addEventListener("close", function(event) {
console.log("Web socket connection closed:", event.code, event.reason);
});
}
// Send data through the web socket
function sendData(data) {
socket.send(JSON.stringify(data));
}
// Modified type writer effect to stack messages
function typeWriter(text) {
const element = document.getElementById("status");
const newMessage = document.createElement("div");
newMessage.textContent = text;
element.insertBefore(newMessage, element.firstChild);
}
// Button handlers
const connectButton = document.getElementById("connectButton");
const getAddressButton = document.getElementById("getAddressButton");
const getBalanceButton = document.getElementById("getBalanceButton");
const getDeroBalanceButton = document.getElementById("getDeroBalanceButton");
const withdrawLottoButton = document.getElementById("withdrawLottoButton");
const mintLottoButton = document.getElementById("mintLottoButton");
const playLotto777Button = document.getElementById("playLotto777Button");
const playLotto77Button = document.getElementById("playLotto77Button");
const playLotto7Button = document.getElementById("playLotto7Button");
const getInfoButton = document.getElementById("getInfoButton");
connectButton.addEventListener("click", function() {
if (connectButton.textContent === "Connect") {
connectWebSocket();
connectButton.textContent = "Disconnect";
getAddressButton.disabled = false;
getBalanceButton.disabled = false;
getDeroBalanceButton.disabled = false;
withdrawLottoButton.disabled = false;
mintLottoButton.disabled = false;
playLotto777Button.disabled = false;
playLotto77Button.disabled = false;
playLotto7Button.disabled = false;
getInfoButton.disabled = false;
} else {
socket.close();
connectButton.textContent = "Connect";
getAddressButton.disabled = true;
getBalanceButton.disabled = true;
getDeroBalanceButton.disabled = true;
withdrawLottoButton.disabled = true;
mintLottoButton.disabled = true;
playLotto777Button.disabled = true;
playLotto77Button.disabled = true;
playLotto7Button.disabled = true;
getInfoButton.disabled = true;
}
});
getAddressButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "1",
method: "GetAddress"
});
});
getBalanceButton.addEventListener("click", function () {
currentBalanceRequest = 'LOTTO';
sendData({
jsonrpc: "2.0",
id: "2",
method: "GetBalance",
params: {
"scid": scid
}
});
});
getDeroBalanceButton.addEventListener("click", function () {
currentBalanceRequest = 'DERO';
sendData({
jsonrpc: "2.0",
id: "6",
method: "GetBalance"
});
});
withdrawLottoButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "7",
method: "scinvoke",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Withdraw_My_LOTTO_balance"
}]
}
});
});
mintLottoButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "8",
method: "scinvoke",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "MintLOTTO"
}]
}
});
});
getInfoButton.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "9",
method: "DERO.GetSC",
params: {
scid: scid,
variables: true
}
});
});
playLotto777Button.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "3",
method: "transfer",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Pay_777_LOTTO__Game_7_Rounds"
}],
transfers: [{
burn: 77700000,
scid: scid
}]
}
});
});
playLotto77Button.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "4",
method: "transfer",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Pay_77_LOTTO__Game_77_Rounds"
}],
transfers: [{
burn: 7700000,
scid: scid
}]
}
});
});
playLotto7Button.addEventListener("click", function () {
sendData({
jsonrpc: "2.0",
id: "5",
method: "transfer",
params: {
scid: scid,
ringsize: 2,
sc_rpc: [{
name: "entrypoint",
datatype: "S",
value: "Pay_7_LOTTO__Game_777_Rounds"
}],
transfers: [{
burn: 700000,
scid: scid
}]
}
});
});
</script>
</body>
</html>
*/'] |