make initwill setup the environment by downloading and installing all necessary dependencies and the required toolchain.
make buildbuilds the chain's code so we can execute it.
chainSpec.jsonfile from this repository into the chain's directory. More on the spec file will be explained a little bit later.
/tmpfor 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:
--alicewill make Alice the node's authority uses her predefined key pair.
bootnodesparameter which specifies the network and identity information of Alice's node.
CurrencyIdas key type. That means it can be one of the predefined values FBTC, FETH, FEUR, etc. The value uses the type
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.x
txfor 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
feedValuesin 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_getValue. That means we have the two functions
getValueavailable for the RPC
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.
feedPricewhich 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: