Have a way to send token ERC20 on backend?

hello everyone !
I am quite new to this ERC20 Token thing, I would like to know if there is any way to send tokens or receive using only the backend, without the need for the frontend, as I would like to automate some operations…
using for example: C++ or php.

Yes definitely. I am not sure how to do it with C++ or PHP though. But the basic thing is if it’s on the backend then you need to have the private key of your wallet on the backend to interact with. Basically that wallet will be used to execute all transaction instead of the user’s wallet. This way you can send tokens from the backend.

1 Like

thanks by your answer YosephKS

I tried to find this wallet private key in the trustWallet app, but I didn’t find it, is it possible to configure it that way?

you mean that you don’t know how to export the private key from trust wallet?

you can try initially with a testnet, with a new wallet that you add in metamask, in case that you don’t have metamask already, and in metamask it is easy to export a private key for an account

I’m not very sure about private key in trust wallet too like @cryptokid, you can try to google how to do that. Using Metamask is easy for sure, but I believe you can use mnemonics too if you don’t have the private key, which usually you will get when generating new wallet from mobile apps like trust wallet.

Thanks for the information i was trying to send token and i am not getting my problem solved can anyone explain me in detail.

You need to create a signed transaction with signTransaction and then send it with sendSignedTransaction. For example:

const contract = new web3.eth.Contract(abi_you_have_exported_from_remix, contract_address);
const tx = {
    from: sender_address,
    to: contract_address,
    gas: 100000,
    data: contract.methods.transfer(payee_address, payment_in_wei).encodeABI()
}
const signResp = await web3.eth.accounts.signTransaction(tx, private_key).then(async (signedTx) => {
    const sentTx = await web3.eth.sendSignedTransaction(signedTx.raw || signedTx.rawTransaction)
      .then(async receipt => {
        logger.info("Transfer to " + payee_address + " executed. Transaction code " + receipt.transactionHash);
      })
      .catch(err => {
        logger.info(err.message);
      });
}).catch((err) => {
    logger.info(err.message);
});
4 Likes

Nice work @RedCabbage!

Thank you :raised_hands:

1 Like