CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
115 stars 80 forks source link

Provide insight into bytesize and opcount of contracts #45

Closed rkalis closed 4 years ago

rkalis commented 4 years ago

Due to the limitations on bytesize (520 bytes) and opcount (201 ops), it can be valuable to quickly see whether your contracts conform to these limits. So we should add instance.bytesize and instance.opcount. Perhaps instance.sigops might be handy as well, but the first two are more important.

rkalis commented 4 years ago

It can also be nice to add the option to the cashc-cli to output bytesize and opcount when compiling.

rkalis commented 4 years ago

Added this in https://github.com/Bitcoin-com/cashscript/commit/199e5b887744d9ebc105e1aab7e34b7e734845e1. The CLI outputs a warning if any of the limits is exceeded. But it doesn't account for the constructor arguments. eg if the contract is 500 bytes, but the constructor arguments will be 50 bytes total, the compiler won't warn.