From 64aa4dcc1cb5b87378a1910195438a9dc5709221 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 24 Feb 2020 16:52:00 +0100 Subject: [PATCH] More metadata clarifications (#1933) --- docs/start/basics.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/start/basics.md b/docs/start/basics.md index 42c23d2e29..0eac01f8db 100644 --- a/docs/start/basics.md +++ b/docs/start/basics.md @@ -6,7 +6,7 @@ To unpack this, we will start with the Metadata and explain what it actually pro ## Metadata -When the API connects to a node, one of the first things it does is to retrieve the metadata. The metadata, effectively provides data in the form of `api...
` that fits into one of the following categories - +When the API connects to a node, one of the first things it does is to retrieve the metadata and decorate the API based on the metadata information. The metadata effectively provides data in the form of `api...
` that fits into one of the following categories - - [consts](../substrate/constants.md) - All runtime constants, e.g. `api.consts.balances.existentialDeposit`. These are not functions, rather accessing the endpoint immediately yields the result as defined. - [query](../substrate/storage.md) - All chain state, e.g. `api.query.system.account()`. @@ -14,6 +14,8 @@ When the API connects to a node, one of the first things it does is to retrieve Additionally the metadata also provides information on [events](../substrate/events.md), these are query-able via the `api.query.system.events()` interface and also appear on transactions... both these cases are detailed later. +None of the information contained within the `api.{consts, query, tx}..` endpoints are hard coded in the API. Rather everything is fully decorated by what the metadata exposes and is therefore completely dynamic. This means that when you connect to different chains, the metadata and API decoration will change and the API interfaces will reflect what is available on the chain you are connected to. + ## Types The metadata defines the calls with all the type names used in the various interfaces. At the moment (this is undergoing investigations and could improve in future versions of metadata), this also means that the types between the API and the node need to be aligned. For instance, by default Substrate defines a `BlockNumber` type as a `u32` and the API follows the Substrate defaults - if a chain has a different definitions, the API needs to be aware of this so it can actually decode (and encode) the type.