Below is a brief explanation of how to create web-based dApps using JavaScript on top of the Daten Network.
First you should connect to a Daten node by creating a wallet object. It accepts an initial node address as its first argument.
var wallet = new daten.Wallet("1.2.3.4:32323");You can get the state of a random node in the network like this:
wallet.getStatus(function(state) {
alert(state.height);
});You should create a transaction before sending it, be aware that the transactions created by this function expire when a new block gets validated across the network, send it as soon as possible!
wallet.createTransaction(name, destination, amount, data, function(tx) {
// Transaction is created!
}, onError);Send transactions:
wallet.sendTransaction(tx, function(result) {
// Check if the process was successfull.
}, onError);Find data:
wallet.query(params, function(txs) {
});Listen to incoming transactions to a specific address:
wallet.listen(address, function(tx) {
});Confirm transactions:
wallet.confirm(tx, maxConfirmations, function(confirmations, hashTries) {
});