超时免费 TON Solidity 错误:代码:3025 合同执行因错误而终止

问题描述

免费 TON solidity 代码或执行错误。无法理解我的错误,我已经将代码压缩到最小:

cat ./SimpleStorage.sol

pragma solidity >=0.6.0;

contract SimpleStorage {
    uint storedData;
    function set(uint x) public {
        storedData = x;
    }
    function get() public view returns (uint) {
        return storedData;
    }
}

tonos-cli call 0:efbeed7533cae6f12869b665b610c30535397c5c1523f6b41561905807aed958 set '{"x":100}' --abi ./Simple.jsonStorage.abi

Input arguments:
address: 0:efbeed7533cae6f12869b665b610c30535397c5c1523f6b41561905807aed958
method: set
params: {"x":100}
abi: ./SimpleStorage.abi.json

然后结果我在超时时收到错误

code: 3025
message: Contract execution was terminated with error

解决方法

您需要在存储变量之前启用gas。 tvm.accept 可以做到。

  function set(uint x) public {
        tvm.accept();
        storedData = x;
  }