2

The question it's How store Ether in a smart contract.

In first step, I try transfer the transaction value to the smartcontract address doing something y something like that:

function storeETH() payable public {    
   address(this).transfer(msg.value);
}

I have the address but I think that isn't a wallet... I don't know how store ETH in my smart contract or if exist the possibility to do something like that.

Please, help me :D

5

Your transfer is transferring from the contract to the contract. It's not needed, and you can just delete it:

function storeETH() payable public {    
    // nothing to do here
}

https://programtheblockchain.com/posts/2017/12/15/writing-a-contract-that-handles-ether/ might help.

1

All you need is a payable function in your smart contract. Smart contracts can act as wallets and store ETH. You will want to create a function to send ETH out of your wallet to your own wallet to get it out as well!

0

I would suggest doing this. By this, you can just send ether to the smart contract address and that ether will be get stored in the smart contract and also you can call the storeETH function. Include both functions.

function storeETH() payable public {    
// nothing to do here
}
function() payable public {}

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.