Skip to content

Commit

Permalink
Add a couple EVM-related pages
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Apr 19, 2024
1 parent b5307bd commit 6c2f638
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pages/differences-with-ethereum.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Differences with Ethereum
## Opcode Differences

### PREVRANDAO

Since Sei doesn’t rely on the same pseudo-randomness way of determining the next validator like PoS Ethereum does, it doesn’t really have the `RANDOM` artifact that can be set as `PREVRANDO`'s return value. In Sei `PREVRANDAO` is set to return the hash of the current block time. For strong randomness guarantee needs in contracts logic, it’s advised to use external verifiable oracles (as is advised on Ethereum itself)

### COINBASE

Coinbase address on Sei is always sets to (the EVM address of) the global fee collector.

## State Root

Since Sei uses AVL-tree instead of MPT for data storage, Sei doesn’t have per-account state root. The global state root is the AVL-tree root which is also not equivalent to Ethereum’s overall state root (which is a MPT root)

## Block Hash

Block hash on Sei is computed based on block header in Tendermint data format, and as a result is different than Ethereum’s block Hash

## Base Fee & Tips

Sei supports all transaction types. However Sei does not fluctuate base fee based on block congestion. In fact base fee will always be 0 on Sei, meaning all fees will go to the validators (i.e. tips) and none will be burnt.

## Block Limit

Sei has a gas limit of 10M on pacific-1, compared to Ethereum’s 30M. In addition, Sei also has a byte size limit of 21MB, whereas Ethereum doesn’t have byte-denominated limits.

## Non-EVM Transactions

On Sei there exists non-EVM transactions which may update states accessible by EVM transactions. Simplest example would be bank balances, which may be updated by both native Cosmos bank send transactions and EVM send transactions. As a result, if certain offchain applications only parse EVM transactions, they may find certain state changes unattributable to any EVM transaction.

## Finality

Sei has instant finality, meaning that commitment levels of “safe”, “latest”, “justified”, and “finalized” on Ethereum are all the same thing on Sei.

## Pending State

On Ethereum the block proposer would execute its proposed block first (and update its local state) before broadcasting the proposal to others (the updated state would be marked “pending” until the node is accepted by other nodes), whereas on Sei the block proposer would broadcast first and only execute the proposal if it’s accepted (i.e. every node would execute the block at roughly the same time), so Sei does not really have a window when “pending state” exists.

## EIP-4788

On Ethereum, the Consensus Layer (CL) block root is published to the Execution Layer (EL) to give verifiable CL state to apps that rely on CL state without going through a third-party oracle. On Sei, we will instead rely on the staking precompile to give smart contracts access to state of the CL. The EL can stake, delegate, undelegate, and read CL state using the staking precompile.
210 changes: 210 additions & 0 deletions pages/evm-rpc-endpoints.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# EVM RPC Endpoints
Below is a list of EVM-RPC endpoints provided by default on a Sei RPC node. Your RPC provider may offer slightly different/extended specifications.

All endpoints are in the form of JSON-RPC and share the following request/response structure:
- request
- HTTP method: always "GET"
- header: `accept: application/json`
- header: `content-type: application/json`
- body (JSON):
- id: an arbitrary string identifier
- jsonrpc: always "2.0"
- method: endpoint name (e.g. "eth_sendRawTransaction")
- params: an array that differs from endpoint to endpoint
- response
- body (JSON):
- id: the same identifier in request
- jsonrpc: always "2.0"
- result: an object that differs from endpoint to endpoint


## Send Transactions
### eth_sendRawTransaction
Sends a signed transaction.
- param 1: string | hex-encoding of the signed transaction
- result: string | transaction hash

### sei_associate
Sends a transaction to establish association between the signer's Sei address and EVM address on-chain
- param 1: object
- custom_message: any string message
- r: the R-part of the signature over the Keccak256 hash of the custom message
- s: the S-part of the signature over the Keccak256 hash of the custom message
- v: the V-part of the signature over the Keccak256 hash of the custom message

## Transaction Lookup
### eth_getTransactionReceipt
Gets the receipt of a sent transaction
- param 1: string | transaction hash
- result: object | [receipt object](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt)

### eth_getTransactionByBlockNumberAndIndex
Gets transaction by the block number and the index of the transaction in the block
- param 1: string | block number, which can either be a hexadecimal number, or one of "safe", "finalized", "latest", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- param 2: string | transaction index as a hexadecimal number
- result: object | [transaction details](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyhash)

### eth_getTransactionByBlockHashAndIndex
Gets transaction by the block hash and the index of the transaction in the block
- param 1: string | block hash
- param 2: string | transaction index as a hexadecimal number
- result: object | [transaction details](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyhash)

