0

I am getting the actions log data using an action constructor in a smart contract. I need to save this data in MongoDB from the smart contract. How can I do this? I didn't get exactly my required solution. How do I use MongoDB in eosio smart contracts? Any help would be appreciated. I am using Ubuntu 18.04 LTS on Windows 10.

1

You can't access mongodb from smart contract at all. It is executed in closed and segregated context and can't communicate with external network except for internal state. Internal state here means data stored by eosio::multi_index.

Once transaction is recorded, you can make a monitoring daemon to read it from block and do something for your demand like saving data into mongodb.

4
  • Hi..thanx for the answer. Monitoring daemon to read means accessing smart contract related data through API like eos-sharp or eosjs. right?
    – Varsh
    Apr 22 '20 at 2:14
  • @Varsh Correct.
    – conr2d
    Apr 22 '20 at 3:01
  • Hey @conr2d, If I want to save eos transaction data to MongoDB using web API, do I need to install MongoDB externally or connecting internally with EOS is possible?
    – Varsh
    Feb 8 at 10:52
  • @Varsh The feature you describe is supported by deprecated mongo_db_plugin. You can try using it (I think it still works), but you may need to build nodeos including mongo_db_plugin by yourself. You could write fill-mongodb plugin for history-tools which is an external daemon but fills mongodb with tx data, but it would require knowledge for writing plugin in c++.
    – conr2d
    Feb 8 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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