January 29, 2026

Capitalizations Index – B ∞/21M

Blockchain Developer Guide – TruSource – Medium

Blockchain Developer Guide – TruSource – Medium

Blockchain Developers use our platform to develop oracles to provide data for their blockchain applications. If your smart contract use case requires external data, you can use the TruSource platform to develop oracles for the Ethereum and ThunderCore blockchains following the guide below.

Generation

Let’s start, go to the platform and provide an email, this will be used to authenticate you, no passwords needed!

Once logged in, you will see that no oracles have been created yet, let’s create one! Click Create Oracle.

No Oracles 🙁

Design

Here, Oracle Name is used to name the oracles you create and you can connect to a maximum of 5 APIs per oracle. For each request, provide a name that is used for the corresponding smart contract function, a HTTP method and URL. Ensure you name the requests uniquely and provide a valid URL.

Currently we support public APIs with support for authenticated APIs coming soon. The URLs provided can include a query string, we are adding support for building the query string dynamically using arguments.

Set up your requests

Develop

Next select the blockchain platform, the network and generate! Currently we support integration with the Ethereum and ThunderCore blockchains.

Set development configurations for your oracle

Your Oracle

Your oracle has been generated! We have generated a truffle project and monitoring server scripts. The truffle project includes three contracts.

Example.sol is an example contract that makes a query using your oracle. Making a query returns a queryId which you use to keep track of the query. A smart contract using your oracle must implement a trusource_callback function which is used to receive a response from your monitoring server. Within trusource_callback, you define how you handle the data you have requested using the queryId that is passed to identify the query.

OracleAPI.sol is an abstract contract that is inherited by Example.sol, it defines the interface to your oracle and abstracts the methods required from your smart contract. This limits the amount of oracle related logic required in your smart contract so you can focus on core functionality.

Oracle.sol is where your oracle is implemented. It maintains a mapping of contract addresses that can make requests to your oracle. Whenever a request is made by a smart contract, the LogQuery event is emitted.

Your oracle

Testing

We have setup the project and provided scripts to enable local testing. The instructions will set out running a local blockchain instance, deploying your contracts, running the monitoring server and demonstrating that it can listen and respond to queries. For local testing you will need to install the following dependencies:

  • Node
  • npm
  • Ganache-cli
  • Truffle v 5.0.0+

First unzip the downloaded folder, in code you will have two sub folders: server and truffle.

In a terminal run the command:

ganache-cli -b 1

This will run a local blockchain instance on port 8545 with a 1 second block-time.

Open a new terminal and navigate to the truffle directory and run:

npm install 

to install the dependencies. Then run:

truffle migrate

to deploy your contracts to your local blockchain.

Deploy your contracts

Next, open a new terminal and navigate to the server directory and run:

npm install

to install dependencies, then run:

npm run start
Run your monitoring server

This will start the monitoring server which is listening for events emitted by your oracle and is ready to respond with the fetched result.

Finally switch back to your terminal in the truffle directory and run:

truffle exec ./server/call.js

This will execute a script that will make a query to your oracle by calling the query method in the Example.sol contract. Your server will catch the emitted event and respond with the data!

Make a query
Event caught and response sent

You’ve just created your first oracle and tested it using an example contract. We welcome any feedback, contact us here!

Published at Wed, 13 Mar 2019 01:09:54 +0000

Previous Article

What should be known for the main types of crypto mining?

Next Article

XRP Price Goes Sideways Again as XRP/BTC Pressure Remains

You might be interested in …