### eth_getTransactionByHash
Gets transaction by the transaction hash
- param 1: string | transaction hash
- result: object | [transaction details](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyhash)

## Account Information
### eth_getTransactionCount
Gets the number of transactions sent by the account
- param 1: string | address
- param 2: string | block number or hash, which can be one of 1. block hash, 2. hexadecimal block number, 3. one of "safe", "finalized", "latest", "pending", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- result: string | hexadecimal form of the number of transactions

### eth_getBalance
Gets the balance in wei (i.e. 10^-12 usei) of the account
- param 1: string | address
- param 2: string | block number or hash, which can be one of 1. block hash, 2. hexadecimal block number, 3. one of "safe", "finalized", "latest", "pending", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- result: string | hexadecimal form of the wei balance

### eth_getCode
Gets EVM code stored at the account address
- param 1: string | address
- param 2: string | block number or hash, which can be one of 1. block hash, 2. hexadecimal block number, 3. one of "safe", "finalized", "latest", "pending", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- result: string | hexadecimal form of the code binary

### eth_getStorageAt
Gets value at given key of the account
- param 1: string | address
- param 2: string | hexadecimal form of the key
- param 3: string | block number or hash, which can be one of 1. block hash, 2. hexadecimal block number, 3. one of "safe", "finalized", "latest", "pending", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- result: string | hexadecimal form of the storage value

