SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("var_header_name", "core.js")
31 STORE("var_header_description", "")
32 STORE("var_header_icon", "")
33 STORE("dURL", "")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "/")
36 STORE("fileCheckC", "24dc9c93610d4fd951f1d6f35d23e497b5cdfc84ff48949f76ac43b99bfc12c9")
37 STORE("fileCheckS", "1cfaccb2cd4a76522ca64ada0c57bdc5213818a75c790d876d435ec9cfbf0e00")
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
/*
// DERO Explorer v2.0 - Core Module (State, Utils, Router, Module Loader)
(function() {
'use strict';
// State
const S = {
conn: null, connMode: null, isConnected: false,
networkInfo: null, lastUpdate: null,
currentView: 'dashboard', currentDetail: null,
navHistory: [], historyIndex: -1,
blocksPage: 0, blocksPerPage: 15, txsPage: 0, txsPerPage: 20,
blockCache: new Map(), txCache: new Map(), scCache: new Map(),
modules: {}, modulesLoaded: new Set(),
autoRefresh: true, refreshInterval: 30000,
isLoading: false, searchQuery: ''
};
// Utils
const U = {
fmtDERO: function(a, d) {
if (a == null) return '0.00000';
d = d || 5;
return (a / 1e5).toLocaleString(undefined, { minimumFractionDigits: d, maximumFractionDigits: d });
},
fmtNum: function(n) { return n == null ? '0' : n.toLocaleString(); },
fmtCompact: function(n) {
if (n >= 1e15) return (n / 1e15).toFixed(2) + 'P';
if (n >= 1e12) return (n / 1e12).toFixed(2) + 'T';
if (n >= 1e9) return (n / 1e9).toFixed(2) + 'B';
if (n >= 1e6) return (n / 1e6).toFixed(2) + 'M';
if (n >= 1e3) return (n / 1e3).toFixed(2) + 'K';
return n.toString();
},
fmtHashrate: function(h) {
if (h >= 1e15) return (h / 1e15).toFixed(2) + ' PH/s';
if (h >= 1e12) return (h / 1e12).toFixed(2) + ' TH/s';
if (h >= 1e9) return (h / 1e9).toFixed(2) + ' GH/s';
if (h >= 1e6) return (h / 1e6).toFixed(2) + ' MH/s';
if (h >= 1e3) return (h / 1e3).toFixed(2) + ' KH/s';
return h.toFixed(2) + ' H/s';
},
difficultyToHashrate: function(d) { return d / 18; },
fmtBytes: function(b) {
if (b == null || isNaN(b)) return '--';
if (b === 0) return '0 B';
var k = 1024, s = ['B', 'KB', 'MB', 'GB'];
var i = Math.floor(Math.log(b) / Math.log(k));
return parseFloat((b / Math.pow(k, i)).toFixed(2)) + ' ' + s[i];
},
fmtAge: function(t) {
var ms = t > 1e12 ? t : t * 1000;
var sec = Math.floor((Date.now() - ms) / 1000);
if (sec < 0) return 'just now';
if (sec < 60) return sec + 's ago';
if (sec < 3600) { var m = Math.floor(sec / 60); return m + 'm ' + (sec % 60) + 's ago'; }
if (sec < 86400) { var h = Math.floor(sec / 3600); return h + 'h ' + Math.floor((sec % 3600) / 60) + 'm ago'; }
return Math.floor(sec / 86400) + 'd ' + Math.floor((sec % 86400) / 3600) + 'h ago';
},
fmtDate: function(t) {
var ms = t > 1e12 ? t : t * 1000;
return new Date(ms).toISOString().replace('T', ' ').split('.')[0];
},
fmtLocalTime: function(t) {
var ms = t > 1e12 ? t : t * 1000;
return new Date(ms).toLocaleString();
},
truncHash: function(h, s, e) {
if (!h) return '';
h = String(h); s = s || 8; e = e || 6;
if (h.length <= s + e + 3) return h;
if (e === 0) return h.slice(0, s) + '...';
return h.slice(0, s) + '...' + h.slice(-e);
},
isValidHash: function(s) { return /^[a-fA-F0-9]{64}$/.test(s); },
isValidAddr: function(s) { return /^dero1[a-z0-9]{58,}$/i.test(s); },
isNumeric: function(s) { return /^\d+$/.test(s); },
genId: function() { return Date.now() + '-' + Math.random().toString(36).substr(2, 9); },
debounce: function(fn, w) {
var t; return function() { var a = arguments, c = this; clearTimeout(t); t = setTimeout(function() { fn.apply(c, a); }, w); };
},
clone: function(o) { return JSON.parse(JSON.stringify(o)); },
escHtml: function(s) { var d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
};
// Compatibility aliases
U.formatDERO = U.fmtDERO;
U.formatNumber = U.fmtNum;
U.formatCompact = U.fmtCompact;
U.formatHashrate = U.fmtHashrate;
U.formatBytes = U.fmtBytes;
U.formatAge = U.fmtAge;
U.formatDate = U.fmtDate;
U.formatLocalTime = U.fmtLocalTime;
U.truncateHash = U.truncHash;
U.escapeHtml = U.escHtml;
U.generateId = U.genId;
// Router
var R = {
routes: { '': 'dashboard', 'dashboard': 'dashboard', 'blocks': 'blocks', 'block': 'blockDetail', 'pool': 'pool', 'tx': 'txDetail', 'contracts': 'contracts', 'sc': 'scDetail', 'tools': 'tools', 'search': 'search' },
init: function() {
var self = this;
window.addEventListener('hashchange', function() { self.handleRoute(); });
this.handleRoute();
},
handleRoute: function() {
var hash = window.location.hash.slice(1);
var parts = hash.split('/'), route = parts[0], param = parts.slice(1).join('/');
var view = this.routes[route] || 'dashboard';
S.currentView = view;
S.currentDetail = param ? { type: route, id: param } : null;
this.updateNavUI(route || 'dashboard');
this.renderView(view, param);
this.addToHistory(hash);
},
navigate: function(r) { window.location.hash = r; },
goToBlock: function(h) { this.navigate('block/' + h); },
goToTx: function(t) { this.navigate('tx/' + t); },
goToSC: function(s) { this.navigate('sc/' + s); },
goBack: function() {
if (S.historyIndex > 0) { S.historyIndex--; window.location.hash = S.navHistory[S.historyIndex] || ''; }
else this.navigate('dashboard');
},
goHome: function() { this.navigate('dashboard'); },
addToHistory: function(r) {
if (S.navHistory[S.historyIndex] === r) return;
S.navHistory = S.navHistory.slice(0, S.historyIndex + 1);
S.navHistory.push(r);
S.historyIndex = S.navHistory.length - 1;
if (S.navHistory.length > 50) { S.navHistory.shift(); S.historyIndex--; }
},
updateNavUI: function(active) {
document.querySelectorAll('.nav-btn').forEach(function(btn) {
btn.classList.toggle('active', btn.dataset.view === active);
});
},
renderView: function(view, param) {
document.querySelectorAll('[id^="view-"]').forEach(function(el) { el.classList.add('hidden'); });
var el = document.getElementById('view-' + view);
if (el) el.classList.remove('hidden');
window.dispatchEvent(new CustomEvent('explorer:viewChange', { detail: { view: view, param: param } }));
}
};
// Module Loader
var M = {
load: async function(name) {
if (S.modulesLoaded.has(name)) return S.modules[name];
try {
var resp = await fetch(name + '.js?v=' + Date.now());
if (!resp.ok) throw new Error('HTTP ' + resp.status);
var code = await resp.text();
var mod = new Function('DeroExplorer', code + '\nreturn typeof module !== "undefined" ? module : null;')(window.DeroExplorer);
if (mod) {
S.modules[name] = mod;
S.modulesLoaded.add(name);
if (typeof mod.init === 'function') await mod.init();
}
return mod;
} catch (e) { return null; }
},
loadMultiple: async function(names) { return Promise.all(names.map(function(n) { return M.load(n); })); },
get: function(name) { return S.modules[name] || null; }
};
// Initialize
async function init() {
R.init();
var conn = await M.load('connectivity');
if (conn) {
var ok = await conn.initialize();
if (ok) {
await M.loadMultiple(['blocks', 'transactions', 'contracts']);
window.dispatchEvent(new CustomEvent('explorer:connected'));
}
}
}
// Global exports
window.DeroExplorer = { state: S, utils: U, router: R, modules: M, ui: null, search: null, initialize: init };
window.navigate = function(v) { R.navigate(v); };
window.goBack = function() { R.goBack(); };
window.goHome = function() { R.goHome(); };
window.viewBlock = function(h) { R.goToBlock(h); };
window.viewTx = function(t) { R.goToTx(t); };
window.viewSC = function(s) { R.goToSC(s); };
// Init on DOM ready
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
else init();
})();
*/ |
| 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("var_header_name", "core.js")
31 STORE("var_header_description", "")
32 STORE("var_header_icon", "")
33 STORE("dURL", "")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "/")
36 STORE("fileCheckC", "24dc9c93610d4fd951f1d6f35d23e497b5cdfc84ff48949f76ac43b99bfc12c9")
37 STORE("fileCheckS", "1cfaccb2cd4a76522ca64ada0c57bdc5213818a75c790d876d435ec9cfbf0e00")
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
/*
// DERO Explorer v2.0 - Core Module (State, Utils, Router, Module Loader)
(function() {
'use strict';
// State
const S = {
conn: null, connMode: null, isConnected: false,
networkInfo: null, lastUpdate: null,
currentView: 'dashboard', currentDetail: null,
navHistory: [], historyIndex: -1,
blocksPage: 0, blocksPerPage: 15, txsPage: 0, txsPerPage: 20,
blockCache: new Map(), txCache: new Map(), scCache: new Map(),
modules: {}, modulesLoaded: new Set(),
autoRefresh: true, refreshInterval: 30000,
isLoading: false, searchQuery: ''
};
// Utils
const U = {
fmtDERO: function(a, d) {
if (a == null) return '0.00000';
d = d || 5;
return (a / 1e5).toLocaleString(undefined, { minimumFractionDigits: d, maximumFractionDigits: d });
},
fmtNum: function(n) { return n == null ? '0' : n.toLocaleString(); },
fmtCompact: function(n) {
if (n >= 1e15) return (n / 1e15).toFixed(2) + 'P';
if (n >= 1e12) return (n / 1e12).toFixed(2) + 'T';
if (n >= 1e9) return (n / 1e9).toFixed(2) + 'B';
if (n >= 1e6) return (n / 1e6).toFixed(2) + 'M';
if (n >= 1e3) return (n / 1e3).toFixed(2) + 'K';
return n.toString();
},
fmtHashrate: function(h) {
if (h >= 1e15) return (h / 1e15).toFixed(2) + ' PH/s';
if (h >= 1e12) return (h / 1e12).toFixed(2) + ' TH/s';
if (h >= 1e9) return (h / 1e9).toFixed(2) + ' GH/s';
if (h >= 1e6) return (h / 1e6).toFixed(2) + ' MH/s';
if (h >= 1e3) return (h / 1e3).toFixed(2) + ' KH/s';
return h.toFixed(2) + ' H/s';
},
difficultyToHashrate: function(d) { return d / 18; },
fmtBytes: function(b) {
if (b == null || isNaN(b)) return '--';
if (b === 0) return '0 B';
var k = 1024, s = ['B', 'KB', 'MB', 'GB'];
var i = Math.floor(Math.log(b) / Math.log(k));
return parseFloat((b / Math.pow(k, i)).toFixed(2)) + ' ' + s[i];
},
fmtAge: function(t) {
var ms = t > 1e12 ? t : t * 1000;
var sec = Math.floor((Date.now() - ms) / 1000);
if (sec < 0) return 'just now';
if (sec < 60) return sec + 's ago';
if (sec < 3600) { var m = Math.floor(sec / 60); return m + 'm ' + (sec % 60) + 's ago'; }
if (sec < 86400) { var h = Math.floor(sec / 3600); return h + 'h ' + Math.floor((sec % 3600) / 60) + 'm ago'; }
return Math.floor(sec / 86400) + 'd ' + Math.floor((sec % 86400) / 3600) + 'h ago';
},
fmtDate: function(t) {
var ms = t > 1e12 ? t : t * 1000;
return new Date(ms).toISOString().replace('T', ' ').split('.')[0];
},
fmtLocalTime: function(t) {
var ms = t > 1e12 ? t : t * 1000;
return new Date(ms).toLocaleString();
},
truncHash: function(h, s, e) {
if (!h) return '';
h = String(h); s = s || 8; e = e || 6;
if (h.length <= s + e + 3) return h;
if (e === 0) return h.slice(0, s) + '...';
return h.slice(0, s) + '...' + h.slice(-e);
},
isValidHash: function(s) { return /^[a-fA-F0-9]{64}$/.test(s); },
isValidAddr: function(s) { return /^dero1[a-z0-9]{58,}$/i.test(s); },
isNumeric: function(s) { return /^\d+$/.test(s); },
genId: function() { return Date.now() + '-' + Math.random().toString(36).substr(2, 9); },
debounce: function(fn, w) {
var t; return function() { var a = arguments, c = this; clearTimeout(t); t = setTimeout(function() { fn.apply(c, a); }, w); };
},
clone: function(o) { return JSON.parse(JSON.stringify(o)); },
escHtml: function(s) { var d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
};
// Compatibility aliases
U.formatDERO = U.fmtDERO;
U.formatNumber = U.fmtNum;
U.formatCompact = U.fmtCompact;
U.formatHashrate = U.fmtHashrate;
U.formatBytes = U.fmtBytes;
U.formatAge = U.fmtAge;
U.formatDate = U.fmtDate;
U.formatLocalTime = U.fmtLocalTime;
U.truncateHash = U.truncHash;
U.escapeHtml = U.escHtml;
U.generateId = U.genId;
// Router
var R = {
routes: { '': 'dashboard', 'dashboard': 'dashboard', 'blocks': 'blocks', 'block': 'blockDetail', 'pool': 'pool', 'tx': 'txDetail', 'contracts': 'contracts', 'sc': 'scDetail', 'tools': 'tools', 'search': 'search' },
init: function() {
var self = this;
window.addEventListener('hashchange', function() { self.handleRoute(); });
this.handleRoute();
},
handleRoute: function() {
var hash = window.location.hash.slice(1);
var parts = hash.split('/'), route = parts[0], param = parts.slice(1).join('/');
var view = this.routes[route] || 'dashboard';
S.currentView = view;
S.currentDetail = param ? { type: route, id: param } : null;
this.updateNavUI(route || 'dashboard');
this.renderView(view, param);
this.addToHistory(hash);
},
navigate: function(r) { window.location.hash = r; },
goToBlock: function(h) { this.navigate('block/' + h); },
goToTx: function(t) { this.navigate('tx/' + t); },
goToSC: function(s) { this.navigate('sc/' + s); },
goBack: function() {
if (S.historyIndex > 0) { S.historyIndex--; window.location.hash = S.navHistory[S.historyIndex] || ''; }
else this.navigate('dashboard');
},
goHome: function() { this.navigate('dashboard'); },
addToHistory: function(r) {
if (S.navHistory[S.historyIndex] === r) return;
S.navHistory = S.navHistory.slice(0, S.historyIndex + 1);
S.navHistory.push(r);
S.historyIndex = S.navHistory.length - 1;
if (S.navHistory.length > 50) { S.navHistory.shift(); S.historyIndex--; }
},
updateNavUI: function(active) {
document.querySelectorAll('.nav-btn').forEach(function(btn) {
btn.classList.toggle('active', btn.dataset.view === active);
});
},
renderView: function(view, param) {
document.querySelectorAll('[id^="view-"]').forEach(function(el) { el.classList.add('hidden'); });
var el = document.getElementById('view-' + view);
if (el) el.classList.remove('hidden');
window.dispatchEvent(new CustomEvent('explorer:viewChange', { detail: { view: view, param: param } }));
}
};
// Module Loader
var M = {
load: async function(name) {
if (S.modulesLoaded.has(name)) return S.modules[name];
try {
var resp = await fetch(name + '.js?v=' + Date.now());
if (!resp.ok) throw new Error('HTTP ' + resp.status);
var code = await resp.text();
var mod = new Function('DeroExplorer', code + '\nreturn typeof module !== "undefined" ? module : null;')(window.DeroExplorer);
if (mod) {
S.modules[name] = mod;
S.modulesLoaded.add(name);
if (typeof mod.init === 'function') await mod.init();
}
return mod;
} catch (e) { return null; }
},
loadMultiple: async function(names) { return Promise.all(names.map(function(n) { return M.load(n); })); },
get: function(name) { return S.modules[name] || null; }
};
// Initialize
async function init() {
R.init();
var conn = await M.load('connectivity');
if (conn) {
var ok = await conn.initialize();
if (ok) {
await M.loadMultiple(['blocks', 'transactions', 'contracts']);
window.dispatchEvent(new CustomEvent('explorer:connected'));
}
}
}
// Global exports
window.DeroExplorer = { state: S, utils: U, router: R, modules: M, ui: null, search: null, initialize: init };
window.navigate = function(v) { R.navigate(v); };
window.goBack = function() { R.goBack(); };
window.goHome = function() { R.goHome(); };
window.viewBlock = function(h) { R.goToBlock(h); };
window.viewTx = function(t) { R.goToTx(t); };
window.viewSC = function(s) { R.goToSC(s); };
// Init on DOM ready
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
else init();
})();
*/'] |