什么是 Cosmos EVM?
什么是 Cosmos EVM?
Cosmos EVM 是一个开源的 Cosmos SDK 模块,它将完整的以太坊虚拟机嵌入到基于 CometBFT 的区块链中。你可以启动一条主权 L1,运行标准 Solidity 合约并支持完整的以太坊工具链,同时还可获得以太坊不具备的能力:单区块终局性、无重组、原生 IBC 跨链转账,以及智能合约可直接访问 Cosmos SDK 模块。与 Rollup 不同,你可以自行控制验证者集合、治理机制和手续费经济模型。更多信息请参见概览。
它与以太坊兼容吗?
它与以太坊兼容吗?
是的,完全兼容。Cosmos EVM 链实现了完整的以太坊 JSON-RPC API,并执行相同的 EVM 字节码。在以太坊上可运行的合约,无需修改代码即可在 Cosmos EVM 上运行;MetaMask、Hardhat、Foundry、ethers.js 和 viem 等工具也都可以直接使用。差异体现在新增能力,而不是替代原有能力:更快的终局性(约 1–2 秒,相比以太坊约 3 分钟)、无重组、原生 IBC,以及可从 Solidity 暴露 Cosmos SDK 功能的 precompiles。完整说明请参见 EVM Compatibility 页面。
是否完整支持 Solidity?
是否完整支持 Solidity?
是的。所有操作码、ABI 编码和库的行为都与以太坊相同。任何能在以太坊上编译和运行的合约,都可以无需修改地运行在 Cosmos EVM 链上。只需将你的工具指向该链的 RPC endpoint 和 chain ID 即可。
部署合约有什么不同吗?
部署合约有什么不同吗?
没有。使用指向你的链 JSON-RPC endpoint 的 Hardhat、Foundry 或 Remix 即可。部署通过
eth_sendRawTransaction 发起,并由 EVM 模块以与以太坊相同的方式处理。合约会获得一个以太坊地址,并按预期运行。若需查看使用 Forge 逐步部署的完整流程,请参见快速开始指南。我可以使用哪些工具?
我可以使用哪些工具?
任何支持标准以太坊 JSON-RPC 的工具都可以无需修改直接使用:
- 合约开发: Hardhat, Foundry, Remix
- 库: ethers.js, viem, wagmi, web3.js
- 钱包: MetaMask, Rabby, WalletConnect, Keplr
- 区块浏览器: Blockscout
支持哪些 EIP?
支持哪些 EIP?
Cosmos EVM 支持截至 Prague 硬分叉的所有标准 EVM 操作码和 EIP。以下是其中一些值得关注的项目:
有两项不支持:EIP-4844(blob 交易)和 EIP-4399(PREVRANDAO)。完整列表请参见 EVM Compatibility 页面。
| EIP | 用途 |
|---|---|
| EIP-155 | 通过签名中的 chain ID 提供重放保护 |
| EIP-712 | 类型化结构化数据签名 |
| EIP-1559 | 动态手续费(基础费 + 优先费) |
| EIP-2535 | 用于可升级合约的 Diamond 代理模式 |
| EIP-4337 | 账户抽象 |
| EIP-7702 | 为 EOA 设置代码 |
什么是 precompiles?
什么是 precompiles?
Precompiles 是部署在固定地址上的智能合约接口,其实现由原生 Go 代码执行,而不是 EVM 字节码。在标准以太坊中,precompiles 用于处理签名校验、哈希等操作。Cosmos EVM 新增了有状态 precompiles,使 Solidity 合约可以直接与 Cosmos SDK 模块交互。在 Solidity 中,你可以调用 staking precompile 进行代币委托,调用 governance precompile 提交提案,或调用 ICS20 precompile 发起 IBC 转账,而且这些都可以在单笔交易中完成。内置 precompiles 包括:
完整地址和接口列表请参见 Precompiles Overview。
| Precompile | 地址 | 用途 |
|---|---|---|
| Staking | 0x...0800 | 委托、取消委托、领取奖励 |
| Distribution | 0x...0801 | 质押奖励和社区资金池 |
| ICS20 | 0x...0802 | IBC 跨链代币转账 |
| Bank | 0x...0804 | 原生 Cosmos 代币的 ERC-20 访问接口 |
| Governance | 0x...0805 | 提交提案和投票 |
什么是预部署合约?
什么是预部署合约?
预部署合约(也称为 preinstalls)是从创世区块开始就部署在其标准以太坊地址上的标准 EVM 合约。任何预期它们位于这些地址的工具都可以直接使用,无需额外设置。Cosmos EVM 默认内置五个:
地址、配置以及如何添加你自己的合约,请参见 Predeployed Contracts 页面。
| 合约 | 用途 |
|---|---|
| Create2 | 确定性合约部署 |
| Multicall3 | 在一笔交易中批量执行多个调用 |
| Permit2 | 基于签名的 ERC-20 授权 |
| Safe Singleton Factory | 部署 Safe 多签钱包 |
| EIP-2935 | 历史区块哈希存储 |
如何开始?
如何开始?
最快的方式是在本地运行示例链。整个过程只需几分钟,并且只依赖 Go 和 Make。Quick Start 指南涵盖了克隆仓库、启动链、连接钱包以及部署你的第一个合约。
如何从 cosmos/evm v-0.1.x 升级到 v0.3.x 或更高版本?
如何从 cosmos/evm v-0.1.x 升级到 v0.3.x 或更高版本?
我们正在编写迁移指南,会尽快发布到这里。
`secp256k1` 和 `ed25519` 有什么区别?
`secp256k1` 和 `ed25519` 有什么区别?
两者都是可提供 128 位安全性的椭圆曲线算法。实际差别主要在于兼容性与攻击面。secp256k1 是比特币和大多数 EVM 链使用的曲线。它经过充分验证,支持广泛,在需要与现有加密基础设施互操作时是更自然的选择,包括以太坊工具和钱包。ed25519 在签名验证方面更快,并且能够抵御某些可能影响 secp256k1 的侧信道攻击。Cosmos SDK 验证者默认使用 ed25519,原因就在于此。代价是工具支持面相对更窄,不过这一差距这些年已经在逐步缩小。在实践中,通常由具体场景决定选择:EVM 合约和以太坊风格账户使用 secp256k1;Cosmos 验证者密钥使用 ed25519。
在哪里可以找到 Cosmos EVM 的 Protobuf 接口?
在哪里可以找到 Cosmos EVM 的 Protobuf 接口?
请参见 Cosmos 的 Buf 项目页面。
What is Cosmos EVM?
What is Cosmos EVM?
Cosmos EVM is an open-source Cosmos SDK module that embeds a full Ethereum Virtual Machine into a CometBFT-based blockchain. You can launch a sovereign L1 that runs standard Solidity contracts and supports the full Ethereum toolchain, while also getting things Ethereum doesn’t have: single-block finality, no reorganizations, native IBC cross-chain transfers, and direct Cosmos SDK module access from smart contracts.Unlike rollups, you control your own validator set, governance, and fee economics. See the overview for more.
Is it compatible with Ethereum?
Is it compatible with Ethereum?
Yes, fully. Cosmos EVM chains implement the complete Ethereum JSON-RPC API and execute the same EVM bytecode. Contracts that work on Ethereum work on Cosmos EVM without code changes, and tools like MetaMask, Hardhat, Foundry, ethers.js, and viem all work as-is.The differences are additions, not substitutions: faster finality (~1–2 seconds vs. ~3 minutes on Ethereum), no reorgs, native IBC, and precompiles that expose Cosmos SDK functionality from Solidity. See the EVM Compatibility page for a full breakdown.
Is full Solidity supported?
Is full Solidity supported?
Yes. All opcodes, ABI encoding, and libraries work the same as on Ethereum. Any contract that compiles and runs on Ethereum runs on a Cosmos EVM chain without modification. Point your tooling at your chain’s RPC endpoint and chain ID and you’re set.
Is deploying a contract any different?
Is deploying a contract any different?
No. Use Hardhat, Foundry, or Remix pointed at your chain’s JSON-RPC endpoint. Deployment goes through
eth_sendRawTransaction and is processed by the EVM module the same way as on Ethereum. The contract gets an Ethereum address and behaves as expected.See the quick start guide for a step-by-step deployment walkthrough with Forge.What tools can I use?
What tools can I use?
Any tool that speaks standard Ethereum JSON-RPC works without modification:
- Contract development: Hardhat, Foundry, Remix
- Libraries: ethers.js, viem, wagmi, web3.js
- Wallets: MetaMask, Rabby, WalletConnect, Keplr
- Block explorers: Blockscout
What EIPs are supported?
What EIPs are supported?
Cosmos EVM supports all standard EVM opcodes and EIPs up to the Prague hard fork. Some notable ones:
Two things are not supported: EIP-4844 (blob transactions) and EIP-4399 (PREVRANDAO). See the EVM Compatibility page for the complete list.
| EIP | Purpose |
|---|---|
| EIP-155 | Replay protection via chain ID in signatures |
| EIP-712 | Typed structured data signing |
| EIP-1559 | Dynamic fees (base fee + priority fee) |
| EIP-2535 | Diamond proxy pattern for upgradeable contracts |
| EIP-4337 | Account abstraction |
| EIP-7702 | Set code for EOAs |
What are precompiles?
What are precompiles?
Precompiles are smart contract interfaces at fixed addresses where the implementation runs as native Go code rather than EVM bytecode. On standard Ethereum, precompiles handle things like signature verification and hashing. Cosmos EVM adds stateful precompiles that let Solidity contracts interact directly with Cosmos SDK modules.From Solidity, you can call the staking precompile to delegate tokens, the governance precompile to submit a proposal, or the ICS20 precompile to send an IBC transfer, all within a single transaction. Built-in precompiles include:
See the Precompiles Overview for the full list of addresses and interfaces.
| Precompile | Address | Purpose |
|---|---|---|
| Staking | 0x...0800 | Delegate, undelegate, claim rewards |
| Distribution | 0x...0801 | Staking rewards and community pool |
| ICS20 | 0x...0802 | IBC cross-chain token transfers |
| Bank | 0x...0804 | ERC-20 access to native Cosmos tokens |
| Governance | 0x...0805 | Submit proposals and vote |
What are predeployed contracts?
What are predeployed contracts?
Predeployed contracts (also called preinstalls) are standard EVM contracts deployed at their canonical Ethereum addresses from genesis. Any tooling that expects them at those addresses works without extra setup.Cosmos EVM ships five by default:
See the Predeployed Contracts page for addresses, configuration, and how to add your own.
| Contract | Purpose |
|---|---|
| Create2 | Deterministic contract deployment |
| Multicall3 | Batch multiple calls in one transaction |
| Permit2 | Signature-based ERC-20 approvals |
| Safe Singleton Factory | Deploy Safe multisig wallets |
| EIP-2935 | Historical block hash storage |
How do I get started?
How do I get started?
The quickest path is running the example chain locally. It takes a few minutes and only requires Go and Make. The Quick Start guide covers cloning the repo, starting the chain, connecting a wallet, and deploying your first contract.
How can I upgrade from cosmos/evm v-0.1.x to v0.3.x or later?
How can I upgrade from cosmos/evm v-0.1.x to v0.3.x or later?
We’re working on a migration guide for this and will have it posted up here as soon as possible!
What is the difference between `secp256k1` and `ed25519`?
What is the difference between `secp256k1` and `ed25519`?
Both are elliptic curve algorithms that produce 128-bit security. The practical difference is compatibility vs. attack surface.secp256k1 is the curve used by Bitcoin and most EVM chains. It’s well-tested, broadly supported, and the natural choice when you need to interoperate with existing crypto infrastructure, including Ethereum tooling and wallets.ed25519 is faster for signature verification and resistant to certain side-channel attacks that can affect secp256k1. Cosmos SDK validators default to ed25519 for this reason. The tradeoff is narrower tool support, though that gap has closed over time.In practice, the context usually decides for you: EVM contracts and Ethereum-style accounts use secp256k1; Cosmos validator keys use ed25519.
Where can I find the Protobuf interfaces for Cosmos EVM?
Where can I find the Protobuf interfaces for Cosmos EVM?
See the Cosmos Buf project page.