Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
How to click button on dapp/website then confirm transaction in metamask? Then repeat every xx hour

TL;DR I want to automate clicking a button in a dapp then confirm the transaction in Metamask then wait xx time and repeat

So far, I have started working on creating a script using dappeteer and puppeteer which I will share below.

So far with dappeteer I can't get it to switch network to BNB and every time the script runs it has to setup metamask with an account etc which I don't think is ideal!

Can this be done using a chrome extension? I'd prefer this as then it can connect to the existing plugin.

Any help or ideas would be appreciated!

Code

import puppeteer from 'puppeteer';
import dappeteer from '@chainsafe/dappeteer';

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function main() {
    const browser = await dappeteer.launch(puppeteer, { metamaskVersion: 'v10.15.0', defaultViewport: null });
    const metamask = await dappeteer.setupMetamask(browser,{seed: "xxx xxx xxx xxx xxx xxx xxx xxx"});
    await metamask.addNetwork({networkName: "BSC",rpc: "https://bsc-dataseed.binance.org",chainId: "56",symbol: "BNB"})

    await metamask.switchNetwork('main')
    await sleep(2000);

    const page = await browser.newPage()
    await page.goto('https://app.solarfarm.finance/?ref=xxxxxxxxxxxxxx');

    await sleep(2000);

    await page.waitForXPath('//div[contains(@class,"chakra-button css-1voh9rj")]');
    var originSelector = await page.$x('//div[contains(@class,"chakra-button css-1voh9rj")]');
    await originSelector[0].click();

    var input = await page.$x('//button[contains(text(),"Connect")]');
    await input[0].click();
    input = await page.waitForSelector("button#connect-METAMASK");
    await input.click();
    await metamask.approve({allAccounts: false});
    page.bringToFront();
    await sleep(2000);

    await metamask.confirmTransaction();
}

main()
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda