SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "transactions-helpers.js")
31 STORE("descrHdr", "Transaction utility functions")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "c424ddd66566822bf4edbd680c68295541428c0fe5059479ccca5d81ade9450")
37 STORE("fileCheckS", "1735a63a7ab1750d957592e2708b1726b1cdeaea154e342753103d38e6a301d4")
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
/*
({
name: 'transactions-helpers',
version: '1.0.0',
calculateRingSize(txData) {
if (!txData || !txData.vin || txData.vin.length === 0) return 'Coinbase';
const vin = txData.vin[0];
if (vin && vin.key && vin.key.key_offsets) {
return vin.key.key_offsets.length;
} else if (vin && vin.key && vin.key.k_image) {
return 1;
} else if (txData.rct_signatures && txData.rct_signatures.MGs && txData.rct_signatures.MGs.length > 0) {
const mg = txData.rct_signatures.MGs[0];
return mg.ss ? mg.ss.length : mg.cc ? mg.cc.length : txData.vin.length;
}
return txData.vin.length;
},
determineTxType(txData, ringSize) {
if (ringSize === 'Coinbase') return 'Coinbase';
if (txData.scdata) return 'Smart Contract';
return 'Transfer';
},
getRingColor(ringSize) {
if (ringSize === 'Coinbase') return '#fbbf24';
if (typeof ringSize === 'number') {
if (ringSize >= 16) return '#4ade80';
if (ringSize >= 8) return '#52c8db';
if (ringSize >= 2) return '#fbbf24';
return '#ef4444';
}
return '#888';
},
getRingBorderColor(ringSize) {
if (ringSize === 'Coinbase') return 'rgba(251,191,36,0.3)';
if (typeof ringSize === 'number') {
if (ringSize >= 16) return 'rgba(74,222,128,0.3)';
if (ringSize >= 8) return 'rgba(82,200,219,0.3)';
if (ringSize >= 2) return 'rgba(251,191,36,0.3)';
return 'rgba(239,68,68,0.3)';
}
return 'rgba(136,136,136,0.3)';
},
formatAge(milliseconds) {
if (milliseconds < 0) return 'Future';
const seconds = Math.floor(milliseconds / 1000);
if (seconds < 60) return `${seconds} seconds ago`;
const minutes = Math.floor(seconds / 60);
if (minutes < 60) return `${minutes} minutes ago`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return `${hours} hours ago`;
const days = Math.floor(hours / 24);
if (days < 30) return `${days} days ago`;
const months = Math.floor(days / 30);
if (months < 12) return `${months} months ago`;
const years = Math.floor(months / 12);
return `${years} years ago`;
},
extractPaymentId(extra) {
if (!extra || !Array.isArray(extra)) return null;
// Look for payment ID in extra field
for (let i = 0; i < extra.length; i++) {
const item = extra[i];
if (typeof item === 'object' && item.tag) {
if (item.tag === 1 || item.tag === 2) {
return item.data || item.value;
}
}
}
const extraStr = JSON.stringify(extra);
const paymentIdMatch = extraStr.match(/[0-9a-fA-F]{16,64}/);
return paymentIdMatch ? paymentIdMatch[0] : null;
}
})
*/ |
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", "transactions-helpers.js")
31 STORE("descrHdr", "Transaction utility functions")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "c424ddd66566822bf4edbd680c68295541428c0fe5059479ccca5d81ade9450")
37 STORE("fileCheckS", "1735a63a7ab1750d957592e2708b1726b1cdeaea154e342753103d38e6a301d4")
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
/*
({
name: 'transactions-helpers',
version: '1.0.0',
calculateRingSize(txData) {
if (!txData || !txData.vin || txData.vin.length === 0) return 'Coinbase';
const vin = txData.vin[0];
if (vin && vin.key && vin.key.key_offsets) {
return vin.key.key_offsets.length;
} else if (vin && vin.key && vin.key.k_image) {
return 1;
} else if (txData.rct_signatures && txData.rct_signatures.MGs && txData.rct_signatures.MGs.length > 0) {
const mg = txData.rct_signatures.MGs[0];
return mg.ss ? mg.ss.length : mg.cc ? mg.cc.length : txData.vin.length;
}
return txData.vin.length;
},
determineTxType(txData, ringSize) {
if (ringSize === 'Coinbase') return 'Coinbase';
if (txData.scdata) return 'Smart Contract';
return 'Transfer';
},
getRingColor(ringSize) {
if (ringSize === 'Coinbase') return '#fbbf24';
if (typeof ringSize === 'number') {
if (ringSize >= 16) return '#4ade80';
if (ringSize >= 8) return '#52c8db';
if (ringSize >= 2) return '#fbbf24';
return '#ef4444';
}
return '#888';
},
getRingBorderColor(ringSize) {
if (ringSize === 'Coinbase') return 'rgba(251,191,36,0.3)';
if (typeof ringSize === 'number') {
if (ringSize >= 16) return 'rgba(74,222,128,0.3)';
if (ringSize >= 8) return 'rgba(82,200,219,0.3)';
if (ringSize >= 2) return 'rgba(251,191,36,0.3)';
return 'rgba(239,68,68,0.3)';
}
return 'rgba(136,136,136,0.3)';
},
formatAge(milliseconds) {
if (milliseconds < 0) return 'Future';
const seconds = Math.floor(milliseconds / 1000);
if (seconds < 60) return `${seconds} seconds ago`;
const minutes = Math.floor(seconds / 60);
if (minutes < 60) return `${minutes} minutes ago`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return `${hours} hours ago`;
const days = Math.floor(hours / 24);
if (days < 30) return `${days} days ago`;
const months = Math.floor(days / 30);
if (months < 12) return `${months} months ago`;
const years = Math.floor(months / 12);
return `${years} years ago`;
},
extractPaymentId(extra) {
if (!extra || !Array.isArray(extra)) return null;
// Look for payment ID in extra field
for (let i = 0; i < extra.length; i++) {
const item = extra[i];
if (typeof item === 'object' && item.tag) {
if (item.tag === 1 || item.tag === 2) {
return item.data || item.value;
}
}
}
const extraStr = JSON.stringify(extra);
const paymentIdMatch = extraStr.match(/[0-9a-fA-F]{16,64}/);
return paymentIdMatch ? paymentIdMatch[0] : null;
}
})
*/'] |