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

106
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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