Skip to content

Simulation Results

WARNING

SolidML is currently only available on our alpha testnet. It is not yet available on the official testnet.

All inference output types from OGInference have a flag called is_simulation_result that indicates whether the result returned is 'simulated' or not.

As explained in ML Execution, OpenGradient transactions are executed in 2 phases. In the first phase, the transaction is executed in simulation mode to gather and execute all inference requests in the background. Once the results are ready, the transaction is re-executed with the actual inference results. is_simulation_result indicates if the transaction is executed in simulation mode. When is_simulation_result=false, the value returned comes from the model; however, when it is_simulation_result=true, the value is empty.

Developers should explicitly handle both scenarios in their code.

NOTE

Transaction simulations and their output are never committed to the blockchain.

For example:

solidity
function calculateFeeFromModelResult(ModelOutput memory result) int128 {
    if (result.is_simulation_result) {
      // when in simulation, return some sensible default value
      return 1;
    }
    
    return result.numbers[0].values[0].value * 2;
}