Issue creating query with a contract

Hello everyone,

I am using a contract with a part in this url: Hastebin: Send and Save Text or Code Snippets for Free | Toptal®

Calling query method with/without value >= 100000000000000000 is giving this error:

(If you want to call it without or lower value, You need to make a change in required condition or oracle register fee)

Hi @VitalJeevanjot

I fail to understand your problem. Can you elaborate what is the issue?

From your contract:

    stateful entrypoint createOracle() : oracle(string, string) =
        let oracle_created : oracle(string, string) = Oracle.register(Contract.address, 100000000000000000, RelativeTTL(10000))
        Chain.event(OracleCreated(oracle_created, "New oracle created"))
        oracle_created

You register your oracle with a fee for any query to your oracle to be 100000000000000000. This means that if you try calling the oracle with a smaller fee, it will be an invalid query. You actually store that value in your contract’s state as base_fee so you can later check if enough tokens were provided to the query method:

         require(state.base_fee =< Call.value, "insufficient value for qfee") 

So yes, if you call this without an amount - the check above will fail and your contract call will result in an error. Yes, if you provide less than base_fee, this same check will fail again.

So you register an oracle with a fee and then check if it were provided in order to call the oracle. What is the issue you’re facing?

While we are there - the error message displayed looks misleading. Since the node provides a HTTP endpoint with the info of the transaction (/v3/transactions/{hash}/info) which comes along with a return_value - my question regarding this tool is - why isn’t it shown there? I am not sure who to ping, so I shoot at random, if you’re not responsible for this, please ping the correct recipient of the ping: @nikitafuchs.chain @bruteforce.chain @philipp.chain

1 Like

@dimitar.chain The error is misleading in both ways, either failing at require statement or passing it (It just doesn’t execute) with appropriate value sent.

I meant for query function not createOracle. Create query is not working on my end from the oracle in the contract.

What is the error message you get when you dry-run it?

And a code suggestion:

if(Map.lookup(Call.caller, state.reqc) == None)
  put(state{reqc[Call.caller] = 0})
put(state{reqc[Call.caller] = state.reqc[Call.caller] + 1})

Is equivalent to:

put(state{reqc[Call.caller = 0] @ c = c + 1})
1 Like

After Dry-run, I got

Then I think the actual problem is that the contract you are trying to call does not exist? Did you check that the contract create was successful?

@hanssv.chain It could be the case also Because I did say the deployed address at the contracts interface…

it occurs same on Mainnet where i did deployed it at ct_sNVvvS4oCcX6QwFsEk3EuLNoikQGrAdXPpbrTh5cp48ib7rRX

and on testnet like above test, I just redeployed it and got the result at (Incognitor mode) ct_2TGVNTNvLjsXhqTbqw39AtB59WjbDSshMhLPD9Zb4yzdAmHLJF

But there are some complications indeed, Like Aestudio wasn’t deploying it on testnet but it did on mainnet multiple times but some times it stucks at loading, It thought the symptoms to be Oracle with big number as fee not deploying or cannot transact to these. · Issue #57 · aeternity/fire-editor · GitHub

Right now on trying again to deploy on testnet, It stucks at (regular mode, Redeploy same account)

Nick do mentioned Nounce issue and I suspect it could be it, Does my contract in anyway stopping users account nounces to increase, Probably something to do with initializing oracle in init function ?

What occurs where? It is impossible to follow what you are trying to do, sorry. If the result of the dry-run is: (error message in picture :face_vomiting: ) then it means that you are calling a non-existing contract. That will not work. Ever.

So, which contract is it that you trying to call? (And is that contract running the code from your first post?) What does the tx look like?

I am sorry, I am also confused with all these different types of errors.

But what I am sure of is, when I do:

  • Copy this code hastebin
  • Deploy it
  • Run query method from above code.

The call never completes or invocation fails.

But using Greeter Example for oracles, In the end (After multiple tries) creates the query.

@hanssv.chain , Tried again just now…

Testnet: ct_2aKGf2J3FUPgcVYYHyTGLMB7cLPaCU7dTcd5MDnnirAgsLxcC8

Same code from: Hastebin: Send and Save Text or Code Snippets for Free | Toptal®
Gets:

{"rawTx":"tx_+LoLAfhCuEBFN21jXTUTQgzWveV+fM1WUFN4BAN2zQT9ECx3+HACeRJc16+KWF6F7xAhxj/pOCnErVO27xGjbCZtF6v+maUPuHL4cCsBoQEwV3K+wkNMEccNSmibkKnfZDt6lc8x1DhzoPYxtQbS02qhBc9XhSR3mgboYPyYokBCIgYrSxqCZuj5ebdKAsWE52K1A4alyF6mUAAAiAFjRXhdigAAgw9CQIQ7msoAjSsRiRYtxRsVaGVsbG81vg1U"}

And the testnet Account I use do have balance :slight_smile:

“Call Static Function” doesn’t seem to take an amount/value so that is why you are not successful there (the value is too small, as indicated by the error message).

For your contract - if you’d actually dry run it (which I did, and I guess it took about 5 minutes to setup) - you would get the error: <<"Error in oracle_query: too_long_ttl">> I.e. in your setup, the query you ask has a TTL that is longer than the TTL of the Oracle itself, of course that is not allowed.

2 Likes

Thank you @hanssv.chain .

That makes total sense, I increased the TTL in past.

  • Can you please tell me which tools you mostly use to run contracts ?
  • Is that the GitHub - aeternity/aesophia_cli: Aeternity Sophia CLI or Something else?
  • What is the maximum TTL for oracle & query? For oracle with some trial and error i figured around 999999, Is it correct?
  • Also as blocktime is 3 sec, 1000 TTL means 3000 seconds of oracle existence (despite the fact that it can be extended)?

I’m using my own node for example in this case I deserialized your Tx (tx_+LoL...) replaced a couple of the fields and called the aec_dry_run:dry_run/3.

The block time is 3 seconds, but the average generation time is 3 minutes, and TTL is in generations/key-blocks.

There is no maximum TTL for Oracles as far as I remember, but I must say it was a while since I did anything with oracles…

1 Like

Thank you @hanssv.chain