Imagine i get an approve from some wallet to access some amount of ERC20 token,

I wanna to sent this amount of token in a transaction, every time my contract calls for transfer these tokens, but that time i need a signer and i want to doing this automatically.

I think i need some ETH for cover transaction fee but i have no idea how i can sign this transaction automatically??

Anyone knows how?

1 Answer 1


For automating signing you typically need to use some backend system, such as Hardhat+ethers.js . The private key is stored securely somewhere next to the backend and the backend uses it to sign transactions. And yes, the backend wallet needs Ethers to broadcast the transactions (but not for signing them, so in theory someone else can broadcast them and pay the gas fees).

You can't automate signing of transactions with browser wallets, since they are meant to be used with human interaction for security purposes.

  • Thanks ,thats help me ,but still i don't know how i can do this in backend, at first i should add my wallet private key in a .env file then i define my wallet in js file, after that how can sign automatically? can u explain more please?
    – Alireza
    Commented Dec 18, 2022 at 11:39
  • Well you need to run a service of some sorts which runs the transaction when needed. So based on whatever rules, the service uses the private key to sign a transaction. Probably easiest with some cloud service Commented Dec 18, 2022 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.