# Compatibility with the EVM

The eSpace implements an Ethereum Virtual Machine (EVM). Below are some differences between eSpace and Ethereum:

- The
`NUMBER`

opcode will return the tree-graph`epoch number`

. As a result,`block.number`

used in eSpace contracts will not grow at a stable and predictable rate, and so it might not be suitable for measuring time. - The
`BLOCKHASH`

opcode can only take`NUMBER-1`

as input. (Unlike Ethereum, which takes any integer in`NUMBER-256`

to`NUMBER-1`

as input) - Block generate rate is 1.25s per block (mainnet)
- Contract max code size is
`49152`

double as Ethereum - No gas refund in
`SSTORE`

opcode and`SUICIDE`

opcode. - The operations which occupy storage have a different gas cost.
`SSTORE`

costs 40000 gas (instead of 20000 gas in Ethereum) when changing a storage entry from zero to non-zero.- When deploying a new contract, each byte costs 400 gas (instead of 200 gas in Ethereum).
- When creating a new account by
`CALL`

or`SUICIDE`

, it consumes 50000 gas (instead of 25000 gas in Ethereum).

- At most
`1/4`

of transaction`gasLimit`

will be refund (if not used) - Only the block whose block height is a multiple of
`5`

can pack Ethereum type transaction. The total gas limit of these transaction cannot exceed half of the block gas limit (1500w).

## #

Precompiles### #

Standard precompilesAddress | ID | Name | Spec | Status |
---|---|---|---|---|

0x01 | `ECRecover` | ECDSA public key recovery | Yellow Paper | âœ… |

0x02 | `SHA256` | SHA-2 256-bit hash function | Yellow Paper | âœ… |

0x03 | `RIPEMD160` | RIPEMD 160-bit hash function | Yellow Paper | âœ… |

0x04 | `Identity` | Identity function | Yellow Paper | âœ… |

0x05 | `ModExp` | Big integer modular exponentiation | EIP-198 | âœ… |

0x06 | `BN128Add` | Elliptic curve addition | EIP-196 | âœ… |

0x07 | `BN128Mul` | Elliptic curve scalar multiplication | EIP-196 | âœ… |

0x08 | `BN128Pair` | Elliptic curve pairing check | EIP-197 | âœ… |

0x09 | `Blake2F` | BLAKE2b `F` compression function | EIP-152 | âœ… |

## #

Phantom transactionsA *cross-space transaction* is a transaction in the Conflux core space that, at some point during its execution, calls one of the state-changing (i.e., not `view`

) methods of the `CrossSpaceCall`

internal contract.
Such transactions can change CFX balances and contract storage in both spaces, core and eSpace.

As EVM clients are not aware of Conflux space transactions (the two spaces use different transaction formats), we construct one or more *phantom* transactions (aka *virtual* transactions) for each call to the `CrossSpaceCall`

internal contract.
These phantom transactions are derived from the corresponding core space transaction, they do not exist in the ledger.
Phantom transactions have the following special properties:

`gas`

and`gasPrice`

are`0`

. Gas for cross-space transactions is charged in the core space. Therefore, the corresponding phantom transactions do not consume any gas.- Invalid signature (
`r`

,`s`

,`v`

,`standardV`

). The Conflux protocol is unable to sign transactions on behalf of the sender of the cross-space transaction. Therefore, phantom transactions use a fake signature that will not pass ECDSA verification.

### #

ExampleWhen we retrieve epoch `0x72819`

in the Conflux core space, we see it contains a single Conflux transaction.

When we retrieve the corresponding block in the eSpace, we see it contains two phantom transactions.