Creating Blockchain Connector 

Last updated by Jamiu Idowu 2 months ago
Blockchain connector is a WebSocket server which the Grindery Nexus engine communicates with to listen for events from / send transactions to one or more blockchain. This document outlines how to create a blockchain connector. 

Prerequisites 

To understand the instructions in this document you need to have experience with Ethereum and other blockchains, have used web3.js or other libraries to develop a blockchain app, and can create app with TypeScript and Node.js. 
Additionally you should make yourself familiar with Zapier. This means specifically: 
Create a few ZAPs between different apps 
Play around with the Zapier Developer Portal 
Look at Zapier documentation related to creating new dApps 
Then reading the following documents is required 
Whitepaper 2.2 
On Connectors 

Background 

Grindery Nexus depends on connectors to communicate with different blockchains. We have decided that connector should use one of the API provider to connect to blockchain. We have chosen ANKR as our initial API provider as it covers most of the chains we need. We have implemented support for chains listed under https://www.ankr.com/docs/build-blockchain/guides/websocket-premium  , other chains (like NEAR) requires a different implementation because API is different. 

Setup 

Before starting to work please make sure you have been added to Discord and our Slack channel.To get support please contact CESAR in Discord.   

Selecting a blockchain  

Pick any blockchain from the list. Using ANKR is preferred, but it is OK to use another API provider if the chain is not supported by ANKR. 

Creating the connector  

Fork https://github.com/grindery-io/grindery-nexus-connector-web3  and implement the connector in src/web3.ts. You should rewrite the 2 trigger classes (NewTransactionTrigger, NewEventTrigger) and one action function (callSmartContract) for the target blockchain. 
Code should be written in TypeScript, usage of `any` should be avoided when possible, and there should be no warning when building with `npm run build`. 
For testing, please run `npm run server`, then connect to the server via WebSocket and send JSON-RPC request with "setupSignal" or "runAction" as method name and following parameter: 
{ 
  "key": "TRIGGER_OR_ACTION_NAME", 
  "fields": { ...FIELDS... } 
} 
Replace "TRIGGER_OR_ACTION_NAME" with name of an action or trigger (see src/connector.ts). See also https://www.jsonrpc.org/specification  for format of JSON-RPC. 
After you are done, please post a link to your repository on Discord and @ - mention CESAR. 

Quality assurance 

Refreshed On: Dec 08, 2022 13:16:43 UTC+00:00