Giter VIP home page Giter VIP logo

chainlink-polkadot's Introduction

Chainlink-polkadot

This repository contains all relevant project necessary to have polkadot and substrate chains interact with chainlink.

This is WIP and will evolve frequently.

How to use pallet-chainlink?

Using pallet-chainlink is fairly straightforward and requires a couple easy steps:

  • add the correct dependency to your runtime
  • use some of the pallet bundled functions

Add the pallet dependency

Update Cargo.toml to reference pallet-chainlink.

Add the following section:

[dependencies.chainlink]
default_features = false
package = 'pallet-chainlink'

And amend the std section so that it shows like this:

std = [
    ... // all the existing pallets
    'chainlink/std'
]

Use provided functions

Edit lib.rs to that it references pallet-chainlink:

...
// Add the chainlink Trait
impl chainlink::Trait for Runtime {
	type Event = Event;
}
...
// In construct_runtime!, add the pallet
...
construct_runtime!(
    ...
    Chainlink: chainlink::{Module, Event<T>},
  }
);

Add necessary use declarations:

use chainlink::{Event, create_get_parse_request};

You can now deposit chainlink events:

Self::deposit_event(create_get_parse_request::<T>(who));

Those will be picked up by chainlink nodes that will in turn

See the full example for more details.

Run the example

rust-toolchain is used to make sure the correct rust version is used. Make sure to install the WASM target using:

rustup target add wasm32-unknown-unknown

substrate-node-example shows off out to use pallet-chainlink end-to-end. To test:

  • start the chain using make run-chain
  • start the frontend using make run-front-end

You are now ready to send test requests and see the result being provided back by an Oracle (TBD).

Send a test request using PolkadotJS

const alice = ...;
const txHash = await api.tx.example
  .sendRequest()
  .signAndSend(alice);
console.log(`Submitted with hash ${txHash}`);

Send a test request using PolkadotJS Apps

Make sure you add the following additional to Settings/Developer section:

{"SpecIndex": "u32",
 "RequestIdentifier": "u64",
 "DataVersion": "u64"}

Then in Extrinsincs, example / sendRequest can be submitted.

chainlink-polkadot's People

Contributors

boxhock avatar j16r avatar jeluard avatar thodges-gh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.