1

There are a couple of packages that are outdated or do not have the features I need for Dart-lang. So, I decided to code my own. There are really good implementations coded in various languages that are mentioned in the Substrate Docs.

My plan is to understand how it's coded and try to migrate it into Dart. One of the limitations of the Dart is the lack of unsigned integers.

I can Encode and Decode basic values for now. However, I don't really understand how to decode metadata.

Where should I look for metadata decoding in @polkadot/api or in any other languages?

Any suggestions or ideas would be great!

1 Answer 1

3

https://docs.substrate.io/v3/advanced/scale-codec/ is really enough to implement it completely.

Otherwise, here is TypeScript implementation we use at subsquid.io, which will be probably easier to understand than the one from polkadot.js.

Edit:

Somehow missed the metadata part of the question.

Metadata is a regular scale-encodable data-structure, which is supposed to be well known. You can have a look at its definition here. Its canonical encoding beside "regular bytes serialised by scale" also includes a special magic number prefix.

1
  • Your implementation is way more straightforward than other ones, IMHO. I migrated this to Dart and it works great! The only failing test is -100_i8. I'll investigate further once I got my coffee :)
    – Burak
    May 16, 2022 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.