-
Notifications
You must be signed in to change notification settings - Fork 0
/
solidity_code.html
456 lines (420 loc) · 15.9 KB
/
solidity_code.html
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<!DOCTYPE html>
<html lang="en">
<head>
<!-- <meta http-equiv="refresh" content="10" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"
crossorigin="anonymous"
/>
<script
src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx"
crossorigin="anonymous"
></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
/>
<link href="./assets/styles/styles.css" rel="stylesheet" />
<link
rel="icon"
type="image/png"
sizes="32x32"
href="./assets/main_img/coding.svg"
/>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
/>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism.min.css"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
/>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
window.onscroll = function () {
myFunction();
};
var navbar = document.getElementById("navbar");
var sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky");
} else {
navbar.classList.remove("sticky");
}
}
});
</script>
<script src="./assets/js/app.js"></script>
<title>Solidityコード</title>
</head>
<body>
<div class="header">
<!-- <h1>Career change: Software Engineer</h1> -->
<h1></h1>
<!-- <p>Introduction of myself to you.<br />Looking for someone ?</p> -->
<p></p>
<a href="project.html" class="button" style="background-color: #42cc8c"
>プロジェクトへ戻る</a
>
</div>
<div id="navbar">
<div class="menu-container">
<div class="hamburger-menu">
<div></div>
<div></div>
<div></div>
</div>
<span class="menu-label">メニュー</span>
</div>
<div class="navbar-links">
<!-- <a href="index.html">Home</a> -->
<a href="portofolio.html">Home</a>
<a class="active" href="project.html">Projects</a>
<!-- <a href="resume.html">Resume</a> -->
<a href="course_path.html">Study & Resources</a>
<!-- <a href="contact.html">Contact</a> -->
<a href="https://github.com/Jer-B/" target="_blank">Github</a>
</div>
</div>
<section class="hero" id="about">
<img
src="./assets/pages_img/projects.svg"
alt=""
loading="lazy"
class="hero-img"
/>
<div class="bio animate__animated animate__shakeX">
<h2 class="bio-title">Solidityコード</h2>
<p class="bio-text">
Solidityでスマートコントラクトプログラミングを学び中です。
<br />
現在、このでページにあるコードは言語の使い方と考え方のコードテストです。
</p>
</div>
</section>
<section class="projects" id="projects">
<div class="card">
<div class="row-solidity">
<div class="avatar-container-solidity">
<div class="photo-solidity">
<img
class="img-solidity"
src="./assets/projects_img/solidity.png"
/>
</div>
</div>
<div class="details-container-solidity">
<div class="content-solidity">
<h3>スマートコントラクト</h3>
<p>例えのコードについて:</p>
<ul>
<li>
Remixテスト・SimpleStorage.sol。
スマートコントラクトから値と操作する事のコードです。
</li>
<li>
Remixテスト・FundMe.sol。スマートコントラクトへの資金の入金と引き出しの事のコードです。
</li>
</ul>
<p>使い方:</p>
<ul>
<li>
!Metamaskとテストブロックチェーン系のイーサリアムは必要です。!
</li>
<li>REMIXのサイトで新しいコントラクトを作成。</li>
<li>コードをペストする。</li>
<li>コンパイルして後、契約を操作する事が出来ます。</li>
</ul>
<a
href="project.html"
class="project-link, button"
style="background-color: #99e9c4"
>プロジェクト一覧へ戻る</a
>
<!-- <button class="btn-card btn--block card__btn"><a class="btn-link" href="https://portofolio-finance.herokuapp.com/" target="_blank" class="project-link">Check it Out</a></button> -->
</div>
</div>
</div>
<!-- delete class or not class="card-footer"-->
<section class="skills2" id="skills">
<h4 class="skill-header">ツール</h4>
<div class="skills-wrapper">
<div class="first-set animate__animated animate__pulse">
<img
src="./assets/skill_icons/solidity.svg"
alt=""
loading="lazy"
class="icon2 icon-card"
/>
<img
src="./assets/skill_icons/python.svg"
alt=""
loading="lazy"
class="icon2 icon-card"
/>
<img
src="./assets/skill_icons/remix.png"
alt=""
loading="lazy"
class="icon2 icon-card"
/>
<img
src="./assets/skill_icons/brownie.png"
alt=""
loading="lazy"
class="icon2 icon-card"
/>
<img
src="./assets/skill_icons/chainlink.svg"
alt=""
loading="lazy"
class="icon2 icon-card"
/>
<img
src="./assets/skill_icons/ganache.svg"
alt=""
loading="lazy"
class="icon2 icon-card"
/>
<img
src="./assets/skill_icons/web3.svg"
alt=""
loading="lazy"
class="icon2 icon-card"
/>
</div>
</div>
</section>
</div>
<div class="card">
<div class="row">
<div class="details-container">
<div class="content">
<h3 class="h3code">
Remixテスト・SimpleStorage.sol<button class="copy-btn">
<i class="fas fa-copy"></i>
</button>
</h3>
<figcaption>
<pre><code class="language-solidity">
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract SimpleStorage {
// initialize to 0
uint256 favoriteNumber;
bool favoriteBool;
struct People {
uint256 favoriteNumber;
string name;
}
People[] public people;
mapping(string => uint256) public nameToFavoriteNumber;
function store(uint256 _favoriteNumber) public {
favoriteNumber = _favoriteNumber;
}
function retrieve() public view returns(uint256) {
return favoriteNumber;
}
function addPerson(string memory _name, uint256 _favoriteNumber) public{
people.push(People(_favoriteNumber, _name));
nameToFavoriteNumber[_name] = _favoriteNumber;
}
}
</code></pre>
</figcaption>
</div>
</div>
</div>
</div>
<div class="card">
<div class="row">
<div class="details-container">
<div class="content">
<h3 class="h3code">
Remixテスト・FundMe.sol<button class="copy-btn">
<i class="fas fa-copy"></i>
</button>
</h3>
<figcaption>
<pre><code class="language-solidity">
// SPDX-License-Identifier: MIT
// Smart contract that lets anyone deposit ETH into the contract
// Only the owner of the contract can withdraw the ETH
pragma solidity >=0.6.6 < 0.9.0;
// Get the latest ETH/USD price from chainlink price feed
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
// safe math library check uint256 for integer overflows
using SafeMathChainlink for uint256;
//mapping to store which address depositeded how much ETH
mapping(address => uint256) public addressToAmountFunded;
// array of addresses who deposited
address[] public funders;
//address of the owner (who deployed the contract)
address public owner;
// the first person to deploy the contract is
// the owner
constructor() public {
owner = msg.sender;
}
function fund() public payable {
// 18 digit number to be compared with donated amount
uint256 minimumUSD = 50 * 10 ** 18;
//is the donated amount less than 50USD?
require(getConversionRate(msg.value) >= minimumUSD, "You need to spend more ETH!");
//if not, add to mapping and funders array
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
//function to get the version of the chainlink pricefeed
function getVersion() public view returns (uint256){
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
return priceFeed.version();
}
function getPrice() public view returns(uint256){
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
(,int256 answer,,,) = priceFeed.latestRoundData();
// ETH/USD rate in 18 digit
return uint256(answer * 10000000000);
}
// 1000000000
function getConversionRate(uint256 ethAmount) public view returns (uint256){
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;
// the actual ETH/USD conversation rate, after adjusting the extra 0s.
return ethAmountInUsd;
}
//modifier: https://medium.com/coinmonks/solidity-tutorial-all-about-modifiers-a86cf81c14cb
modifier onlyOwner {
//is the message sender owner of the contract?
require(msg.sender == owner);
_;
}
// onlyOwner modifer will first check the condition inside it
// and
// if true, withdraw function will be executed
function withdraw() payable onlyOwner public {
// If you are using Solidity version v0.8.0 or above,
// you will need to modify the code below to
// payable(msg.sender).transfer(address(this).balance);
msg.sender.transfer(address(this).balance);
//iterate through all the mappings and make them 0
//since all the deposited amount has been withdrawn
for (uint256 funderIndex=0; funderIndex < funders.length; funderIndex++){
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
//funders array will be initialized to 0
funders = new address[](0);
}
}
</code>
</pre>
</figcaption>
</div>
</div>
</div>
</div>
<!-- Side Images -->
<div class="socials">
<!-- <a href="https://github.com/Jer-B" target="_blank"
><img
src="./assets/side_img/github.svg"
alt="Github"
loading="lazy"
class="socicon"
/></a> -->
<!-- <a href="#" target="_blank"
><img
src="./assets/side_img/stackoverflow.svg"
alt="Stackoverflow"
loading="lazy"
class="socicon"
/></a> -->
<!-- <a href="https://githubgroupe.slack.com" target="_blank"
><img
src="./assets/side_img/slack-logo.svg"
alt="Slack"
loading="lazy"
class="socicon"
/></a> -->
<!-- <a href="#" target="_blank"
><img src="./assets/side_img/linkedin.svg" alt="Linkedin" class="socicon"
/></a> -->
<!-- <i class="scroll-up" id="scroll-up"
><img
src="./assets/side_img/uparrow.gif"
class="socicon up-arrow"
alt="scroll-up"
/></i> -->
</div>
</section>
<footer>
<a href="https://github.com/Jer-B/" class="copy-link">Github</a>
<p class="copy">ブルー ジェレミー ・ Bru Jeremy</p>
<p class="copy">Contact: [email protected]</p>
<p class="copy">© Copyright 2022~2024</p>
</footer>
<script>
document.querySelectorAll(".copy-btn").forEach(function (button) {
button.addEventListener("click", function () {
var code =
this.parentNode.nextElementSibling.querySelector("code").innerText;
var textarea = document.createElement("textarea");
textarea.textContent = code;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
});
});
</script>
<script>
// Get the menu and the button elements for mobile
const menu = document.querySelector(".navbar-links");
const button = document.querySelector(".hamburger-menu");
// Toggle the menu when the button is clicked
button.addEventListener("click", (event) => {
event.stopPropagation(); // Prevent the document click event from firing
menu.classList.toggle("display");
});
// Close the menu when the document is clicked
document.addEventListener("click", () => {
menu.classList.remove("display");
});
// Prevent the document click event from firing when the menu is clicked
menu.addEventListener("click", (event) => {
event.stopPropagation();
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/components/prism-solidity.min.js"></script>
</body>
<!-- icons scripts -->
<script
type="module"
src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"
></script>
<script
nomodule
src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"
></script>
</html>