-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataTypes2.sol
38 lines (30 loc) · 1.04 KB
/
DataTypes2.sol
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract DataTypes2 {
// string
string public myStr = "test string"; // storage-blockchain
// address
address public myAddr = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
// mapping
mapping (address => uint) public payments;
function tmpStr() public {
string memory myTmpStr = "temp test string"; // memory
myStr = "new test string value";
}
function tmpStrMemory(string memory newValueStr) public {
myStr = newValueStr;
}
function getMyBalance() public view returns(uint) {
return myAddr.balance;
}
function getAddressBalance(address targetAddress) public view returns(uint) {
return targetAddress.balance;
}
function transferTo(address targetAddress, uint amount) public {
address payable _to = payable(targetAddress);
_to.transfer(amount); // transfer from this account contract
}
function receiveFounds() public payable {
payments[msg.sender] = msg.value;
}
}