make init
will setup the environment by downloading and installing all necessary dependencies and the required toolchain.make build
builds the chain's code so we can execute it.chainSpec.json
file from this repository into the chain's directory. More on the spec file will be explained a little bit later./tmp
for each node (its base directory). If the base directory doesn't exist it will be created but it is necessary to purge all data of a specific node on subsequent launches:y
.--alice
will make Alice the node's authority uses her predefined key pair.bootnodes
parameter which specifies the network and identity information of Alice's node.CurrencyId
as key type. That means it can be one of the predefined values FBTC, FETH, FEUR, etc. The value uses the type Price
.package.json
file:index.ts
. We import the required types//[Name]
. We derive those key pairs from the keyring we create specifying the key pair format SR25519.api.tx.
the code completion shows us the available extrinsics but the oracle isn't one of them. That's because the default methods of the Substrate runtime are known at compile time but not the custom chain specific extrinsics that might be part of the runtime. Let's find out what's really available by querying the node:laminarOracle
. The list tells us even more about the oracle: the available query method feedValues
. This is exactly what we needed to know.xtx
for transaction). The available extrinsics depend on the used chain. In this case we address the oracle pallet of the laminar chain which is addressed by laminarOracle
.feedValues
in order to submit key-value pairs that should be fed into the oracle. In this case we just submit a single key-value pair for the Bitcoin price.oracle_getAllValues
and oracle_getValue
. That means we have the two functions getAllValues
and getValue
available for the RPC oracle.
oracle
) and query the value to the key associated with the Bitcoin price (which is FBTC
). The output is a pair of two values: The current price and the timestamp of the transaction that contained the feeding operation.yarn start
. The oracle will be fed and queried and the output is the expected BTC price of 1.getValue
. The oracle pallet states that this method returns a "combined value" which indicates that there is some data aggregation happening.feedPrice
which takes a price value and a sender and triggers the transaction accordingly. We use the subscription API of Polkadot JS in order to make sure that we wait for every transaction to be finalized in a block. Now our three users submit their values: