Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- uses: actions/setup-node@v4
if: env.GIT_DIFF
with:
node-version: "20"
node-version: "22"

# Lint: check only, fail on errors
- name: markdownlint (check only)
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/slither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ jobs:
with:
PATTERNS: |
**/*.sol
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 11
- name: Setup Node.js and pnpm
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
- name: Node dependencies Install
run: |
cd contracts && npm i
cd contracts && pnpm install
cp -r node_modules/@openzeppelin .
- name: Run Slither Action
uses: crytic/slither-action@v0.4.0
continue-on-error: true
id: slither
with:
target: contracts/
if: "env.GIT_DIFF"
if: "env.GIT_DIFF"
6 changes: 6 additions & 0 deletions .github/workflows/solidity-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jobs:
go-version: '1.25'
check-latest: true
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 11
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '22'

- name: Cache Go modules
uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-compatibility-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '22'

- name: Cache Go modules
uses: actions/cache@v4
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/tests-compatibility-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly


- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 11

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

node-version: '22'
cache: 'pnpm'

- name: Cache Go modules
uses: actions/cache@v4
with:
Expand All @@ -66,8 +72,8 @@ jobs:
uses: actions/cache@v4
with:
path: tests/evm-tools-compatibility/hardhat/node_modules
# no restore-keys: a stale fallback tree makes the setup script skip npm install
key: ${{ runner.os }}-node-${{ hashFiles('tests/evm-tools-compatibility/hardhat/package-lock.json', 'tests/evm-tools-compatibility/hardhat/package.json') }}
# no restore-keys: only reuse modules resolved from these exact manifests
key: ${{ runner.os }}-pnpm-${{ hashFiles('tests/evm-tools-compatibility/hardhat/pnpm-lock.yaml', 'tests/evm-tools-compatibility/hardhat/package.json') }}

- name: Build and install evmd
run: |
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/tests-compatibility-viem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly


- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 11

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

node-version: '22'
cache: 'pnpm'

- name: Cache Go modules
uses: actions/cache@v4
with:
Expand All @@ -64,9 +70,9 @@ jobs:
uses: actions/cache@v4
with:
path: tests/evm-tools-compatibility/viem/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('tests/evm-tools-compatibility/viem/package-lock.json') }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('tests/evm-tools-compatibility/viem/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-

- name: Build and install evmd
run: |
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/tests-compatibility-web3js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly


- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 11

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

node-version: '22'
cache: 'pnpm'

- name: Cache Go modules
uses: actions/cache@v4
with:
Expand All @@ -64,9 +70,9 @@ jobs:
uses: actions/cache@v4
with:
path: tests/evm-tools-compatibility/web3.js/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('tests/evm-tools-compatibility/web3.js/package-lock.json') }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('tests/evm-tools-compatibility/web3.js/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-

- name: Build and install evmd
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ yarn.lock

# Node.js
**/node_modules
.pnpm-store

# OpenZeppelin contracts
contracts/@openzeppelin/*
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- [\#1082](https://github.com/cosmos/evm/pull/1082) Enable incarnation cache for verify result.
- [\#1096](https://github.com/cosmos/evm/pull/1096) Allow eth_call overrides work with static precompiles.
- [\#1228](https://github.com/cosmos/evm/pull/1228) Respect `ctx.IsSigverifyTx()` in EVM signature verification, mirroring x/auth to allow applications skip redundant ecrecover for txs the node already verified.
- [\#1240](https://github.com/cosmos/evm/pull/1240) Add a publishable `cosmos-evm-contracts` package with precompile Solidity interfaces and typed ESM/CJS ABI modules, and migrate Solidity tooling to pnpm.

### BUG FIXES

Expand Down
9 changes: 9 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Compiled contracts
artifacts/

# Precompiles build output (OpenZeppelin-style dist)
dist/

# Generated Solidity interface sources (published artifact)
precompiles/

# Wagmi/tsdown staging (generated inputs)
.generated/

# Cached files
cache/

Expand Down
77 changes: 77 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# cosmos-evm-contracts

A collection of smart contracts for the Cosmos EVM blockchain.
The published package includes precompile interface sources (`.sol`) and ABIs as typed ESM/CJS modules.

## Installation

```bash
# pnpm
pnpm add cosmos-evm-contracts

# npm
npm install cosmos-evm-contracts

# yarn
yarn add cosmos-evm-contracts
```

## Package structure

After installation, use the following paths:

| Path | Description |
|------|-------------|
| `cosmos-evm-contracts/precompiles/{module}/{Interface}.sol` | Solidity sources (`.sol`) |
| `cosmos-evm-contracts/precompiles/{module}/{Interface}` | ABI as typed ESM/CJS modules |

Included precompiles: `bank`, `bech32`, `callbacks`, `common`, `distribution`, `erc20`, `gov`, `ics02`, `ics20`, `slashing`, `staking`, `werc20` (testdata and testutil excluded).

## Usage

### Loading ABI with TypeScript / viem (typed)

Import the named ABI constant so that `functionName`, `args`, and return types are inferred:

```typescript
import { createPublicClient, http } from "viem";
import { iBankAbi } from "cosmos-evm-contracts/precompiles/bank/IBank";

const client = createPublicClient({ transport: http() });

// functionName and args are type-checked and autocompleted
const balances = await client.readContract({
address: "0x0000000000000000000000000000000000000804",
abi: iBankAbi,
functionName: "balances",
args: ["0x..."],
});
```

Use the same pattern for other precompiles, e.g. `distributionIAbi` from `precompiles/distribution/DistributionI`, `stakingIAbi` from `precompiles/staking/StakingI`, etc.

### Using interfaces in Hardhat

Import by package path in your contract:

```solidity
import "cosmos-evm-contracts/precompiles/bank/IBank.sol";
```

### Using interfaces in Foundry

Add the following to `remappings.txt` for shorter import paths:

```
cosmos-evm-contracts/=node_modules/cosmos-evm-contracts/precompiles/
```

```solidity
import "cosmos-evm-contracts/bank/IBank.sol";
```

### Path reference

- Interface ABI: `cosmos-evm-contracts/precompiles/{module}/{Interface}` (typed ESM/CJS module)
e.g. `precompiles/staking/StakingI`
- Common types: `cosmos-evm-contracts/precompiles/common/Types.sol` (structs only, no ABI)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type import('hardhat/config').HardhatUserConfig */
export default {
module.exports = {
solidity: {
compilers: [
{
Expand Down
Loading