VM Opcodes


Lity’s EVM is a stack-based, big-endian VM with a word size of 256-bits and is used to run the smart contracts on the blockchain. Each opcode is encoded as one byte.


  • integer : UADD, UMUL, USUB, SADD, SSUB, SMUL
  • fixed-point : UFMUL, SFMUL, UFDIV, SFDIV

The values are popped from the operand stack, and the result will be pushed back to the stack. Opcode starts with S is a signed operation, and U is an unsigned operation.

All arithmetic operations are overflow-checked. An overflow would cause the contract execution fail. See overflow protection for more details.


This operation will check whether an address popped from the stack is a validator of CyberMiles blockchain, and the result will be pushed back to the stack. With this feature, smart contract developers can make a contract modifiable only by the validators.

See Validator Only Contract for more details.


This operation allows developers to use contract balance to pay the transaction fee for the users. See Freegas-Let contract owner pay the tx fee for you for more details.


This operation will use random seed, nonce, code hash, and a counter number to generate a random number. After RAND is called, the counter will automaticlly increase. The counter number depends on the the called time of RAND. Even if transations are in the same code block, we can still receive different results.

See Rand-Get random number on the chain for more details.


OpCode uint8 Stack Input Stack Output Expression Notes
UADD 0x01 [a|b|$ [a+b|$ a + b unsigned integer addition
UMUL 0x02 [a|b|$ [a*b|$ a * b unsigned integer multiplication
USUB 0x03 [a|b|$ [a-b|$ a - b unsigned integer substraction
SADD 0x0c [a|b|$ [a+b|$ a + b signed integer addition
SSUB 0x0d [a|b|$ [a-b|$ a - b signed integer substraction
SMUL 0x0e [a|b|$ [a*b|$ a * b signed intger multiplication
UFMUL 0x2a [a|b|N|$ [a*b/pow(10,N)|$ A [1] * B [2] unsigned fixed-point multiplication
SFMUL 0x2b [a|b|N|$ [a*b/pow(10,N)|$ A [1] * B [2] signed fixed-point multiplication
UFDIV 0x2c [a|b|N|$ [a*pow(10,N)/b|$ A [1] / B [2] unsigned fixed-point division
SFDIV 0x2d [a|b|N|$ [a*pow(10,N)/b|$ A [1] / B [2] signed fixed-point division
ENI 0xf5        
ISVALIDATOR 0xf6 [addr|$ [boolean|$ isValidator(addr) make a contract modifiable only by the validators
SCHEDULE 0xf7        
FREEGAS 0xf8 [|$ [|$ function modifier freegas let contract owner pay the tx fee for you
RAND 0xf9 [|$ [keccak256|$ rand() get the random number on the chain
[1](1, 2, 3, 4) A = a * pow(10,N)
[2](1, 2, 3, 4) B = b * pow(10,N)