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
11 changes: 10 additions & 1 deletion .github/workflows/slither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ jobs:
with:
PATTERNS: |
**/*.sol
- name: Setup Node.js and pnpm
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- 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
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/tests-compatibility-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'

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

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

- name: Build and install evmd
run: |
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/tests-compatibility-viem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'

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

- name: Cache Go modules
uses: actions/cache@v4
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
10 changes: 8 additions & 2 deletions .github/workflows/tests-compatibility-web3js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'

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

- name: Cache Go modules
uses: actions/cache@v4
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
3 changes: 3 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Compiled contracts
artifacts/

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

# 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 TypeScript (`.ts`).

## 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/` | Solidity sources (`.sol`) |
| `cosmos-evm-contracts/abi/precompiles/` | ABI as typed ESM (`.ts`) |

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 { IBank_ABI } from "cosmos-evm-contracts/abi/precompiles/bank/IBank";

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

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

Use the same pattern for other precompiles, e.g. `DistributionI_ABI` from `abi/precompiles/distribution/DistributionI`, `StakingI_ABI` from `abi/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/abi/precompiles/{module}/{Interface}` (`.ts`)
e.g. `abi/precompiles/staking/StakingI`
- Common types: `cosmos-evm-contracts/precompiles/common/Types.sol` (structs only, no ABI)
11 changes: 11 additions & 0 deletions contracts/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ export default {
viaIR: true,
},
},
// This version is required to compile @account-abstraction/contracts (PackedUserOperation, IAccount use ^0.8.28).
{
version: "0.8.28",
settings: {
optimizer: {
enabled: true,
runs: 100,
},
viaIR: true,
},
},
// This version is required to compile the werc9 contract.
{
version: "0.4.22",
Expand Down
Loading