Epoch SDK

To send transactions, manage smart contract wallet addresses and signing you can use Epoch SDK

Install SDK

yarn add @epoch-protocol/sdk
# or 
npm i @epoch-protocol/sdk

Setting up Bundler Instance

Bundler Instance is needed to connect to the bundler and perform bundler specific actions like send userOps, getUserOps, getUserOperationHash etc.

You need to the bundlerUrl, ENTRY_POINTarrow-up-right address and the chain id to setup Bundler Instance

import { HttpRpcClient } from '@epoch-protocol/sdk'

const bundlerInstance = new HttpRpcClient(bundlerUrl, ENTRY_POINT, parseInt(network.chainId.toString()));
const network = await provider.getNetwork();

Setting up Account API

The Account API is essential to manage user's Smart Contract Wallet.

There are 2 Implementations of the Account API in Epoch's SDK

Simple Account API

Account API Implementation for Eth-Infinitism SimpleAccount.solarrow-up-right

You can get the ENTRY_POINT and FACTORY_ADDRESS from the Github herearrow-up-right

SAFE Account API

Account API Implementation for SAFE Wallet and ERC4337 Modulearrow-up-right

For SAFE Account API we need the SAFE Config like below, you can use the SAFE config from the SDK itself or you can pass you own.

The safeConfig and salt are essential to calculate an address for your SAFE Account. If the salt changes the address will change as well. So make sure you keep a standardised Salt for your application.

Note -

  • ERC4337 Module only works for SAFE Version 1.4.1 and above.arrow-up-right The wallet deployed using our SDK will have that version

  • Connecting an existing ERC4337 Compatible Address is WIP and we'll soon add support for it. For now if you know the correct safeConfig and salt you can use that address as well.

Generating Valid Nonce for UserOP

Nonce For Normal Transactions

You don't need to do anything for a normal transaction to calculate nonce. The SDK takes care of it or you can manually pass in the nonce if you like.

Nonce For Automated Transactions

Nonce management through Epoch SDK is slightly different when compared to the usual approach for automated transactions, this is to make sure there are no nonce clashes in case you have many user ops in the queue.

Sending Transactions

Sending transactions is straightforward.

Getting Queued UserOps

To get a list of all the transactions that are with the bundler simply run these

Deleting Queued UserOp

To delete a specific userOp in the automation queue you need to send a new userOp with the same nonce as the userOp you want to delete.

Last updated