UNPKG

@thirdweb-dev/wallets

Version:

<p align="center"> <br /> <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> <br /> </p> <h1 align="center">thirdweb Wallet SDK</h1> <p align="center"> <a h

50 lines (46 loc) 1.47 kB
import { AbstractWallet } from '../../abstract/dist/thirdweb-dev-wallets-evm-wallets-abstract.browser.esm.js'; import { ethers } from 'ethers'; import { getChainProvider } from '@thirdweb-dev/sdk'; import '../../../../dist/defineProperty-350fc508.browser.esm.js'; import 'eventemitter3'; /** * Wallet interface to connect using a Private Key * * @example * ```ts * import { PrivateKeyWallet } from "@thirdweb-dev/wallets"; * * // can be any ethers.js signer * const privateKey = process.env.PRIVATE_KEY; * const wallet = new PrivateKeyWallet(privateKey); * ``` * * @wallet */ class PrivateKeyWallet extends AbstractWallet { /** * Create instance of `PrivateKeyWallet` * * @param privateKey - The private key to use for signing transactions. * * @param chain - The chain or rpc url to connect to when querying the blockchain directly through this wallet. * * @param secretKey - * Provide `secretKey` to use the thirdweb RPCs for given `chain` * * You can create a secret key from [thirdweb dashboard](https://thirdweb.com/create-api-key). */ constructor(privateKey, chain, secretKey) { super(); this._signer = new ethers.Wallet(privateKey, chain ? getChainProvider(chain, { secretKey }) : undefined); } /** * Get the [ethers.js signer](https://docs.ethers.io/v5/api/signer/) object used by the wallet */ async getSigner() { return this._signer; } } export { PrivateKeyWallet };