Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
How to prevent "out of gas" errors?

Sometimes I encounter "out of gas" error, and it's hard to predict. Are there any best practices on how to deal with that and make sure in advance the code won't use too much gas?


This question was imported from Telegram Chat: https://t.me/tondev/125376

  
  
Posted 10 months ago
Votes Newest

Answers


There are two parts to this question. The first is ensuring that you don't encounter the "out of gas" error.

You can try to estimate a transaction's gas fee by first calling the http-api's estimateFee endpoint. You can see how TON Center does it on their documentation site. Essentially, you want to provide details about the transaction that you will send to see how much gas the transaction could cost or if it will fail.

{
  "address": "string",
  "body": "string",
  "init_code": "",
  "init_data": "",
  "ignore_chksig": true
}

The second part of this question is dedicated towards gas optimization. To optimize smart contracts on the TVM, you should understand how the compiler turns higher level languages into Fift. You can see how much each OP code costs on the documentation site. Generally speaking, the less you store, the less gas it costs.

  
  
Posted 10 months ago
Jeremy
384 × 5 Administrator
2K Views
1 Answer
10 months ago
10 months ago
Tags