SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "index.html")
31 STORE("descrHdr", "NFA checker")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "weguy.nfa-tool.tela")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "2ee33608f5cc593565a1fd678c721556e41fe1483cb768b36fafa15af7313ace")
37 STORE("fileCheckS", "1f6dd47301733fb1dc40a36642ac234b2d6365c7a943c91db6129c7f4b54a90b")
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
/*
<html lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<style>
#image {float:left;}
#image img{max-width:100%;height:auto;}
table#info{width:100%;}
table#info, table#info th, table#info td {
border: 1px solid black;
border-collapse: collapse;
}
table#info td:nth-child(2) { word-break: break-all;}
#sccode{overflow-x:auto;}
</style>
<h1>Enter your NFA SCID to load the details</h1>
<form id="lookup">
<input type="text" name="scid" placeholder="Enter SCID">
<button type="submit">Check NFA</button>
</form>
<div id="image"></div>
<table id="info"></table>
<div id="sccode"></div>
<script>
function lookup(scid){
let fields = [];
fields.push({"field":"descrHdr","value":""});
fields.push({"field":"typeHdr","value":""});
fields.push({"field":"iconURLHdr","value":""});
fields.push({"field":"tagsHdr","value":""});
fields.push({"field":"fileCheckC","value":""});
fields.push({"field":"fileCheckS","value":""});
fields.push({"field":"fileURL","value":""});
fields.push({"field":"fileSignURL","value":""});
fields.push({"field":"coverURL","value":""});
fields.push({"field":"collection","value":""});
let socket = new WebSocket("ws://node.derofoundation.org:11012/ws");
let preflight = true;
socket.onopen = function(e) {
socket.send('{"jsonrpc": "2.0", "id": "1", "method": "DERO.GetBlock", "params": {"height": 420 }}');
};
var lastObj;
socket.onmessage = function(event) {
lastObj = JSON.parse(event.data);
if(typeof lastObj.result === 'undefined' ){
alert("Error Retrieving Smart Contract");
return;
}
if(typeof lastObj.result.block_header === 'undefined' && preflight){
alert("Service Temporarily Unavailable");
return;
}else if(preflight){
preflight = false;
return getSC(scid);
}
if(typeof lastObj.result.code !== 'undefined'){
if(lastObj.result.code.includes("Function BuyItNow() Uint64")){
fields.forEach((pair,index) => {
if(lastObj.result.stringkeys[pair.field] !== 'undefined'){
pair.value = hexToUtf8(lastObj.result.stringkeys[pair.field]);
}
});
}
if(fields[0].value !=""){
render(lastObj.result.code);
}
}
socket.close();
};
function hexToUtf8(s)
{
return decodeURIComponent(
s.replace(/\s+/g, '') // remove spaces
.replace(/[0-9a-f]{2}/g, '%$&') // add '%' before each 2 characters
);
}
function getSC(sc){
let json = {};
json.jsonrpc = "2.0";
json.id = "1";
json.method = "DERO.GetSC";
json.params = {};
json.params.scid = sc;
json.params.code = true;
json.params.variables = true;
json = JSON.stringify(json);
socket.send(json);
}
function render(sc_code){
let coverField = fields.filter(f => f.field === 'coverURL');
let img_url = (coverField[0].value.indexOf('://') === -1) ? 'https://' + coverField[0].value : coverField[0].value ;
document.getElementById("image").innerHTML = '<img onerror="alert(\'Error Loading Image\')" src="'+img_url+'">';
fields.forEach((pair,index) => {
if(pair.field !== 'coverURL'){
let tr = document.createElement("tr");
let tdf = document.createElement("td");
let tdv = document.createElement("td");
tdf.appendChild(document.createTextNode(pair.field));
tdv.appendChild(document.createTextNode(pair.value));
tr.appendChild(tdf);
tr.appendChild(tdv);
// add the text node to the newly created div
document.getElementById("info").appendChild(tr);
}
});
let pre = document.createElement("pre");
pre.appendChild(document.createTextNode(sc_code));
document.getElementById("sccode").appendChild(pre);
}
}
const form = document.getElementById('lookup');
form.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the default form submission behavior
scid = form.elements.scid.value; // Get the input value
lookup(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", "NFA checker")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "weguy.nfa-tool.tela")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "2ee33608f5cc593565a1fd678c721556e41fe1483cb768b36fafa15af7313ace")
37 STORE("fileCheckS", "1f6dd47301733fb1dc40a36642ac234b2d6365c7a943c91db6129c7f4b54a90b")
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
/*
<html lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<style>
#image {float:left;}
#image img{max-width:100%;height:auto;}
table#info{width:100%;}
table#info, table#info th, table#info td {
border: 1px solid black;
border-collapse: collapse;
}
table#info td:nth-child(2) { word-break: break-all;}
#sccode{overflow-x:auto;}
</style>
<h1>Enter your NFA SCID to load the details</h1>
<form id="lookup">
<input type="text" name="scid" placeholder="Enter SCID">
<button type="submit">Check NFA</button>
</form>
<div id="image"></div>
<table id="info"></table>
<div id="sccode"></div>
<script>
function lookup(scid){
let fields = [];
fields.push({"field":"descrHdr","value":""});
fields.push({"field":"typeHdr","value":""});
fields.push({"field":"iconURLHdr","value":""});
fields.push({"field":"tagsHdr","value":""});
fields.push({"field":"fileCheckC","value":""});
fields.push({"field":"fileCheckS","value":""});
fields.push({"field":"fileURL","value":""});
fields.push({"field":"fileSignURL","value":""});
fields.push({"field":"coverURL","value":""});
fields.push({"field":"collection","value":""});
let socket = new WebSocket("ws://node.derofoundation.org:11012/ws");
let preflight = true;
socket.onopen = function(e) {
socket.send('{"jsonrpc": "2.0", "id": "1", "method": "DERO.GetBlock", "params": {"height": 420 }}');
};
var lastObj;
socket.onmessage = function(event) {
lastObj = JSON.parse(event.data);
if(typeof lastObj.result === 'undefined' ){
alert("Error Retrieving Smart Contract");
return;
}
if(typeof lastObj.result.block_header === 'undefined' && preflight){
alert("Service Temporarily Unavailable");
return;
}else if(preflight){
preflight = false;
return getSC(scid);
}
if(typeof lastObj.result.code !== 'undefined'){
if(lastObj.result.code.includes("Function BuyItNow() Uint64")){
fields.forEach((pair,index) => {
if(lastObj.result.stringkeys[pair.field] !== 'undefined'){
pair.value = hexToUtf8(lastObj.result.stringkeys[pair.field]);
}
});
}
if(fields[0].value !=""){
render(lastObj.result.code);
}
}
socket.close();
};
function hexToUtf8(s)
{
return decodeURIComponent(
s.replace(/\s+/g, '') // remove spaces
.replace(/[0-9a-f]{2}/g, '%$&') // add '%' before each 2 characters
);
}
function getSC(sc){
let json = {};
json.jsonrpc = "2.0";
json.id = "1";
json.method = "DERO.GetSC";
json.params = {};
json.params.scid = sc;
json.params.code = true;
json.params.variables = true;
json = JSON.stringify(json);
socket.send(json);
}
function render(sc_code){
let coverField = fields.filter(f => f.field === 'coverURL');
let img_url = (coverField[0].value.indexOf('://') === -1) ? 'https://' + coverField[0].value : coverField[0].value ;
document.getElementById("image").innerHTML = '<img onerror="alert(\'Error Loading Image\')" src="'+img_url+'">';
fields.forEach((pair,index) => {
if(pair.field !== 'coverURL'){
let tr = document.createElement("tr");
let tdf = document.createElement("td");
let tdv = document.createElement("td");
tdf.appendChild(document.createTextNode(pair.field));
tdv.appendChild(document.createTextNode(pair.value));
tr.appendChild(tdf);
tr.appendChild(tdv);
// add the text node to the newly created div
document.getElementById("info").appendChild(tr);
}
});
let pre = document.createElement("pre");
pre.appendChild(document.createTextNode(sc_code));
document.getElementById("sccode").appendChild(pre);
}
}
const form = document.getElementById('lookup');
form.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the default form submission behavior
scid = form.elements.scid.value; // Get the input value
lookup(scid);
});
</script>
</body>
</html>
*/'] |