0

Hi I awant to transfer transfer ether from smart to my wallet so I ceated a sendEther function in the smart contract

    function sendEther() public {
msg.sender.transfer(1 ether);
}

very basic function and when I try to call it from app.js

   App.contracts.MyContract.deployed().then(function(instance) {
   return instance.sendEther();
 })

I got this

enter image description here

  1. I don't understand why it's from the account to the smart contract
  2. why msg.value is 0
0

I don't understand why it's from the account to the smart contract

MetaMask shows you the ETH you have to pay as gas costs.

why msg.value is 0

Again, MetaMask shows you the ETH you send along with your transaction to the contract. Not what the final results of a transaction are.

Reasons why your transaction is reverting could be the smart contract doesn't have 1 ETH or you don't have enough ETH to pay for the transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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