Typecript error: invalid format: Integer too large

Typecript error: invalid format: Integer too large

我在使用 Typescript 的 Neo One 智能合约框架方面遇到了问题。 我正在变成这个错误“部署 → 格式无效:整数太大:66547 > 65536:-32603”。 没有出现这个问题的行号,有时候好像是随机调用这个错误。

这是它现在出现的行。 this.orderExist()..:[=​​13=]

public sendORDERS(orderId : Fixed<8>, actorAddress : Address){
    if(this.onlyBy(actorAddress) &&
    this.orderExist(orderId, false)){   //error
        //
        // only comments
    }
}

调用的函数如下所示:

 @constant
public orderExist (orderId: Fixed<8>, state: boolean){
    const currentState = this.getOrderState(orderId);
    if(currentState == 0 && state == false) 
        return true;  
    else if(currentState != 0 && state == true){
        return true;
    }
    return false;
}

getOrderState() 看起来像这样:

  @constant
public getOrderState(orderId: number): Fixed<8>{
    const state = this.orderState.get(orderId);
    return state === undefined ? 0 : state;
}

有什么想法吗? 我正在使用 typescript 3.6.3 ,它应该与 Neo One Framework 兼容。

提前致谢。

问题是我的合同太大(代码太多)。这也导致了“未知错误”。

This is a known limitation of smart contracts. There's a hard limit on smart contract sizes (in bytecode) and there's also a similar difficulty with compiling large contracts that has to do with the NeoVM max number size The way around this is to only do logic in your smart contract that absolutely must be executed on the blockchain (ie. in the NeoVM) Or you can split your smart contract into multiple smart contracts that then call each other for different logic.

  • 斯宾塞·科温