Hey there. I have such a question. I have a database (where exactly to create it?) With ceratin fields. And depending on the values from this fields smartcontract should send crypto to certain address. For example if the value in the certain cell in database is 50 - so the smartconract should send 1eth. If the value is 70 - smartcontract should send 2eth. How this can be released? I mean how it's possible to make SQL queries from smartcontract , and which database to use to keep everything secure?


And if these database values are live updating, how to do release it through contract ? I mean for example there is the aluminum price. Today it's for example 100usd. So if it's 100usd , smart contract should send to my wallet 1eth. If tomorrow the price will change to 200usd, smartcontract should send me 2eth. Can the smartcontract somehow checks the values from the outside ?

Feb 7, 2023, 11:22 AM
Smart contract can't chack off chain values
Any program from outside can check values on the block chain and call a smart contract function

Also outside programs or off chain programs can listen to events and then do an action which can be off chain or in the block chain
Feb 7, 2023, 11:39 AM
And how this outside program , for example written on js, checking values in the database in the end of each day, can call a smartcontract function?
Feb 7, 2023, 11:42 AM
this would require a script that both talks with your backend & blockchain
the script should do queries to the database, pass the results to the contract call.
Maybe you want to check this before starting from scratch?
https://www.openzeppelin.com/defender
you can write an autotask or bind it to a sentinel, you can store 1000 K:V items as free user on it (to avoid using a database, otherwise you should code the connection&elaboration inside the autotask script)
👍
Feb 7, 2023, 12:06 PM

© 2024 Draquery.com All rights reserved.