Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
ZeroDev SDK
https://github.com/zerodevapp/sdk
Admin
Tokens:
2,078
Snippets:
11
Trust Score:
7.9
License:
MIT
Update:
1 year ago
Context
Chat
Benchmark
58.67
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Build and Prepare ZeroDev SDK for Testing Source: https://github.com/zerodevapp/sdk/blob/main/README.md Commands to install project dependencies, build the core package, and set up environment variables by copying the example file, essential for development and testing. ```bash bun install ``` ```bash bun run build ``` ```bash cp .env.example .env ``` -------------------------------- ### Install ZeroDev SDK Source: https://github.com/zerodevapp/sdk/blob/main/README.md Provides commands to install the ZeroDev SDK using popular package managers like npm, yarn, and bun. ```bash npm install @zerodev/sdk ``` ```bash yarn add @zerodev/sdk ``` ```bash bun install @zerodev/sdk ``` -------------------------------- ### APIDOC: Account Methods Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Documents the core methods available on an `Account` object within the SDK. These methods include retrieving the account's address and nonce, getting the account initialization code, encoding various types of calls (single, execute, delegate, batch), and a suite of signing methods, including EIP-6492 compliant ones and user operation signing. ```APIDOC Account: getAddress(): Promise<Address> Returns: The address of the account. getNonce(): Promise<bigint> Returns: The current nonce of the account. getAccountInitCode(): Promise<Hex> Returns: The initialization code for the account. encodeCall(args: {to: Address, value: bigint, data: Hex} | Array<{to: Address, value: bigint, data: Hex}>): Promise<Hex> args: Single call object or an array of call objects. Returns: Encoded calldata for the call(s). encodeExecute(to: Address, value: bigint, data: Hex): Promise<Hex> to: Target address. value: Value to send. data: Calldata. Returns: Encoded calldata for an execute call. encodeExecuteDelegate(to: Address, value: bigint, data: Hex): Promise<Hex> to: Target address. value: Value to send. data: Calldata. Returns: Encoded calldata for a delegate call. encodeBatchExecute(calls: Array<{to: Address, value: bigint, data: Hex}>): Promise<Hex> calls: Array of call objects. Returns: Encoded calldata for a batch execute call. signMessageWith6492(msg: Uint8Array | Hex | string): Promise<Hash> msg: The message to be signed. signTypedDataWith6492(params: SignTypedDataParams): Promise<Hash> params: The parameters for typed data signing (EIP-712). signMessage(msg: Uint8Array | Hex | string): Promise<Hash> msg: The message to be signed. signTypedData(params: SignTypedDataParams): Promise<Hash> params: The parameters for typed data signing (EIP-712). signUserOp(UserOperation: UserOperation): Promise<Hex> UserOperation: The user operation to be signed. ``` -------------------------------- ### TypeScript: Plugin Interface Definition Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Defines the `Plugin` interface, which extends `LocalAccount` and provides methods for generating dynamic dummy signatures, dummy user operation signatures, and actual signatures. It also includes methods for signing user operations, retrieving the nonce key, and getting calldata for a user operation. ```typescript export type Plugin< Name extends string = string, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined > = LocalAccount<Name> & { getDynamicDummySignature: (msg: Uint8Array | Hex | string) => Promise<Hash>; getDummyUserOperationSignature: (calldata: Hex) => Promise<Hex>; getSignature: (msg: Uint8Array | Hex | string) => Promise<Hash>; signUserOperation: (UserOperation: UserOperation) => Promise<Hex>; getNonceKey: () => Promise<Hex>; getCalldata: (UserOperation: UserOperation) => Promise<Hex>; } ``` -------------------------------- ### APIDOC: Validator/Plugin Methods Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Documents the methods available on `Validator` or `Plugin` objects. These methods include various signing functionalities (message, typed data, user operation), retrieving a signature (potentially encoding validator-specific data), obtaining a nonce key, and getting calldata. ```APIDOC Validator/Plugin: signMessage(msg: Uint8Array | Hex | string): Promise<Hash> msg: The message to be signed. signTypedData(params: SignTypedDataParams): Promise<Hash> params: The parameters for typed data signing (EIP-712). signUserOp(UserOperation: UserOperation): Promise<Hex> UserOperation: The user operation to be signed. getSignature(msg: Uint8Array | Hex | string): Promise<Hash> msg: The message to be signed. Returns: The signature, potentially with validator-specific data. getNonceKey(): Promise<Hex> Returns: The nonce key for the validator/plugin. getCalldata(): Promise<Hex> Returns: The calldata for the validator/plugin. ``` -------------------------------- ### Run ZeroDev SDK Tests Source: https://github.com/zerodevapp/sdk/blob/main/README.md Executes the test suite for the ZeroDev SDK using bun, after the project has been built and environment variables are properly configured. ```bash bun test ``` -------------------------------- ### APIDOC: BundlerClient Methods Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Documents the core methods available on the `BundlerClient`, which interacts with the bundler service. These methods include sending a fully signed user operation, estimating gas for a partial user operation, and querying the maximum priority fee per gas. ```APIDOC BundlerClient: sendUserOperation(fullSignedUserOp: UserOperation, ...): Promise<Hash> fullSignedUserOp: The fully signed user operation object. estimateUserOperationGas(partialUserOp: UserOperation, ...): Promise<GasEstimates> partialUserOp: The partially constructed user operation object. eth_maxPriorityFeePerGas(): Promise<bigint> Returns: The maximum priority fee per gas. ``` -------------------------------- ### TypeScript: SmartAccount Interface Definition Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Defines the `SmartAccount` interface, extending `LocalAccount` with properties like `client` and `entryPoint`. It includes methods for retrieving nonce and init code, encoding call data for single or batched transactions, and various signing methods including EIP-6492 compliant ones and user operation signing. ```typescript export type SmartAccount< Name extends string = string, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined > = LocalAccount<Name> & { client: Client<transport, chain>; entryPoint: Address; getNonce: () => Promise<bigint>; getInitCode: () => Promise<Hex>; encodeCallData: ( args: | { to: Address; value: bigint; data: Hex; } | { to: Address; value: bigint; data: Hex; }[] ) => Promise<Hex>; signMessageWith6492: (msg: Uint8Array | Hex | string) => Promise<Hash>; signTypedDataWith6492: (params: SignTypedDataParams) => Promise<Hash>; signUserOperation: (UserOperation: UserOperation) => Promise<Hex>; }; ``` -------------------------------- ### APIDOC: SignerClient Methods Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Documents the `SignerClient` methods, which abstract signing functionalities. These methods allow signing arbitrary messages, signing typed data according to EIP-712, and retrieving the signer's Ethereum address. ```APIDOC SignerClient: signMessage(msg: Uint8Array | Hex | string): Promise<Hash> msg: The message to be signed. signTypedData(params: SignTypedDataParams): Promise<Hash> params: The parameters for typed data signing (EIP-712). getAddress(): Promise<Address> Returns: The address of the signer. ``` -------------------------------- ### APIDOC: PaymasterClient Methods Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Documents the methods provided by the `PaymasterClient` for interacting with a paymaster. This includes obtaining paymaster and data (PND) along with gas limits for a partial user operation, and retrieving the paymaster's address. ```APIDOC PaymasterClient: getPaymasterAndData(partialUserOp: UserOperation): Promise<{paymasterAndData: Hex, gasLimits: GasLimits}> partialUserOp: The partially constructed user operation object. Returns: An object containing paymaster and data (PND) and gas limits. getPaymasterAddress(): Promise<Address> Returns: The address of the paymaster. ``` -------------------------------- ### TypeScript: SmartAccountSigner Type Definition Source: https://github.com/zerodevapp/sdk/blob/main/NOTES.md Defines the `SmartAccountSigner` type, which extends Viem's `Account` and includes methods for signing messages and typed data, along with retrieving the address. It also shows a utility type `toSmartAccountSigner` for converting an `AccountSource`. ```typescript type SmartAccountSigner = Account /*Viem Account*/ && { signMessage: (msg: Uint8Array | Hex | string) => Promise<Hash>; signTypedData: (params: SignTypedDataParams) => Promise<Hash>; getAddress: () => Promise<Address>; }; type toSmartAccountSigner = ( source: AccountSource, // Viem AccountSource ): GetAccountReturnType<AccountSource>; // Can implement different Account signer like below // toFireblocksAccountSigner // toTurnKeyAccountSigner ```