#Captain Nemo
Manipulating data on-chain is a difficult task: smart contracts should handle as little data as possible and perform only the bare minimum logical operations. Uploading off-chain data to a smart contract is therefore not an easy process.
A possible solution is to use an Oracle, a trusted off-chain agent that feeds external data to the contract.
We extend this concept and define a sort of oracle-on-steroids, that not only fetches data, but executes arbitrarily complex tasks and uploads the result. This oracle-on-steroids is a fetch.ai agent, Captain Nemo.
Captain Nemo is a bridge between on-chain smart contracts, off-chain fetch.ai agents and data on the Ocean protocol.
The workflow is as follows:
- A smart contract creates a query request on the
Submarine.sol
smart contract (the Submarine), by calling the functioncreateQuery
. The parameters are the address of the target fetch.ai agent, the command he should run, the did of the ocean resource and the identifier of the callback function to be called after the result is received. - The Submarine emits an event containing the query data
- The agent logs events emitted from the Submarine and checks whether there is a request targeting them.
- The agent processes the request by first fetching the data from the Ocean protocol. Then they execute the requested command on the data.
- The agent transmits the result to the Submarine.
- The Submarine calls the callback function on the original contract to set the result.
As an example, the agent nemo.py
(Nemo) fetches data from the Ocean protocol, applies a machine learning algorithm and outputs the result.
Submarine.sol
and TestCase.sol
are two smart contracts written in solidity.
nemo.py
is an agent written in python with the fetch.ai SDK.
Integrating all the various components from the different protocols has been the biggest challenge.
A first step for Captain Nemo would be to integrate a payment system, where agents get paid after they process their data and users can rank agents according to the quality of the result.
A next step would be to integrate an agents market with a user interface, listing all agents addresses and possible commands. Users could then choose which agent best fits their needs and create queries accordingly.
Submarine.sol
is deployed on the Nile testnet at 0x7d5158372BC13D1bA316b44B9002821BE46652F5
.
TestCase.sol
is deployed on the Nile testnet at 0xb930AF9aDfe58029B135EA2949b591C46849de4c
.