Methods provided by dAppeteer.
For additional information read root readme
- Launch dAppeteer
- Setup MetaMask
- Bootstrap dAppeteer
- Initialize Snap Environment
- Get MetaMask Window
- MetaMask methods
type DappeteerLaunchOptions = {
metaMaskVersion?:
| "latest"
| "local"
| string;
metaMaskLocation?: Path;
metaMaskPath?: string;
metaMaskFlask?: boolean;
automation?: "puppeteer" | "playwright";
puppeteerOptions?: Parameters<typeof puppeteerLaunch>[0];
playwrightOptions?: PlaywrightLaunchOptions;
userDataDir?: string;
key?: string;
};
returns an instance of DappeteerBrowser
for more information visit browser page
dappeteer.setupMetaMask(browser: Browser, options: MetaMaskOptions = {}, steps: Step[]): Promise<Dappeteer>
interface MetaMaskOptions {
seed?: string;
password?: string;
showTestNets?: boolean;
}
type Step = (page: Page, options?: Options) => void;
metaMask: Dappeteer; browser: DappeteerBrowser; metaMaskPage: DappeteerPage; }>`
type DappeteerLaunchOptions = {
metaMaskVersion?:
| "latest"
| "local"
| string;
metaMaskLocation?: Path;
metaMaskPath?: string;
metaMaskFlask?: boolean;
automation?: "puppeteer" | "playwright";
puppeteerOptions?: Omit<Parameters<typeof puppeteerLaunch>[0], "headless">;
playwrightOptions?: Omit<PlaywrightLaunchOptions, "headless">;
userDataDir?: string;
key?: string;
};
type MetaMaskOptions = {
seed?: string;
password?: string;
showTestNets?: boolean;
};
it runs dappeteer.launch
and dappeteer.setupMetaMask
and returns an object with metaMask, metaMaskPage and browser.
dappeteer.initSnapEnv( opts: DappeteerLaunchOptions & MetaMaskOptions & InstallSnapOptions & { snapIdOrLocation: string }): Promise<{ metaMask: Dappeteer; browser: DappeteerBrowser; metaMaskPage: DappeteerPage; snapId: string;}
type DappeteerLaunchOptions = {
metaMaskVersion?:
| "latest"
| "local"
| string;
metaMaskLocation?: Path;
metaMaskPath?: string;
metaMaskFlask?: boolean;
automation?: "puppeteer" | "playwright";
browser: "chrome";
puppeteerOptions?: Omit<Parameters<typeof puppeteerLaunch>[0], "headless">;
playwrightOptions?: Omit<PlaywrightLaunchOptions, "headless">;
};
type MetaMaskOptions = {
seed?: string;
password?: string;
showTestNets?: boolean;
};
type InstallSnapOptions = {
customSteps?: InstallStep[];
version?: string;
installationSnapUrl?: string;
}
it runs dappeteer.launch
and dappeteer.setupMetamask
and snaps.installSnap
and returns an object with metaMask, metaMaskPage, browser and snapId.
metaMask
is used as placeholder for dAppeteer returned by setupMetaMask
or getMetaMaskWindow
it commands MetaMask to switch to a different account, by passing the index/position of the account in the accounts list.
it commands MetaMask to import a private key. It can only be used while you haven't signed in yet, otherwise it throws.
signs out from MetaMask. It can only be used if you already signed it, otherwise it throws.
it unlocks the MetaMask extension. It can only be used in you locked/signed out before, otherwise it throws. The password is optional, it defaults to password1234
.
it changes the current selected network. networkName
can take the following values: "mainnet"
, "goerli"
, "sepolia"
, "ropsten"
, "rinkeby"
, "kovan"
, "localhost"
.
commands MetaMask to accept a Network addition. For this to work MetaMask has to be in a Network addition state (basically prompting the user to accept/reject a Network addition). You can optionally tell MetaMask to switch to this network by passing the true
parameter (default to false
).
commands MetaMask to reject a Network addition. For this to work MetaMask has to be in a Network addition state (basically prompting the user to accept/reject a Network addition).
commands MetaMask to accept a Token addition. For this to work MetaMask has to be in a Token addition state (basically prompting the user to accept/reject a Token addition).
commands MetaMask to reject a Token addition. For this to work MetaMask has to be in a Token addition state (basically prompting the user to accept/reject a Token addition).
interface TransactionOptions {
gas?: number;
gasLimit?: number;
priority?: number;
}
commands MetaMask to submit a transaction. For this to work MetaMask has to be in a transaction confirmation state (basically prompting the user to submit/reject a transaction). You can (optionally) pass an object with gas
and/or gasLimit
, by default they are 20
and 50000
respectively.
commands MetaMask to sign a message. For this to work MetaMask must be in a sign confirmation state.
commands MetaMask to sign a message. For this to work MetaMask must be in a sign typed data confirmation state.
enables the app to connect to MetaMask account in privacy mode
get balance of specific token
deletes account containing name with specified number
deletes custom network from metaMask
for advanced usages in case you need custom features.
metaMask.snaps.installSnap: (snapIdOrLocation: string, opts?: { customSteps?: InstallStep[]; version?: string;},installationSnapUrl?: string
) => Promise;
installs the snap. The snapIdOrLocation
param is either the snapId or the full path to your snap directory.
metaMask.snaps.invokeSnap<Result = unknown, Params extends Serializable = Serializable>(page: DappeteerPage,snapId: string,method: string,params?: Params): Promise<Partial<Result>>
invokes a MetaMask snap method. The snapId is the id of your installed snap (result of invoking installSnap
method). This function will throw if there is an error while invoking snap.
returns emitter to listen for notifications appearance in notification page
Returns all notifications in MetaMask notifications page
accepts a snap_dialog dialog
rejects snap_dialog dialog
type value in snap_dialog dialog