インストールと基本的な使い方
インストール
GitHubから直接UserOpSDKをインストールできます:
npm install github:nerochain/aa-userop-sdkまたは、yarnを使用:
yarn add github:nerochain/aa-userop-sdk基本的な使い方
このセクションでは、UserOpSDKの使用を開始するための基本的なステップを説明します。
SDKのインポート
import { Client, Presets } from 'userop';設定定数
必要なコントラクトアドレスとサービスエンドポイントで設定を行います:
// Chain configuration
const NERO_RPC_URL = "https://rpc-testnet.nerochain.io";
const BUNDLER_URL = "https://bundler-testnet.nerochain.io/";
const PAYMASTER_URL = "https://paymaster-testnet.nerochain.io";
// Contract addresses
const ENTRYPOINT_ADDRESS = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
const ACCOUNT_FACTORY_ADDRESS = "0x9406Cc6185a346906296840746125a0E44976454";クライアントの初期化
// Initialize the AA Client
const client = await Client.init(NERO_RPC_URL, {
overrideBundlerRpc: BUNDLER_URL,
entryPoint: ENTRYPOINT_ADDRESS,
});SimpleAccountビルダーの作成
SimpleAccountビルダーは、UserOperationsの作成と設定をサポートします:
// accountSigner is the EOA wallet that will own the AA wallet
const builder = await Presets.Builder.SimpleAccount.init(
accountSigner,
NERO_RPC_URL,
{
overrideBundlerRpc: BUNDLER_URL,
entryPoint: ENTRYPOINT_ADDRESS,
factory: ACCOUNT_FACTORY_ADDRESS,
}
);次のステップ
クライアントとビルダーをインストール、初期化したら、次のことができます: