Skip to content

How to use Alto in CI/CD testing

To effectively integrate Alto, a performant and type-safe ERC-4337 bundler developed by Pimlico, into your CI/CD testing pipeline, we recommend utilizing Prool, a library that provides programmatic HTTP testing instances for Ethereum.rool facilitates the creation of isolated Ethereum environments, enabling efficient testing of smart contracts and related components. Installation Steps:

Install Anvil

You can find detailed instructions in the Anvil documentation.

Quickstart:

curl -L https://foundry.paradigm.xyz | bash

Source the bashrc file:

bashrc
source $HOME/.bashrc

Install Foundry:

foundryup

Install Prool and Alto:

Use npm to install the Prool and Alto packages:

npm install @pimlico/alto prool

Set Up Prool with Anvil:

Prool offers pre-configured instances, including Anvil, which can be used to simulate a local Ethereum execution environment. By using the fork option, you can avoid deploying an entry point manually. If you opt for a bare-bones Anvil server, deploying the entry point yourself will be necessary.

import { createServer } from 'prool';
import { anvil } from 'prool/instances';
 
const anvilPort = 8545;
 
const server = createServer({
  instance: anvil({
    port: anvilPort, // The port to run the Anvil server on
    forkUrl: 'https://mainnet.base.org',
    forkBlockNumber: 26008827, // This can be any block number
  }),
});
 
await server.start();

Integrate Alto with Prool:

Prool also provides an instance for Alto, enabling seamless integration into your testing environment.

import { createServer } from 'prool';
import { anvil, alto } from 'prool/instances';
import { entryPoint06Address, entryPoint07Address } from "viem/account-abstraction"
 
const anvilRpc = `http://localhost:${anvilPort}`
const anvilPrivateKey =
     "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" // Choose any private key
 const altoPort = 4337
 
 const altoServer = createServer({
  instance: (key) =>
    alto({
      port: altoPort, // The port to run the Alto server on
      entrypoints: [entryPoint06Address, entryPoint07Address],
      rpcUrl: anvilRpc,
      executorPrivateKeys: [anvilPrivateKey],
    }),
});
 
await altoServer.start();

By following these steps, you can effectively incorporate Alto into your CI/CD testing pipeline using Prool, ensuring a robust and efficient testing environment for your Ethereum applications.