### eth_getProof
Gets the IAVL proof (note: not a MPT proof) of the given keys for an account
- param 1: string | address
- param 2: array of string | hexadecimal form of the keys
- param 3: string | block number or hash, which can be one of 1. block hash, 2. hexadecimal block number, 3. one of "safe", "finalized", "latest", "pending", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- result: object
- address - the requested address
- hexValues - an array of the hexdecimal form of the values at the given keys
- storageProof - an array of storage proofs, each of which follows this [format](https://github.com/sei-protocol/sei-tendermint/blob/main/proto/tendermint/crypto/proof.pb.go#L272-L274)

## Block Information
### eth_getBlockTransactionCountByNumber
Gets the count of EVM transactions (i.e. excluding native Cosmos transactions) in a block by its number
- param 1: string | block number, which can either be a hexadecimal number, or one of "safe", "finalized", "latest", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- result: string | hexadecimal form of the count

### eth_getBlockTransactionCountByHash
Gets the count of EVM transactions (i.e. excluding native Cosmos transactions) in a block by its hash
- param 1: string | block hash
- result: string | hexadecimal form of the count

### eth_getBlockByHash
Gets the block metadata and/or its EVM transactions by block hash
- param 1: string | block hash
- param 2: bool | whether to include transactions in the response
- result: object | [block info](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash)

### eth_getBlockByNumber
Gets the block metadata and/or its EVM transactions by block number
- param 1: string | block number, which can either be a hexadecimal number, or one of "safe", "finalized", "latest", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- param 2: bool | whether to include transactions in the response
- result: object | [block info](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash)

### eth_getBlockReceipts
Gets an array of EVM transaction receipt in a block by block number
- param 1: string | block number, which can either be a hexadecimal number, or one of "safe", "finalized", "latest", or "earliest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- result: array of objects | [receipt object](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt)

## Blockchain Information
### eth_blockNumber
Gets the latest committed block number
- no param
- result: string | hexadecimal form of the block number

### eth_chainId
Gets the chain ID
- no param
- result: string | hexadecimal form of the chain ID

### eth_coinbase
Gets the fee collector address
- no param
- result: string | fee collector address

### eth_feeHistory
Gets fee history over the requested block range
- param 1: string | number of blocks to look at, in either decimal or hexadecimal form
- param 2: string | block number, which can either be a hexadecimal number, or one of "safe", "finalized", or "latest". Note that "safe", "finalized", and "latest" mean the same thing on Sei due to its instant finality.
- param 3: array of floats | reward percentiles
- result: object

### eth_gasPrice
Gets the 50% percentile of gas prices in the most recent block
- no param
- result: string | hexadecimal form of the gas price

### net_version
Gets the version (equal to Chain ID)
- no param
- result: string | hexadecimal form of the chain ID

### web3_clientVersion
- no param
- result: string | the RPC node's runtime version

## Filter Endpoints
Note that log filters are subject to the following limits by default:
- 10000 logs in one response if block range is open-ended
- 2000 blocks to query over if block range is close-ended
Your RPC provider may tweak these limits.

### eth_newFilter
Creates a new log filter for later queries
- param 1: object | [filter criteria](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter)
- result: string | the newly created filter's ID

### eth_newBlockFilter
Creates a new block filter for later queries
- no param
- result: string | the newly created filter's ID

### eth_getFilterChanges
Gets all the updates since the filter was last queried
- param 1: string | filter ID
- result: array | for block filters, the result would be an array of block hashes; for log filters, the result would be an array of [log objects](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)

### eth_getFilterLogs
Get all logs for a given log filter, including the logs that have been returned before
- param 1: string | filter ID
- result: array | an array of [log objects](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)

### eth_getLogs
Get all logs for the given filter criteria
- param 1: object | [filter criteria](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter)
- result: array | an array of [log objects](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)

### eth_uninstallFilter
Removes a created filter
- param 1: string | filter ID
- result: bool | whether the filter exists

## Simulation Endpoints
### eth_estimateGas
Same as [the official specification](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas)

### eth_call
Same as [the official specification](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_call)

## Debugging Endpoints
### debug_traceTransaction
Same as [Alchemy](https://docs.alchemy.com/reference/debug-tracetransaction)

### debug_traceBlockByNumber
Same as [Alchemy](https://docs.alchemy.com/reference/debug-traceblockbynumber)

### debug_traceBlockByHash
Same as [Alchemy](https://docs.alchemy.com/reference/debug-traceblockbyhash)
3 changes: 3 additions & 0 deletions pages/interoperability/overview.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ImageWithCaption } from "../../components";
import interoperability from "../../public/assets/interoperability.png";

# EVM version
Shanghai

# EVM \<\> Wasm Interoperability
EVM and Cosmos based applications co-exist on Sei, but live in different execution environments.
This creates a challenge for users, who use wallets that typically only support a single execution environment.
Expand Down
23 changes: 23 additions & 0 deletions pages/quickstart/evm-cli-tutorial.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Interact with EVM on Sei via CLI
You can query or send transactions to Sei easily via CLI once you have the `seid` command installed (see `Installing Seid`)

## Queries
If the machine you run these commands aren't a node of the network, you'd need to append `--node http://url-to-sei-cosmos-rpc` to your command.

- `seid q evm sei-addr [some EVM address]`: gets the associated Sei address, if exists on-chain, of the queried EVM address
- `seid q evm evm-addr [some Sei address]`: gets the associated EVM address, if exists on-chain, of the queried Sei address
- `seid q evm erc20 [erc20 address] [method] [arguments...]`: query the ERC20 contract at given address for the given method/arguments
- `seid q evm payload [abi-filepath] [method] [arguments...]`: generate the hexadecimal payload of the requested method call given an ABI
- `seid q evm pointer [type] [pointee]`: gets the pointer contract of the requested pointee. `type` can be one of "NATIVE", "CW20", "CW721", "ERC20", or "ERC721", and `pointee` is the target contract address (except for "NATIVE" type, for which `pointee` would be the native denom name)

## Transactions
Sending transactions via CLI requires you to have keys added via `seid keys add`. You can then specify the key you want to use by appending `--from=[key name]` to your command.

If the machine you run these commands aren't a node of the network, you'd need to append `--evm-rpc http://url-to-sei-evm-rpc` to your command.

- `seid tx evm associate-address`: associate Sei address and EVM address on-chain for the sending key
- `seid tx evm send [to EVM address] [amount in wei]`: send native tokens to the target EVM address
- `seid tx evm deploy [path to binary]`: deploy an EVM contract
- `seid tx evm call-contract [addr] [payload hex]`: send a transaction that calls contract at the target address with the provided payload
- `seid tx evm erc20-send [addr] [recipient] [amount]`: send ERC20 tokens of contract at `addr` to the target recipient
- `seid tx evm delegate [val-addr] [amount]`: delegate specified amount to the target validator address. Note that the validator address would be in Sei/Cosmos validator address format
26 changes: 26 additions & 0 deletions pages/tools-and-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,29 @@ To support your development and testing efforts, we provide a range of public RP
</Tabs>

For more endpoint options, please visit our [chain registry](https://github.com/sei-protocol/chain-registry/blob/main/chains.json).

## Important Contract Info
Wrapped Sei
arctic-1: 0x63600a899ad94ae1bc638504fa56d8a6144df2fe
atlantic-2: TODO
pacific-1: TODO

USDC
arctic-1: TODO
atlantic-2: TODO
pacific-1: TODO

CW20 Pointer Code for ERC20
arctic-1: TODO
atlantic-2: TODO
pacific-1: TODO

CW721 Pointer Code for ERC20
arctic-1: TODO
atlantic-2: TODO
pacific-1: TODO

LayerZero Endpoint
arctic-1: 40258
atlantic-2: TODO
pacific-1: TODO

0 comments on commit 6c2f638

Please sign in to comment.