I am new to substrate and I am working on a project (in substrate) and as per the requirement I have to store the map key and value on a external database and to do so I chosen mongodb but I don't know how to implement it in runtime. or there are any other ways to use external code written in rust and use it inside the pallet...
Asked
Active
Viewed 90 times
-3
-
Please provide enough code so others can better understand or reproduce the problem. – Community Aug 28 '21 at 18:57
1 Answers
0
The runtime should be considered a sandboxed environment and cannot easily talk to the outer client.
We do define a set of host functions which specifically describe the interface between the runtime and the client, but this is probably the wrong way to approach your problem.
Instead you probably want to run a second service which listens to your chain and forms the DB with the information you want.
Take a look at: https://github.com/paritytech/substrate-archive
And other such indexing solutions.

Shawn Tabrizi
- 12,206
- 1
- 38
- 69