I want to get a random value in my smart contract to provide a fair distribution of different tokens.

I read that using Harbinger to get values and use it for entropy could be the good way to do. But I can't figure out how to make a call to the deployed normalizer contract using Smartpy and then retrieve the given price value.

This is actually the method that I implemented but I get an error when I run it on the Granada network and I don't know how to retrieve the price value (I don't know where and how to pass a callback name)

@ sp.entry_point
def call_oracle(self):
    params_type = sp.TPair(sp.TString, sp.TAddress)
    oracle_params = sp.contract(params_type, self.data.oracle_address, entry_point="get").open_some()
    data_to_be_sent = sp.pair(sp.string("XTZ-USD"), sp.self_address)
    sp.transfer(data_to_be_sent, sp.mutez(0), oracle_params)
  • So my first question is, can I use directly the deployed Harbinger normalizer smart contract or do I need to develop and deploy my own ?
  • And second question, does anyone have an implementation example to call the normalizer smart contract from another smart contract using Smartpy ?

Thanks for your attention.

1 Answer 1


This project tezos-randomizer uses the Harbinger Oracle.

Try to have a look at this file: https://github.com/asbjornenge/tezos-randomizer/blob/c4e2134daa724c6338c01daba055b85397ffd97e/randomizer.py#L169

  • Thank you for your answer. But as I see the Caller contract call the Randomizer contract which has an entropy value. Does it mean that this entropy should be set by the contract administrator "by hands" ? Because I don't see any call to an oracle there.
    – Noctambul
    Dec 1, 2021 at 14:03
  • I've never used the harbinger oracle. But I think you want to do this: github.com/asbjornenge/tezos-randomizer/blob/… Dec 1, 2021 at 14:35
  • Thanks, I missed this one ! I'll try that :) !
    – Noctambul
    Dec 1, 2021 at 15:44

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.