Sign transaction using the private key in cloud functions

In the docs https://docs.moralis.io/moralis-server/cloud-code/cloud-functions#web3
it says


that its not recommended for security reason, but it doesn’t explain how to do it, if we really need it.

I don’t see any other way to solve my use case and that is to distribute some tokens.

it doesn’t say it how to do it, but you can do it if you really want, you’ll have to provide the private key and use HDWalletProvider to load it in a web3 instance, you could use the address of a speedy node for example.
it is similar how you would do it from your local system with a private key and not with metamask.

1 Like