Solidity 智能合约
Cosmos EVM 的智能合约开发流程与以太坊完全一致。能在以太坊上运行的合约,无需修改代码即可在 Cosmos EVM 上运行。相同的工具、相同的 Solidity、相同的模式。开发
使用 Hardhat、Foundry 或 Remix 编写 Solidity,无需任何自定义配置。只需将你的工具指向链的 JSON-RPC 端点和 chain ID,即可开始。支持工具的完整列表请参见工具概览,合约部署的分步演练请参见快速开始指南。部署
将标准以太坊工具指向你的链 RPC 端点,即可使用标准以太坊工具部署。部署交易会通过 JSON-RPC 或 Cosmos gRPC 接口进入,并由 EVM 模块处理。部署完成后,合约字节码会存储在链状态中,并可像其他链一样通过其以太坊地址调用。升级
Cosmos EVM 支持所有标准 EVM 升级模式:- 代理模式(EIP-1967、Transparent Proxy、UUPS):将调用委托给实现合约。升级时只需替换代理中的实现地址,无需变更代理的存储或地址。
- Diamond 模式(EIP-2535):将模块化合约拆分为多个可独立新增、替换或移除的“facet”。Diamond 会将调用路由到对应 facet,从而在无需重新部署整个合约的情况下实现细粒度升级。
支持的标准
Cosmos EVM 支持截至 Prague 硬分叉的所有标准 EVM opcode、EIP 和 ERC 代币接口。EIP
以下是部分值得关注的已支持 EIP;完整列表要长得多。| EIP | 名称 | 用途 |
|---|---|---|
| EIP-155 | 重放保护 | 在签名中加入 Chain ID,防止跨链重放攻击 |
| EIP-712 | 类型化结构化数据签名 | 可对结构化数据、可读消息和自定义 Cosmos 交易进行签名 |
| EIP-1559 | 动态费用 | 基础费 + 小费模型;基础费不会被销毁,而是分配给验证者 |
| EIP-2535 | Diamond 标准 | 面向可升级合约的代理模式,支持多个实现 facet |
| EIP-2935 | 历史区块哈希 | BLOCKHASH opcode 可访问最多 8192 个历史区块哈希(可配置) |
| EIP-4337 | 账户抽象 | 智能合约钱包可支付手续费、批量处理交易并使用自定义认证方案 |
| EIP-7702 | 为 EOA 设置代码 | 可临时为 EOA 分配合约代码,以支持赞助交易和复杂认证 |
ERC
任何可在 EVM 上运行的 ERC 标准都兼容 Cosmos EVM。最常用的包括:- ERC-20 - 同质化代币: 用于货币类表示的标准接口,包含转账、授权和额度机制。
- ERC-721 - 非同质化代币: 用于唯一资产标识、数字证书或所有权证明记录的标准。
- ERC-1155 - 多代币标准: 在单个合约中同时支持同质化与非同质化资产,可实现批量操作并降低复杂资产系统的部署成本。
Opcode
Cosmos EVM 支持截至 Prague 硬分叉的所有 EVM opcode。完整参考请参见 evm.codes。 以下内容不支持:- EIP-4844 - 携带 Blob 的交易: Blob 数据及 L2 专用功能。
- EIP-4399 - PREVRANDAO: 以
PREVRANDAO替代DIFFICULTYopcode 的变更。
工具
任何能够连接标准以太坊 JSON-RPC 端点的工具,都可以在 Cosmos EVM 上直接使用,无需自定义配置。| 工具 | 类别 |
|---|---|
| Hardhat, Foundry, Remix | 合约开发 |
| OpenZeppelin Contracts | 智能合约库 |
| Forge, Hardhat | 测试与模糊测试 |
| MetaMask, WalletConnect, Rabby | 钱包 |
| ethers.js, viem, web3.js, wagmi | JavaScript 库 |
| Blockscout | 区块浏览器 |
JSON-RPC
JSON-RPC 接口实现了完整的以太坊规范。将任何标准工具指向你的链 RPC 端点即可工作。以太坊 RPC 兼容性
大多数标准以太坊 JSON-RPC 方法都已支持,其中部分方法会返回占位值以保持兼容性。点击查看完整参考。
eth_sendRawTransaction、eth_call、eth_estimateGas、事件日志与过滤器、WebSocket 订阅,以及用于追踪的 debug 命名空间。
有几点需要了解:
eth_gasPrice返回 0,建议改用 EIP-1559 费用字段- 与挖矿相关的方法不适用(共识由 CometBFT 处理)
txpool方法要求启用实验性 mempool
超越以太坊
Cosmos EVM 在完整以太坊兼容性之上增加了更多能力。这些能力都不会改变现有合约或工具的行为方式。| 领域 | 以太坊 | Cosmos EVM |
|---|---|---|
| 出块时间 | 约 12 秒 | 1-2 秒 |
| 终局性 | 12+ 个区块(约 3 分钟) | 1 个区块(约 2 秒) |
| 重组 | 可能发生 | 不会发生 |
| 跨链 | 桥接协议 | 原生 IBC |
| 费用分配 | 基础费销毁 | 分配给验证者 |
终局性
Cosmos EVM 交易通过 CometBFT 共识在一个区块后(约 2 秒)即具备终局性,无需等待确认,也不存在重组。任意区块要被提交,都需要验证者集合中超过 2/3 的质押权重达成一致。Gas 与费用
Cosmos EVM 使用 EIP-1559 动态费用。与以太坊不同,基础费不会被销毁,而是分配给验证者和委托人。基础费也可以通过NoBaseFee 参数完全禁用,同时还可以配置全链最小 gas price 下限。
地址系统
每个账户都有两种表示形式,它们引用的是同一把底层密钥:Chain ID
Cosmos EVM 使用两个彼此独立的 chain ID:Cosmos Chain ID(字符串,例如cosmosevm-1)和 EVM Chain ID(整数,例如 9000)。它们分别配置,不同于早期 Ethermint 中两者格式耦合的方式。
预编译合约
预编译概览
内置 Cosmos 预编译及其地址的完整列表。
添加自定义预编译
为你的链启用内置预编译,或添加你自己的预编译。
预部署合约
Cosmos EVM 会在链状态中预置标准 EVM 基础设施合约,并使用其规范地址,包括 Create2、Multicall3、Permit2、Safe Singleton Factory,以及 EIP-2935 区块哈希存储。任何依赖这些知名地址上合约的工具都可直接运行,无需额外设置。预部署合约
了解哪些合约会被预装,以及如何在创世时预装合约。
关键预编译地址
| 功能 | 地址 |
|---|---|
| 质押 | 0x0000000000000000000000000000000000000800 |
| 分发 | 0x0000000000000000000000000000000000000801 |
| IBC 转账 | 0x0000000000000000000000000000000000000802 |
| 银行 | 0x0000000000000000000000000000000000000804 |
| 治理 | 0x0000000000000000000000000000000000000805 |
性能
Cosmos EVM 对 gas 估算做了优化:普通 ETH 转账会直接返回 21000 而无需模拟,复杂交易则会利用初次执行结果收紧二分搜索边界,从而显著提升整体eth_estimateGas 性能。
Cosmos EVM 的 mempool 遵循标准以太坊行为(按 gas price + nonce 排序,每个区块允许同一账户多笔交易)。池限制、超时和优先级函数都可按链配置。可选的实验性 mempool 还支持 nonce gap 处理和自动交易提升。
资源
快速开始
端到端部署一条链以及你的第一个合约。
工具与资源
支持的工具、库和框架完整列表。
预编译概览
内置 Cosmos 预编译及其地址。
预部署合约
创世时可用的标准 EVM 合约。
Cosmos EVM provides full Ethereum compatibility for Cosmos SDK chains. Existing contracts, tools, and workflows run without modification: deploy Solidity contracts, connect MetaMask, and use the same libraries and frameworks you already know.
Solidity Smart Contracts
The Cosmos EVM smart contract development flow is identical to the flow on Ethereum. Contracts that work on Ethereum work on Cosmos EVM without code changes. The same tools, the same Solidity, the same patterns.Development
Write Solidity using Hardhat, Foundry, or Remix with no custom configuration needed. Point your tooling at your chain’s JSON-RPC endpoint and chain ID and you’re set. See the tooling overview for a full list of supported tools, and the quick-start guide for a step-by-step contract deployment walkthrough.Deployment
Deploy using standard Ethereum tools by pointing them at your chain’s RPC endpoint. Deployment transactions go through the JSON-RPC or Cosmos gRPC interface and are processed by the EVM module. Once deployed, contract bytecode is stored in chain state and callable at its Ethereum address like any other chain.Upgrading
Cosmos EVM supports all standard EVM upgrade patterns:- Proxy patterns (EIP-1967, Transparent Proxy, UUPS): Delegate calls to an implementation contract. Upgrading means swapping the implementation address in the proxy without touching the proxy’s storage or address.
- Diamond pattern (EIP-2535): Modular contracts split into “facets” that can be added, replaced, or removed independently. The diamond routes calls to the appropriate facet, enabling granular upgrades without redeploying the whole contract.
Supported Standards
Cosmos EVM supports all standard EVM opcodes, EIPs, and ERC token interfaces up to the Prague hard fork.EIPs
The following are notable supported EIPs; the full list is much longer.| EIP | Name | Purpose |
|---|---|---|
| EIP-155 | Replay Protection | Chain ID in signatures prevents cross-chain replay attacks |
| EIP-712 | Typed Structured Data Signing | Sign structured data, human-readable messages, and custom Cosmos transactions |
| EIP-1559 | Dynamic Fees | Base fee + priority fee model; base fee is distributed to validators rather than burned |
| EIP-2535 | Diamond Standard | Proxy pattern for upgradeable contracts with multiple implementation facets |
| EIP-2935 | Historical Block Hashes | BLOCKHASH opcode provides access to up to 8192 previous block hashes (configurable) |
| EIP-4337 | Account Abstraction | Smart contract wallets can pay fees, batch transactions, and use custom auth schemes |
| EIP-7702 | Set Code for EOA | Temporarily assigns contract code to an EOA for sponsored transactions and complex auth |
ERCs
Any ERC standard that runs on the EVM is compatible with Cosmos EVM. The most commonly used are:- ERC-20 — Fungible Tokens: Standard interface for currency representations with transfer, approval, and allowance mechanisms.
- ERC-721 — Non-Fungible Tokens: Standard for unique asset identifiers, digital certificates, or proof of ownership records.
- ERC-1155 — Multi-Token Standard: Supports both fungible and non-fungible assets in a single contract, enabling batch operations and reduced deployment costs for complex asset systems.
Opcodes
Cosmos EVM supports all EVM opcodes up to the Prague hard fork. For the full reference, see evm.codes. The following are not supported:- EIP-4844 — Blob-Carrying Transactions: Blob data and L2-specific functionality.
- EIP-4399 — PREVRANDAO: The replacement of the
DIFFICULTYopcode withPREVRANDAO.
Tooling
Any tool that connects to a standard Ethereum JSON-RPC endpoint works with Cosmos EVM without custom configuration.| Tool | Category |
|---|---|
| Hardhat, Foundry, Remix | Contract development |
| OpenZeppelin Contracts | Smart contract libraries |
| Forge, Hardhat | Testing & fuzzing |
| MetaMask, WalletConnect, Rabby | Wallets |
| ethers.js, viem, web3.js, wagmi | JavaScript libraries |
| Blockscout | Block explorer |
JSON-RPC
The JSON-RPC interface implements the full Ethereum spec. Point any standard tool at your chain’s RPC endpoint and it works.Ethereum RPC Compatibility
Most standard Ethereum JSON-RPC methods are supported, with some returning stub values for compatibility. Click to view the complete reference.
eth_sendRawTransaction, eth_call, eth_estimateGas, event logs and filters, WebSocket subscriptions, and the debug namespace for tracing.
A few things to know:
eth_gasPricereturns 0 — use EIP-1559 fee fields instead- Mining-related methods don’t apply (consensus is handled by CometBFT)
txpoolmethods require the experimental mempool to be enabled
Beyond Ethereum
Cosmos EVM adds capabilities on top of full Ethereum compatibility. None of these change how existing contracts or tooling behave.| Area | Ethereum | Cosmos EVM |
|---|---|---|
| Block time | ~12 seconds | 1–2 seconds |
| Finality | 12+ blocks (~3 min) | 1 block (~2 seconds) |
| Reorganizations | Possible | Not possible |
| Cross-chain | Bridge protocols | Native IBC |
| Fee distribution | Base fee burned | Distributed to validators |
Finality
Cosmos EVM transactions are final after one block (~2 seconds) via CometBFT consensus—no waiting for confirmations, no reorganizations possible. The validator set requires 2/3+ stake agreement for any block to be committed.Gas & fees
Cosmos EVM uses EIP-1559 dynamic fees. Unlike Ethereum, the base fee is distributed to validators and delegators rather than burned. The base fee can also be disabled entirely via theNoBaseFee parameter, and a chain-wide minimum gas price floor is configurable.
Address system
Every account has two representations that reference the same underlying key:Chain IDs
Cosmos EVM uses two independent chain IDs: a Cosmos Chain ID (string, e.g.cosmosevm-1) and an EVM Chain ID (integer, e.g. 9000). These are configured separately, unlike legacy Ethermint where the format was coupled.
Precompiled Contracts
Precompile Overview
Full list of built-in Cosmos precompiles and their addresses.
Add a Custom Precompile
Enable built-in precompiles or add your own to your chain.
Predeployed Contracts
Cosmos EVM ships with standard EVM infrastructure contracts already in chain state at their canonical addresses — Create2, Multicall3, Permit2, Safe Singleton Factory, and EIP-2935 block hash storage. Any tooling that depends on these contracts at their well-known addresses works without extra setup.Predeployed Contracts
Learn which contracts are preinstalled and how to preinstall contracts at genesis.
Key Precompile Addresses
| Function | Address |
|---|---|
| Staking | 0x0000000000000000000000000000000000000800 |
| Distribution | 0x0000000000000000000000000000000000000801 |
| IBC Transfer | 0x0000000000000000000000000000000000000802 |
| Bank | 0x0000000000000000000000000000000000000804 |
| Governance | 0x0000000000000000000000000000000000000805 |
Performance
Cosmos EVM gas estimation is optimized: plain ETH transfers return 21000 immediately without simulation, and complex transactions use initial execution results to tighten the binary search bounds, makingeth_estimateGas significantly faster across the board.
The Cosmos EVM mempool follows standard Ethereum behavior (gas price + nonce ordering, multiple transactions per account per block). Pool limits, timeouts, and priority functions are configurable per chain. An optional experimental mempool adds nonce gap handling and automatic transaction promotion.
Resources
Quick Start
Deploy a chain and your first contract end-to-end.
Tooling & Resources
Full list of supported tools, libraries, and frameworks.
Precompile Overview
Built-in Cosmos precompiles and their addresses.
Predeployed Contracts
Standard EVM contracts available at genesis.