Last active
February 26, 2022 18:57
-
-
Save Niweera/d0654714318535db12b0574bbd6c7938 to your computer and use it in GitHub Desktop.
Set up MetaMask wallet and OpenSea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import puppeteer from "puppeteer"; | |
import * as dappeteer from "@chainsafe/dappeteer"; | |
import config from "../keys"; | |
const createAssetURL = `https://opensea.io/collection/${config.COLLECTION_NAME}/assets/create` | |
const setUp = async () => { | |
const browser = await dappeteer.launch(puppeteer, { | |
metamaskVersion: config.METAMASK_VERSION, | |
args: ["--no-sandbox", "--disable-setuid-sandbox"], | |
}); | |
const metamask = await dappeteer.setupMetamask(browser, { | |
seed: config.METAMASK_MNEMONIC_PHRASE, | |
password: config.METAMASK_PASSWORD, | |
}); | |
await metamask.addNetwork({ | |
networkName: "Polygon Mainnet", | |
rpc: "https://polygon-rpc.com/", | |
chainId: 137, | |
symbol: "MATIC", | |
explorer: "https://polygonscan.com/", | |
}); | |
await metamask.switchNetwork("Polygon Mainnet"); | |
const page = await browser.newPage(); | |
await page.goto(createAssetURL, { waitUntil: "networkidle0" }); | |
await page.bringToFront(); | |
const tabs = await browser.pages(); | |
await tabs[0].close(); | |
await page.waitForXPath('//button[contains(.,"Show more options")]'); | |
const moreButton = await page.$x('//button[contains(.,"Show more options")]'); | |
await moreButton[0].click(); | |
await page.waitForTimeout(5000); | |
const metaMaskButton = await page.$x( | |
'//button[.//span[contains(text(),"MetaMask")]]' | |
); | |
await metaMaskButton[0].click(); | |
await metamask.approve(); | |
await page.waitForTimeout(2000); | |
await metamask.sign(); | |
await page.bringToFront(); | |
await page.waitForTimeout(5000); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment