SC Arguments: [Name:SC_ACTION Type:uint64 Value:'0' Name:SC_ID Type:hash Value:'a2f4961742e4225fdd767ad90a8749b5a9afce1ece419cf9a9a9d3c34e65f8fb' Name:content Type:string Value:'function listener(event) {
let lastObj = JSON.parse(event.data);
let res = lastObj.result;
if (res.gasstorage) { // Getting Estimate
let result = confirm("Storage cost: " + res.gasstorage + " . " + mode + " SC?");
if (result) {
if(mode === "update"){
update(res.gasstorage);
}
} else {
console.log("Action canceled.");
socket.removeEventListener("message", listener);
}
}else if (res.txid) {
document.getElementById("output").innerHTML = res.txid;
alert(res.txid);
socket.removeEventListener("message", listener);
}
};
function socketSend(data){
socket.addEventListener("message", listener);
sendData(data);
}
if(typeof installJSON == 'undefined') {
mode = "";
}
mode = "install";
var scidInput = document.getElementById('scid');
var signerInput = document.getElementById('signer');
var text = document.getElementById('smartcontract');
var updateButton = document.getElementById('update');
var deployButton = document.getElementById('deploy');
//Install JSON
if(typeof installJSON == 'undefined') {
installJSON = {};
}
installJSON.jsonrpc = "2.0";
installJSON.id = "1";
installJSON.method = "transfer";
installJSON.params = {};
installJSON.params.fees = 0;
installJSON.params.transfers = [{
destination: "dero1qykyta6ntpd27nl0yq4xtzaf4ls6p5e9pqu0k2x4x3pqq5xavjsdxqgny8270",
amount:0,
Burn:0,
payload_rpc:[]
}];
installJSON.params.sc = "";
installJSON.params.sc_value = 0;
installJSON.params.sc_rpc = [];
installJSON.params.ringsize = 2;
//Install function
function install(fees){
installJSON.params.sc = text.value;
socketSend(installJSON);
}
deployButton.addEventListener('click', function(event) {
let result = confirm("Cost estimate: "+(text.value.length * 2) +", Install SC?");
if (result) {
install();
} else {
console.log("Action canceled.");
}
});
//Update
if(typeof quoteJSON == 'undefined') {
quoteJSON = {};
}
function buildQuoteJSON(){
quoteJSON = {};
quoteJSON.jsonrpc = "2.0";
quoteJSON.id = "1";
quoteJSON.method = "DERO.GetGasEstimate";
quoteJSON.params = {};
quoteJSON.params.transfers = [{
destination: "dero1qykyta6ntpd27nl0yq4xtzaf4ls6p5e9pqu0k2x4x3pqq5xavjsdxqgny8270",
amount:0,
Burn:0,
payload_rpc:[]
}];
quoteJSON.params.sc = "";
quoteJSON.params.sc_value = 0;
quoteJSON.params.sc_rpc = [];
quoteJSON.params.ringsize = 2;
}
updateButton.addEventListener('click', function(event) {
buildQuoteJSON();
mode = 'update';
quoteJSON.params.signer = signerInput.value;
quoteJSON.params.SC_RPC = [
{Name: "SC_ACTION", DataType: "U", Value: 0},
{Name: "SC_ID", DataType: "H", Value: scidInput.value},
{Name: "entrypoint", DataType: "S", Value: "UpdateCode"},
{Name: "code", DataType: "S", Value: text.value}
];
socketSend(quoteJSON);
});
//Update Code JSON
if(typeof updateJSON == 'undefined') {
updateJSON = {};
}
updateJSON.jsonrpc = "2.0";
updateJSON.id = "1";
updateJSON.method = "transfer";
updateJSON.params = {};
updateJSON.params.fees = 0;
updateJSON.params.transfers = [{
destination: "dero1qykyta6ntpd27nl0yq4xtzaf4ls6p5e9pqu0k2x4x3pqq5xavjsdxqgny8270",
amount:0,
Burn:0,
payload_rpc:[]
}];
updateJSON.params.sc_value = 0;
updateJSON.params.sc_rpc = [];
updateJSON.params.ringsize = 2;
updateJSON.params.signer = "dero1qykyta6ntpd27nl0yq4xtzaf4ls6p5e9pqu0k2x4x3pqq5xavjsdxqgny8270";
//Update Code function
function update(fees){
updateJSON.params.signer = signerInput.value;
updateJSON.params.SC_RPC = [
{Name: "SC_ACTION", DataType: "U", Value: 0},
{Name: "SC_ID", DataType: "H", Value: scidInput.value},
{Name: "entrypoint", DataType: "S", Value: "UpdateCode"},
{Name: "code", DataType: "S", Value: text.value}
];
updateJSON.params.fees = fees;
socketSend(updateJSON);
}
' Name:entrypoint Type:string Value:'StoreItem' Name:name Type:string Value:'sclauncher.js'] |