Development
...
Basics
The Ledger Client
5 min
to post or get data to/from the signum blockchain you need to create a ledger client instance once instantiated you have access to all the functions provided by the docid\ yynxycqblmbwflxzom4c6 in a comfortable and intuitive way it is highly recommended to use signumjs within a decent ide like https //code visualstudio com/download or https //www jetbrains com/webstorm/ to take full advantage of the auto completion feature, making developing for signum a breeze the client organizes the calls into groups according their functionality, i e account alias asset block contract message network transaction each of this subgroup provides a set of functions (see docid\ kfmwpwrrp1gef3sdg5v4w for complete documentation) for example, network related functionality like getting a list of connected peers are in network , while balance information are inside the account subgroup instantiating a ledger client is very easy const ledger = ledgerclientfactory createclient({ nodehost "https //europe3 testnet signum network" }); networks at this time of writing signum runs two major networks main net and test net test net as a general rule, all development should be done on test net first the signum core team provides a public test net node https //europe3 testnet signum network and a public explorer under https //t chain signum network but best is to run a local test net host http //localhost 6876 see how to docid\ tf9yki9wuh7rfqjahqosz for development purposes main net the main net consists of hundreds of nodes, but some of them are considered as featured nodes, which are maintained by the signum core team and further community members and guarantee better up times a full list of feature nodes can be found in the https //chain signum network/peers/ automatic node selection as a blockchain is a distributed ledger, you can connect the ledger client with any of the nodes if you provide an application and want to offer better user experience through better loading times, it would be good if the application could be capable of selecting the "best" node signumjs provides such a functionality, which tests the response times of a set of given node urls to auto select the "best" node do the following const {ledgerclientfactory} = require("@signumjs/core"); async function selectbesthost() { try { const featurednodes = \[ 'http //localhost 8125', // local main net host 'https //europe signum network', 'https //europe1 signum network', 'https //europe2 signum network', 'https //europe3 signum network', 'https //brazil signum network', 'https //australia signum network', 'https //us east signum network', ] const ledger = ledgerclientfactory createclient({ nodehost featurednodes\[0], // default node reliablenodehosts featurednodes // set this list, when you plan to use the `selectbesthost` method }) // by calling this method all nodes from `reliablenodehosts` will be requested to see who's responding fastest // we want the ledger to be re configured to the best node automatically, that's why we pass `true` as first argument const selectedhost = await ledger service selectbesthost(true) console log('fastest responding node', selectedhost) // you can also get the current selected host from the ledger client, like this // ledger service settings nodehost } catch (e) { // if the api returns an exception, // the return error object is of type httperror handleerror(e); } } (async () => { await selectbesthost(); })();