JoshOrndorff / substrate-recipes

A Hands-On Cookbook for Aspiring Blockchain Chefs
GNU General Public License v3.0
380 stars 184 forks source link

Runtime Interface / Custom Host Function #437

Open JoshOrndorff opened 3 years ago

JoshOrndorff commented 3 years ago

Substrate has the notion of host functions. They are code that runs on the client-side and can be called by the runtime. The standard ones are for cryptography. It is possible to add your own host functions. The recipes should cover this.

@HammeWang has done an [example using sm2 cryptography](https://github.com/hammeWang/substrate-sm2_ and presented it on Substrate Seminar

@tgmichel has done a minimal example as learning for Moonbeam https://github.com/PureStake/moonbeam/pull/402/commits/c5f546631f9293a689512268dec99d232c870344

This is a nice couterpart to the Runtime API recipe. They are both examples of crossing the wasm boundary, but in opposite ways.