0

I am trying to build a smart contract that will need to rely on off-chain information from a trusted server in order to gather to the state of something which will impact on how the UTXO should be spent.

what is a strategy that i can use in order to have the on chain script make an some sort of http request to a trusted api server in order to get the status of something which can branch the decision of the on chain logic?

thanks for any suggestions.

1 Answer 1

1

Unfortunately, there is no way to make http calls from on-chain.

The only way to have off-chain information available on-chain is via transactions. Either the caller of the smart contract can bring the information with their transaction or the smart contract can reference data put on chain with previous transactions.

I'm guessing the latter is what you're looking for, what we call an "oracle". The data can be made available on the datum of some output (or "reference output") at another script address. You can make the updating of that data locked and only accessible by the "trusted" party's public key with a separate contract. Your smart contract can then reference the output that has the data on it.

There are additional ways you can customize this relationship, but that would be straying from your original question.

I hope that helps.

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.