I've been exploring different repositories and noticed inconsistencies in how opcodes are defined. For example, in the ft and nft implementation within the token-contract repository, opcodes are defined as follows:
int op::transfer() asm "0x5fcc3d14 PUSHINT";
However, in the liquid-staking-contract repository, the definition is quite different:
const int op::nft_transfer = 0x5fcc3d14;
While I understand that these are essentially the same, I'm curious about the more commonly accepted or standard method for defining opcodes in func
Additionally, I've observed that the ft and nft implementation in the token-contract repository might be outdated. It uses builder_null from stdlib.fc in this repo, but the stdlib.fc in the official documentation doesn’t include it.
Could someone clarify these points for me?
Answer
Newer versions of FunC compiler added support for const, so in newly written code, you may use this feature, or use the old approach. Both are supported.
The const way of defining a constant is similar to other programming languages, so it can make your code easier to understand for readers.
Hello,
I've been exploring different repositories and noticed inconsistencies in how opcodes are defined. For example, in the ft and nft implementation within the token-contract repository, opcodes are defined as follows:
However, in the liquid-staking-contract repository, the definition is quite different:
While I understand that these are essentially the same, I'm curious about the more commonly accepted or standard method for defining opcodes in func
Additionally, I've observed that the ft and nft implementation in the token-contract repository might be outdated. It uses
builder_null
fromstdlib.fc
in this repo, but thestdlib.fc
in the official documentation doesn’t include it.Could someone clarify these points for me?
Answer
Newer versions of FunC compiler added support for
const
, so in newly written code, you may use this feature, or use the old approach. Both are supported.The
const
way of defining a constant is similar to other programming languages, so it can make your code easier to understand for readers.Original