-
Notifications
You must be signed in to change notification settings - Fork 28
/
Types.sol
48 lines (36 loc) · 901 Bytes
/
Types.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
39
40
41
42
43
44
45
46
47
48
//SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
/**
* @author RareSkills (https://github.com/RareSkills/Udemy-Yul-Code))
* https://solidity-by-example.org/primitives
*/
contract YulTypes {
function getNumber() external pure returns (uint256) {
uint256 x;
assembly {
x := 42
}
return x;
}
function getHex() external pure returns (uint256) {
uint256 x;
assembly {
x := 0xa
}
return x;
}
function demoString() external pure returns (string memory) {
bytes32 myString = "";
assembly {
myString := "lorem ipsum dolor set amet..."
}
return string(abi.encode(myString));
}
function representation() external pure returns (address) {
address x;
assembly {
x := 1
}
return x;
}
}