Differences from EVM

TVM is basically compatible with EVM with some differences in details

  • TVM uses energy instead of gas. The energy price is currently 280 sun

  • GASPRICE, DIFFICULTY and GASLIMIT return zero in TVM; BASEFEE is currently not supported

  • Most opcodes in TVM have the equivalent energy consumption as in the EVM, some of them are lower(e.g., SLOAD, CALL)

  • Contract address prefix created by CREATE2 is different from EVM: TVM chooses 0x41 as the prefix, the formula is keccak256( 0x41 ++ address ++ salt ++ keccak256(init_code))[12:]

  • Pre-compiled contract Ripemd160(0x03): TVM calculates SHA-256 twice on the input. There will be a new pre-compiled contract to implement the standard Ripemd160

  • Pre-compiled contract 0x09: EVM has Blake2F on this address; on TVM it is BatchValidateSign. See TIP-43

  • There are two ways to send TRX to contracts: Transfer and TriggerSmartContract with a callValue. Transfer will not call fallback functions in the contracts

TVM has new features bases on TRON's characteristics

  • TRC-10 related opcodes: CALLTOKEN(0xd0), TOKENBALANCE(0xd1), CALLTOKENVALUE(0xd2) and CALLTOKENID(0xd3)

  • Judging whether an address belongs to a contract: ISCONTRACT(0xd4) TIP-44

  • Batch validations for normal and multiple signatures: BatchValidateSign(0x09)TIP-43, ValidateMultiSign(0x0a)TIP-60

  • Anonymous contract and Librustzcash related pre-compile contracts: verifyMintProof(0x1000001), verifyMintProof(0x1000002), verifyMintProof(0x1000003) and merkleHash(0x1000004). See TIP-135, TIP-137 and TIP-138.

  • Freeze / Unfreeze functions: FREEZE(0xd5), UNFREEZE(0xd6) and FREEZEEXPIRETIME(0xd7). See TIP-157.

  • Contract voting related opcodes and pre-compiled contracts: VOTEWITNESS(0xd8), WITHDRAWREWARD(0xd9), RewardBalance(0x1000006), IsSrCandidate(0x1000006), VoteCount(0x1000007), UsedVoteCount(0x1000008), ReceivedVoteCount(0x1000009) and TotalVoteCount(0x100000a). See TIP-271.

Compatible solutions are currently under discussion, if you are interested, please move to the GitHub ISSUE to participate in the discussion.