How to send a native network token in backend(NodeJS)

How to send a native network token in backend(NodeJS)?

This is a middleware libary so backend or front end shouldnt matter the process would be the following:
This is to send Native network tokens such as Eth, Bnb etc

// sending 0.5 ETH
const options = {type: "native", amount: Moralis.Units.ETH("0.5"), receiver: "0x.."}
let result = await Moralis.transfer(options)

To Transfer ERC Tokens:
When sending an ERC20 you need to know the contract address of the token and the number of decimals. Can be found on Etherscan.

// sending 0.5 tokens with 18 decimals
const options = {type: "erc20", 
                 amount: Moralis.Units.Token("0.5", "18"), 
                 receiver: "0x..",
                 contractAddress: "0x.."}
let result = await Moralis.transfer(options)

Hi @RayRay, thanks for the answer, but look:

On the frontend, when requesting the transfer, it opens the Metamask screen, where I can see the amount, fees and then confirm.

I believe that the backend is different. First I think I need the keys or the wallet seed, I need a preview of the fees and then confirmation, no?

in the backend you can use a hardcoded private key to make those transactions, and you will have to write some custom code as Moralis.transfer doesnโ€™t accept a private key as parameter from what I know

Hi Crypto, thanks!

But Moralis.transfer exists on import Moralis from 'moralis/node' ?

it may be there, but I donโ€™t think that you can use it that way in backend

or if you want to look at the source code for transfer function: https://github.com/MoralisWeb3/Moralis-JS-SDK/blob/0636fe6489f0b268c99a16d4dcd61171da2a71fd/src/MoralisWeb3.js#L564