-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransferirEther.sol
More file actions
50 lines (34 loc) · 1.15 KB
/
TransferirEther.sol
File metadata and controls
50 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract SendEther{
//send() - Ya no se usa. No revierte la transacción. Para eso se usa require
//Permite 2300 unidades de gas
function sendEtherSend(address payable _to) public payable{
bool sent = _to.send(msg.value);
require (sent, "Error");
}
//transfer() - Si no se puede, se revierte la transacción
//Permite 2300 unidades de gas
function sendEtherTransfer(address payable _to) public payable{
_to.transfer(msg.value);
}
//call()
//Permite todo el gas displonible. pPsibilidad de un retorno de datos desde la función receptor.
function sendEtherCall(address payable _to) public payable returns (bytes memory) {
(bool sent, bytes memory data ) = _to.call{value: msg.value, gas: 10000}("");
require (sent, "Error");
return data;
}
}
contract RecibirEther{
//getBalance()
function getBalance() public view returns(uint){
return address(this).balance;
}
//receive()
receive() external payable{
}
//fallback()
fallback() external payable{
}
}