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

110
Vistas
create and sign transaction automatically with wallet instance created with a private key

I have a contract which I want to interact with automatically using a specific wallet at certain times from my web3 app. Only my wallet (A) can interact with the contract. I have an instance of said wallet created, and when I am logged in with that wallet, I can click a button on my web front end to have it pop up for me to sign.

What I need however, is for antoher user to click the button and the wallet calls the method on the contract and signs it without me having to sign it.

User A: wallet created with a privatekey which can call a method in the solidity contract. User B: has tokens from the same contract, uses them to login and do something at a webpage. can't call the method.

In short, the scenario is that user B logs into the website using their wallet, does something that ends up user A's wallet calling a method from the contract and eating the fees.

I can call the method just fine when I do

  const provider = new ethers.providers.Web3Provider(window.ethereum);
  const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
  const contract = new ethers.Contract(address, abi, wallet);
  contract.method();

the wallet pops up and asks me to sign when logged in with that wallet. How would I go about automatically doing this, having it sign when needed without being prompted, assuming it has gas money in it?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just create wallet and export your privatekey then use this code

let privateKey="your private key"; 
let wallet = new ethers.Wallet(privateKey); 
 let provider = "the provider";
 let walletWithProvider = new ethers.Wallet(privateKey, provider); 

Now you dont need to accept the contract transaction every time You can review documents here for more info https://docs.ethers.io/v5/api/signer/

about 4 years ago · Juan Pablo Isaza Denunciar
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