Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda