Socket
Socket
Sign inDemoInstall

@alchemy/aa-ethers

Package Overview
Dependencies
57
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @alchemy/aa-ethers

Ethers.js wrapper for @alchemy/aa-core


Version published
Weekly downloads
4.4K
increased by14.06%
Maintainers
2
Created
Weekly downloads
 

Changelog

Source

3.9.0 (2024-04-24)

Features

  • add a useClientActions hook (#571) (42692e4)
  • add split transport (#590) (2d3687f)
  • revised LightAccount v2 1271 sigs (#614) (378c83b)

Readme

Source

@alchemy/aa-ethers

This package contains EthersProviderAdapter and AccountSigner, respective extensions of the JsonRpcProvider and Signer classes defined in ethers.js external library.

If you currently rely ethers.js for web3 development, you can use these ethers.js-compatible JsonRpcProvider and Signer to integrate Account Abstraction into your dApp. You may also find the util methods helpful.

This repo is community maintained and we welcome contributions!

Getting started

If you are already using the @alchemy/aa-core package, you can simply install this package and start using the EthersProviderAdapter and AccountSigner. If you are not using @alchemy/aa-core, you can install it and follow the instructions in the "Getting started" docs to get started.

yarn add @alchemy/aa-ethers
npm i -s @alchemy/aa-ethers
pnpm i @alchemy/aa-ethers

Usage

You can create a provider and connect it to a signer account like so:

import {
  LightSmartContractAccount,
  getDefaultLightAccountFactoryAddress,
} from "@alchemy/aa-accounts";
import { EthersProviderAdapter } from "@alchemy/aa-ethers";
import { LocalAccountSigner, SmartAccountSigner } from "@alchemy/aa-core";
import { Alchemy, Network } from "alchemy-sdk";
import { polygonMumbai } from "@alchemy/aa-core";

const chain = polygonMumbai;

// 1. Create a provider using EthersProviderAdapter
const alchemy = new Alchemy({
  apiKey: process.env.API_KEY!,
  network: Network.MATIC_MUMBAI,
});
const ethersProvider = await alchemy.config.getProvider();

const provider = EthersProviderAdapter.fromEthersProvider(ethersProvider);

const signer: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner(
  process.env.YOUR_OWNER_MNEMONIC!
);

// 2. Connect the provider to the smart account signer
export const signer = provider.connectToAccount(
  (rpcClient) =>
    new LightSmartContractAccount({
      chain,
      factoryAddress: getDefaultLightAccountFactoryAddress(chain),
      rpcClient,
      signer,
    })
);

FAQs

Last updated on 24 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc