What is it?

Bridges is a Chainlink adaptor framework that lowers the level of skill needed to create and run adaptors. It provides a common interface and a CLI, allowing adaptors to be defined in very little JSON, or alternatively allowing developers to easily create their own without worrying about the specific integration points to work with a Chainlink node.

To show a very basic example, here’s a Bridges-supporting JSON file which calls the CryptoCompare API for Ethereums current price:

[

{

"name": "CryptoCompare",

"method": "GET",

"url": "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,JPY,EUR"

}

]

That’s all that’s needed to create your very own adaptor. Just specify its name, the HTTP method and the URL that will be called.

To then run this, you can either specify a URL or a JSON file path to the Bridges CLI:

bridges -b https://s3.linkpool.io/bridges/cryptocompare.json OR bridges -b json/cryptocompare.json

Once you run this command, Bridges will start a new HTTP server and will listen to any inbound requests from a Chainlink node. Upon receiving a request, Bridges will call the CryptoCompare API and then return the data in the correct format to then be parsed by Chainlink.

Platform Support

Bridges doesn’t just support running it locally via the CLI, it also supports a variety of platforms, including:

Docker

AWS Lambda

Google Cloud Platform Functions

For any adaptor you create, it’s automatically supporting of any of the above! Any Bridges adaptor JSON works in AWS or GCP by default! 🎉

Other Examples

We have built Bridges adaptor examples for the following:

All of the above examples work and can be used on your Chainlink node now.

Why is this important?

Before the development of Bridges, each Chainlink adaptor had its own implementation of how it handles the data sent by a Chainlink node. There was no standard toolset to aid developers in doing this, meaning each adaptor had the same code to do the same thing duplicated throughout.

With Bridges, that is now all done for you. You have a standard interface for creating your own adaptor, or you can just simply define the adaptor in JSON and share it with others. As a developer, the only code you have to now write is how the API you’re wanting to call is called, rather than worrying about how it integrates with Chainlink.

We believe that with Bridges, the amount of adaptors that will be created for Chainlink will increase drastically. Users and node operators will feel empowered to be able to quickly support whatever API they want to use within Chainlink, we’re proud to allow that to happen.

Custom Implementations

To create adaptors that can do literally anything besides proxying a single API, Bridges has a simple interface that you can implement to create your own. For example:

package main



import (

"github.com/linkpoolio/bridges/bridge"

)



type MyAdaptor struct{}



func (ma *MyAdaptor) Run(h *bridge.Helper) (interface{}, error) {

return map[string]string{"hello": "world"}, nil

}



func (ma *MyAdaptor) Opts() *bridge.Opts {

return &bridge.Opts{

Name: "MyAdaptor",

Lambda: true,

}

}



func main() {

bridge.NewServer(&MyAdaptor{}).Start(8080)

}

You can copy this code into your Golang IDE and run it. You’ll see an adaptor start that when called always returns {data: { "hello": "world" }} as part of the Chainlink request.

You can simply expand on that to allow you to fetch any data from any source easily. You can return any type back as the result, and Bridges will automatically parse it and include it into the JSON back to the Chainlink node.

Simple.