Torus REST and RPC client
Install the package via yarn
:
yarn add https://github.com/torus-economy/torus-client
or via npm
:
Install the package via npm
:
npm install --save https://github.com/torus-economy/torus-client
[agentOptions]
(Object): Optionalagent
options to configure SSL/TLS.[headers=false]
(boolean): Whether to return the response headers.[host=localhost]
(string): The host to connect to.[logger=debugnyan('torus-client')]
(Function): Custom logger (by default,debugnyan
).[network=mainnet]
(string): The network.[password]
(string): The RPC server user password.[port=24111]
(string): The RPC server port.[ssl]
(boolean|Object): Whether to use SSL/TLS with strict checking (boolean) or an expanded config (Object).[ssl.enabled]
(boolean): Whether to use SSL/TLS.[ssl.strict]
(boolean): Whether to do strict SSL/TLS checking (certificate must match host).[timeout=30000]
(number): How long until the request times out (ms).[username]
(number): The RPC server user name.[version]
(string): Which version to check methods for.[wallet]
(string): Which wallet to manage.
const Client = require('torus-client')
const client = new Client({
host: '127.0.0.1',
password: 'somepassword',
port: 24111,
username: 'someusername'
});
By default, when ssl
is enabled, strict checking is implicitly enabled.
const fs = require('fs');
const client = new Client({
agentOptions: {
ca: fs.readFileSync('/etc/ssl/torusd/cert.pem')
},
ssl: true
});
const client = new Client({
ssl: {
enabled: true,
strict: false
}
});
client.getBalance().then((bal) => console.log(bal));
Due to JavaScript's limited floating point precision, all big numbers (numbers with more than 15 significant digits) are returned as strings to prevent precision loss. This includes both the RPC and REST APIs.
MIT