Moralis Transfer WBNB

I’m trying to use the Moralis.transfer function in my Dapp to send BNB after user authentication. The code below is working fine but it creates an ETH transfer and not BNB. How do I configure it to let users send BNB.

Run code

You may need to be connected to Binance Smart Chain in MetaMask, it will send native currency that is BNB on Binance Smart Chain and ETH on Ethereum.

It does nothing while connected to Binance Smart Chain in Metamask. But it triggers a transfer while connected to Ethereum in Metamask.

Hey @EncodTech

Please share your full code

I’m using the Moralis demo code on

There is no any transfers. Please share your code :man_mechanic:

That’s my code

WalletConnect

<script>

function runcode(){
Moralis.transfer({type:"native", contractAddress:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", receiver:"0x...", amount:Moralis.Units.ETH(0.015,18)});
}
</script>

<main>
  <section class="buttons">
    <button id="btn-auth">Open Wallet</button>
    <button id="btn-logout">Logout</button>
    <button id="btn-runcode" onclick="runcode()">Pay Now</button>
  </section>
  <section class="result" id="result"></section>
</main>

<!-- scripts -->
<script src="script.js"></script>

You should not have a contractAddress specified in transfer when transferring native coin

Noted. What then defines that you’re sending BNB and not ETH?

The selected network that you selected in MetaMask I think that makes that difference

Or you want to send wrapped BNB instead of BNB?

1 Like

Yes I’m working with wrapped BNB. I’ll love to know the parameters to specify to get that working.

https://docs.moralis.io/moralis-server/sending-assets
The part with Transferring ERC20 Tokens from there


// 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)

1 Like