@trusource/server
Locally test smart contract calls to a TruSource provided oracle.
Getting started
$ npm install @trusource/server
Quick Start
After running a local ganache instance and migrating your
const { server } = require('@trusource/server');
const model = require('./model.json');
const oracleArtifact = require('../build/contracts/Oracle.json');
server(oracleArtifact, model);
trusource.server
trusource.server(oracleArtifact, model);
Calling the server function initiates a process that listens for events emitted by a local ganache instance, fetches the requested data and makes contract calls, passing the response in the payload.
oracleArtifact
A build artifact generated for the oracle.sol
smart contract after migration to a local ganache instance. From the root of truffle project, it is found at ./build/contracts/Oracle.json
.
model.json
A model representing an api from a data source, can be found here.
Command Line Interface
Installing the package creates trusource-server
command line utility, which can be used as follows.
$ trusource-server <path-to-Oracle.json> <path-to-model.json>