Usage
Installation
npm i defichain @defichain/jellyfish-api-jsonrpc
JsonRpcClient
import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
const client = new JsonRpcClient('http://foo:bar@localhost:8554')
ApiClient
You can extend ApiClient
with the @defichain/jellyfish-api-core
package to create your own transport exchange specification.
import { ApiClient } from '@defichain/jellyfish-api-core'
class SpecClient extends ApiClient {
async call<T> (method: string, payload: any[]): Promise<T> {
throw new ClientApiError('error from client')
}
}
const client = new SpecClient('http://localhost:8554')
call
Method
You can use the .call
method directly by specifying:
- node rpc method name
- payload params
- number precision for parse
const result = await client.call('methodname', ['p1', 'p2'], 'number')