This library allows you to connect to existing ql-nodes and use their API to interact with the Qubic Lite protocol.
<!DOCTYPE html>
<html>
<head>
...
<script type="text/javascript" src="../js/qlite.js"></script>
</head>
<body> ... </body>
</html>
const QLITE = new Qlite('https://qlnode.org:17733');
var my_qubic = "GAPGBVIBDKTGZ9BVLCZYWPZAFMIXBDLCUTXOC9NEJ9HGDKZYGRPQVIHMZXRXCDLZIFXGECZBFSTTNA999";
QLITE.qubic_read(function(res, err) {
if(err) // something went wrong
console.log(err);
else // everything is fine
console.log("qubic code: " + res['code']);
}, my_qubic);
- App
- Qubic
- IAM
- General
- Oracle
Gives details about this ql-node.
name | type | description |
---|---|---|
callback |
function |
QLITE.node_info(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
});
{"duration":42,"iota_node":"https://nodes.devnet.thetangle.org:443","success":true,"testnet":true,"version":"0.5.0"}
Changes the IOTA full node used to interact with the tangle.
name | type | description |
---|---|---|
callback |
function |
|
node_address |
string (nodeaddress) |
address of any IOTA full node api (mainnet or testnet, depending on which ql-nodes you want to be able to interact with) |
mwm (opt.) |
int (integer{9-14}) |
min weight magnitude: use 9 when connecting to a testnet node, otherwise use 14 |
QLITE.change_node(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'https://node.example.org:14265', 14);
{"duration":42,"success":true}
Determines the quorum based result (consensus) of a qubic's epoch.
name | type | description |
---|---|---|
callback |
function |
|
qubic |
string (trytes{81}) |
qubic to fetch from |
epoch |
int (integer{0-2147483647}) |
epoch to fetch |
epoch_max (opt.) |
int (integer{-1-2147483647}) |
if used will fetch all epochs from 'epoch' up to this value |
QLITE.fetch_epoch(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'SDTMJ9ZYYTLONLFNFGQVVAY99CHQ9TKOTFIZXENKZHOPQTCSVWGGSBNH9PYHQWPUSAOXWT9ZRS9H9SADG', 4, 7);
{"last_completed_epoch":815,"duration":42,"fetched_epochs":[{"result":"49","quorum":2,"epoch":7,"quorum_max":3},{"quorum":1,"epoch":8,"quorum_max":3},{"result":"81","quorum":2,"epoch":9,"quorum_max":3}],"success":true}
Transforms an entity (iam stream, qubic or oracle) into a string that can be imported again.
name | type | description |
---|---|---|
callback |
function |
|
id |
string (trytes{81}) |
id of the entity to export |
QLITE.export(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'CZLOLNIRWAONKQLQMFAQMRDMONALUXECDFPUSGPSMWUDFMVVIDNVOQPEUHQOZUTQEOYLSUGXIVLRRA9YP');
{"duration":42,"success":true,"export":"q_ISDWNHXQLFTRTUPSTGFA9ONZGQN9TUICPOGQISGIBQAQMYCXRKEFQJBTMHFPKURZDYNTAVIJFDPXEC999_GUACEZHWFAEZEYGUACEZGQFEFFGOAGHSDAHCFCEZGUACEZGDFAABABEYEVJVIDABGBJLFQGNICDRHUBCGSEEDWDZEOFPCDICHGEHHOEYCPGCHJAACCIBGKIZHPINHKGGIBETIJHHANIIESCLCRENCGGUEOCXBBIFJCDJABHFAAGBGYJFEKIWIQCDJBAZIABLBKBFBFEAFCJRFOGGCOHZCHBPDJEWCDCSFZEQHFIHDZCSBOBMFTFNFCETADEODFCRGCCPFAGZIEFRIKFUARGWEOJLELBUGPIRDJGOEHEKGGFBFXBDDDHSEZCTFAFTEYAXIQIAAPFTGHFJCYBYASCFACBIEDAEFJEIIIGAENFAABABEYEPDTBGAFDIBBHHDQCXCIBRIMHACEIHCFJPAUBVCHESHEECACERIHHWFJHHFFACIXIBIJIHAOCGDGIJHZDYJHFFFOABAACAHTFUJHGHEAHWGMFUFRCDDBFHGWAMCUBMDTHGFUJQALIEJSANGMDSBJBUGCGPBZBMJLARJEBJJVFJESGFGZISEJETISJQEZGIHFCYBKEJCKBOIBAQAJBOADDRDTIKDXBFFEASALIWIOAAJRIFGJIUEZHWHFEWDBHTGOFCFVFAFTEYAQDUEWCCEDFHCNHWFQBRGRGCCVDEHHDGERHLFGAN"}
Imports a once exported entity (iam stream, qubic or oracle) encoded by a string.
name | type | description |
---|---|---|
callback |
function |
|
encoded |
string (string) |
the code you received from command 'export' (starts with 'i_', 'o_' or 'q_') |
QLITE.import(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'q_HZGULHJSZNDWPTOCXDYYKMKXCCKCHPORELEBZLBQRWHQNBMNAHBGWQYD9WRVHFKRQRXUXLXORJEPTN999_GUACEZHWFAEZEYGUACEZGQFEFFGOAGHSDAHCFCEZGUACEZGDFAABABEYEVJVIDABGBJLFQGNICDRHUBCGSEEDWDZEOFPCDICHGEHHOEYCPGCHJAACCIBGKIZHPINHKGGIBETIJHHANIIESCLCRENCGGUEOCXBBIFJCDJABHFAAGBGYJFEKIWIQCDJBAZIABLBKBFBFEAFCJRFOGGCOHZCHBPDJEWCDCSFZEQHFIHDZCSBOBMFTFNFCETADEODFCRGCCPFAGZIEFRIKFUARGWEOJLELBUGPIRDJGOEHEKGGFBFXBDDDHSEZCTFAFTEYAXIQIAAPFTGHFJCYBYASCFACBIEDAEFJEIIIGAENFAABABEYEPDTBGAFDIBBHHDQCXCIBRIMHACEIHCFJPAUBVCHESHEECACERIHHWFJHHFFACIXIBIJIHAOCGDGIJHZDYJHFFFOABAACAHTFUJHGHEAHWGMFUFRCDDBFHGWAMCUBMDTHGFUJQALIEJSANGMDSBJBUGCGPBZBMJLARJEBJJVFJESGFGZISEJETISJQEZGIHFCYBKEJCKBOIBAQAJBOADDRDTIKDXBFFEASALIWIOAAJRIFGJIUEZHWHFEWDBHTGOFCFVFAFTEYAHDRGKJTIPFGBHHIGIDNAABHFEEEGEAYJIIVFKDD');
{"duration":42,"success":true}
Reads the specification of any qubic, thus allows the user to analyze that qubic.
name | type | description |
---|---|---|
callback |
function |
|
qubic |
string (trytes{81}) |
id of the qubic to read |
QLITE.qubic_read(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'XZTUUANZCHSSPROSIRCFPKBDSUPNCBPDADBIJYXUZHSPOPGPNANOMUUSPTDXRK9XSPXRLWPWSEJSHUCXV');
{"assembly_list":["B9PCXT9GZYXXTIJ9NWUWZGJCK9FKAHQFDGOWP9NVYGBKK9STYZ9ABZHKRZTWPGPLENGRHGPPONIJWZWKW"],"duration":42,"code":"return(epoch^2);","hash_period_duration":20,"result_period_duration":10,"success":true,"runtime_limit":10,"execution_start":1537543279,"id":"9XXRJJGTWTXWHBJPHCZUQJXOUWPIZAXTMJTIPNRAOIXTXSWZPHEKMGWNQKRBOSDDNCNDJKGRUNDUKY999","version":"ql-0.5.0"}
Lists all qubics stored in the persistence.
name | type | description |
---|---|---|
callback |
function |
QLITE.qubic_list(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
});
{"duration":42,"success":true,"list":[{"specification":{"code":"return('hello world');","hash_period_duration":20,"result_period_duration":10,"execution_start":1537543280,"run_time_limit":10,"type":"qubic transaction","version":"ql-0.5.0"},"id":"MVEOOSTGJDMGYXE9CKYZLFFZENDDAYIG9YUWTOAFKD9UCQDORDFXX9FAHMYGCHFT9RT9PFGNEANLFB999","state":"assembly phase"}]}
Creates a new qubic and stores it in the persistence. life cycle will not be automized: do the assembly transaction manually.
name | type | description |
---|---|---|
callback |
function |
|
execution_start |
int (integer{1-2147483647}) |
amount of seconds until (or unix timestamp for) end of assembly phase and start of execution phase |
hash_period_duration |
int (integer{1-2147483647}) |
amount of seconds each hash period (first part of the epoch) lasts |
result_period_duration |
int (integer{1-2147483647}) |
amount of seconds each result period (second part of the epoch) lasts |
runtime_limit |
int (integer{1-2147483647}) |
maximum amount of seconds the QLVM is allowed to run per epoch before aborting (to prevent endless loops) |
code |
string (string) |
the qubic code to run |
QLITE.qubic_create(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 300, 30, 30, 10, 'return(epoch^2);');
{"duration":42,"success":true,"qubic_id":"YVMZUIRMRY9GJBFPAXIITZPHGUFFEIFYDPOFHPGVTZPOPGWVGEBVCJINBCP9V9HAEEGICAHCQCIJSZTXU"}
Removes a qubic from the persistence (private key will be deleted: cannot be undone).
name | type | description |
---|---|---|
callback |
function |
|
qubic |
string (trytes{81}) |
deletes the qubic that starts with this tryte sequence |
QLITE.qubic_delete(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'OSZIVKKIISMGASEXLJTTXQCVQTYMBNWRPGOMEQKVRZUTOAYPCSVUVSGLODJKRJXPAHRIHVESAVLWSOQAM');
{"duration":42,"success":true}
Lists all incoming oracle applications for a specific qubic, response can be used for 'qubic_assembly_add'.
name | type | description |
---|---|---|
callback |
function |
|
qubic |
string (trytes{81}) |
the qubic of which you want to list all applications |
QLITE.qubic_list_applications(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'DUKV9BLGJYPNM9RNEJOVMRKGTUBXAUGAGUJYQKZQLYGXXLKJMFVAYRFIPIUSTNUVFPRHQFUE9K9ZPLN9Q');
{"duration":42,"success":true,"list":["GIM9CVAKHHXYJFUXGTH9SLYDPWIVPEGFEYDMUTRYAAPKILUCVCHVCTMNEWMSMUXJMOBZNJADA9JEZFKQW","P9HZYAITEDUFVQXILQJBBYZ9VOSQYUZRQXRBVQD9XFBPFPSHENMPLPXEXDLNFXAWNWSQAHBQRORMJJFF9"]}
Publishes the assembly transaction for a specific qubic.
name | type | description |
---|---|---|
callback |
function |
|
qubic |
string (trytes{81}) |
the qubic that shall publish its assembly transaction |
assembly |
array (jsonarray) |
json array of the oracle IDs to be part of the assembly |
QLITE.qubic_assemble(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'RYBJWGXI9MTHGPDEIKZ9ZLSAKAP9LUHLSVKIVSILIMZHPXZG9YN9LBODXBVNUKVDBYGMKJQXVLENBGHKL', ['NVIY9QTVBHOTKCNPHNYHAEMPOVDSMNZAZDHUKGPG99PJUGTIAJZLIGLUBOWUYUZTUHCWTJQZYMLUW9RSR', 'LOQNOUWPEHKDWI9WNXRUYLKJZ9YRWXWPLVOFHWSURVRPIMPXDBGXSOULWJZZZBJUSNLROFRVBJPOWPGEJ']);
{"duration":42,"success":true}
Runs QL code locally (instead of over the tangle) to allow the author to quickly test whether it works as intended. Limited Functionality (e.g. no qubic_fetch).
name | type | description |
---|---|---|
callback |
function |
|
code |
string (string) |
qubic code you want to test |
epoch_index (opt.) |
int (integer{0-2147483647}) |
initializes the run time variable 'epoch' to simulate a running qubic |
QLITE.qubic_test(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'return(epoch^2)', 3);
{"result":"9","duration":42,"success":true,"runtime":12}
Determines the quorum based consensus of a qubic's oracle assembly at any IAM index.
name | type | description |
---|---|---|
callback |
function |
|
qubic |
string (trytes{81}) |
qubic to find consensus in |
keyword |
string (trytes{0-30}) |
keyword of the iam index to find consensus for |
position |
int (integer{0-2147483647}) |
position of the iam index to find consensus for |
QLITE.qubic_consensus(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'KXSMCSMDZRZYUTOEAMVBALRTKFXVENBZUXWQZRYPTBMSMQCDAKDKRRETXENTIVUONQLZRPPUVTOBQDNQF', 'Q', 4);
{"result":"{'color': 'red'}","duration":42,"success":true,"index_keyword":"COLORS","quorum":3,"quorum_max":4,"index_position":2018}
Creates a new oracle and stores it in the persistence. Life cycle will run automically, no more actions required from here on.
name | type | description |
---|---|---|
callback |
function |
|
qubic |
string (trytes{81}) |
ID of the qubic which shall be processed by this oracle. |
QLITE.oracle_create(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'QPFTWIZZQUZQHLELUFFEKBVALVNZRHDUEURIQNKZUBFKAGXRTBYQJHDZQUCOZQWJKYAFWWTFKDUDKADLX');
{"duration":42,"oracle_id":"UOJXGICXEA9UGO9H9VMYCOVDN9DNRKLEJFWUHYQIUKVGJXNPWV9UWTOIDZSCBKBR9NARAP9SVC9GUGOCR","success":true}
Removes an oracle from the persistence (private key will be deleted, cannot be undone).
name | type | description |
---|---|---|
callback |
function |
|
id |
string (trytes{81}) |
oracle ID |
QLITE.oracle_delete(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'BXGS99EYAK9HMV9LHQIS99AM9QTRGPWZASCGWJPRLAZIPXECNKGOYMVJCOSKGIBQJSU9FVOHNHXWTLGCN');
{"duration":42,"success":true}
Lists all oracles stored in the persistence
name | type | description |
---|---|---|
callback |
function |
QLITE.oracle_list(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
});
{"duration":42,"success":true,"list":["LZHSSSADUZWGBWZYKYCOHKQSBIXKZGBCKRHIE9VJJJIB9YJJGPCXNTJKQZGT9NZAUMPANNBMZFSNVZLVU","WQHRNQUNFLWYORPFNHNRAKYTFWBNSNAEAMFYEJCNYRCY9UU9NDHUDHBCHHIJOSTMEJSHKC9YOONFFCTWC"]}
Temporarily stops an oracle from processing its qubic after the epoch finishes. Can be undone with 'oracle_restart'.
name | type | description |
---|---|---|
callback |
function |
|
id |
string (trytes{81}) |
oracle ID |
QLITE.oracle_pause(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'BTO9ZMXZT9ALXBUDZWCDJYRJVFJWAMQZYB9JQGSMOYA9WMYAUEVLAWCJESACBPBRTBQ9UQNP9MZOZZWSN');
{"duration":42,"success":true}
Restarts an oracle that was paused with 'oracle_pause', makes it process its qubic again.
name | type | description |
---|---|---|
callback |
function |
|
id |
string (trytes{81}) |
restarts the oracle that starts with this tryte sequence |
QLITE.oracle_restart(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'QAMFDSMSFUENHLJJEUMFFURIQDVEKRAFXEVGLHHULRZN9FUBSBJARYBC9B9PMMHJ9PJHDMPPKWAFFQRTS');
{"duration":42,"success":true}
Creates a new IAM stream and stores it locally in the persistence.
name | type | description |
---|---|---|
callback |
function |
QLITE.iam_create(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
});
{"duration":42,"iam_id":"IATEVQVMFUQNEBDADBTAOEQ9XBOVJXFDJSBRUITFTZ9GJB9AOSYYBDHLMPBNKZUPJBDVFYKYJSYSUDHVX","success":true}
Removes an IAM stream from the persistence (private key will be deleted, cannot be undone).
name | type | description |
---|---|---|
callback |
function |
|
id |
string (trytes{81}) |
IAM stream ID |
QLITE.iam_delete(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'XUYRQFPGFAMCNNRE9BMGYDWNTXLKWQBYYECSMZAMQFGHTUHSIYKVPDOUOCTUKQPMRGYF9IJSXIMKMAEL9');
{"duration":42,"success":true}
List all IAM streams stored in the persistence.
name | type | description |
---|---|---|
callback |
function |
QLITE.iam_list(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
});
{"duration":42,"success":true,"list":["MUCYJSLGQM9KIEFIMOMWGGQUUJMWNBNCUSLGLOGQQHKJQB9CYUDZSZBWQVAFAYSHKSGVUISGKLSCQJN9F","9JQYX9YSJP9XPN9LAGNELSVYFP9KPMJRLKWUWLHKLVNIKYHHXWLITTDDDMNPVXSSPXJJLUABEEFPLFQDN"]}
Writes a message into the iam stream at an index position.
name | type | description |
---|---|---|
callback |
function |
|
id |
string (trytes{81}) |
the IAM stream in which to write |
index |
int (integer{0-2147483647}) |
position of the index at which to write |
message |
object (jsonobject) |
the json object to write into the stream |
keyword (opt.) |
string (trytes{0-30}) |
keyword of the index at which to write |
QLITE.iam_write(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'CLUZILAWASDZAPQXWQHWRUBNXDFITUDFMBSBVAGB9PVLWDSYADZBPXCIOAYOEYAETUUNHNW9R9TZKU999', 17, {'day': 4}, 'ADDRESS');
{"duration":42,"success":true}
Reads the message of an IAM stream at a certain index.
name | type | description |
---|---|---|
callback |
function |
|
id |
string (trytes{81}) |
IAM stream you want to read |
index |
int (integer{0-2147483647}) |
position of index from which to read the message |
keyword (opt.) |
string (trytes{0-30}) |
keyword of index from which to read the message |
QLITE.iam_read(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'CLUZILAWASDZAPQXWQHWRUBNXDFITUDFMBSBVAGB9PVLWDSYADZBPXCIOAYOEYAETUUNHNW9R9TZKU999', 17, 'RESULTS');
{"duration":42,"read":{"habit":"antarctica","name":"penguin"},"success":true}
Lists all apps installed.
name | type | description |
---|---|---|
callback |
function |
QLITE.app_list(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
});
{"duration":42,"success":true,"list":[{"license":"©2018 by microhash for qame.org","description":"Grow and harvest food on your own farm. The first qApp and decentralized IOTA game. The game state is entirely stored on the Tangle and validated by Qubic Lite.","id":"tanglefarm","title":"Tangle Farm","version":"v0.1","url":"http://qame.org/tanglefarm"}]}
Installs an app from an external source.
name | type | description |
---|---|---|
callback |
function |
|
url |
string (url) |
download source of the app |
QLITE.app_install(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'http://qame.org/tanglefarm');
{"duration":42,"success":true}
Uninstalls an app.
name | type | description |
---|---|---|
callback |
function |
|
app |
string (alphanumeric) |
app ID (directory name in 'qlweb/qlweb-0.5.0/qapps') |
QLITE.app_uninstall(function(resp, err) {
if(err) { console.log(err); /* handle error */ }
else { /* process response ... */ }
}, 'tanglefarm');
{"duration":42,"success":true}