
如上图
代码
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
 * @title Storage
 * @dev Store & retrieve value in a variable
 */
contract Storage {
    uint[5][7] levelParams = [
        [200*1e18, 0, 18, 0, 40],
        [400*1e18, 10, 20, 0, 40],
        [800*1e18, 12, 22, 0, 40],
        [1000*1e18, 14, 24, 0, 40],
        [2000*1e18, 18, 28, 6, 50],
        [3000*1e18, 20, 30, 8, 60],
        [5000*1e18, 20, 30, 10, 70]
    ];
}把 [5000*1e18, 20, 30, 10, 70] 中的5000改成4000又是正常
我还真没有遇到过这个问题。
根据报错“Unable to deduce common type for array elements”, 找到了这个: https://gitter.im/ethereum/solidity/archives/2018/03/18
发现下面的方式可以解决:
uint256[5][7] levelParams = [
    [uint(200*1e18), 0, 18, 0, 40],
    [uint(400*1e18), 10, 20, 0, 40],
    [uint(800*1e18), 12, 22, 0, 40],
    [uint(1000*1e18), 14, 24, 0, 40],
    [uint(2000*1e18), 18, 28, 6, 50],
    [uint(3000*1e18), 20, 30, 8, 60],
    [uint(5000*1e18), 20, 30, 10, 70]
];