Skip to content

Instantly share code, notes, and snippets.

View Violet-Bora-Lee's full-sized avatar
๐Ÿ’œ
I code, build and act.

Bora Lee Violet-Bora-Lee

๐Ÿ’œ
I code, build and act.
View GitHub Profile
@Violet-Bora-Lee
Violet-Bora-Lee / DebugContracts.tsx
Created October 7, 2024 18:35
Speed Run Ethereum, #2: Token Vendor, Debug Contracts page
"use client";
import { useCallback, useEffect, useMemo, useState } from "react";
import { BarsArrowUpIcon } from "@heroicons/react/20/solid";
import { ContractUI } from "~~/app/debug/_components/contract";
import { ContractName } from "~~/utils/scaffold-eth/contract";
import { getAllContracts } from "~~/utils/scaffold-eth/contractsData";
const selectedContractStorageKey = "scaffoldEth2.selectedContract";
const contractsData = getAllContracts();

์ด๋”๋ฆฌ์›€ ๊ธฐ์ดˆ

![[Pasted image 20240323012814.png]]

์†”๋ฆฌ๋””ํ‹ฐ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ๊ณต๊ฐ„์€ ์ด 6๊ฐœ์ด๋‹ค. ์†”๋ฆฌ๋””ํ‹ฐ๋กœ ์ฝ”๋”ฉํ•˜๋ฉด์„œ ์ž์ฃผ ์–ธ๊ธ‰๋˜๋Š” ๊ฐœ๋…์€ ์ด stack, memory, storage, calldata ์ด๋ฏ€๋กœ ์ด ๋„ท์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.

Stack

EVM์€ ๊ธฐ์กด ํ”„๋กœ์„ธ์„œ์™€ ์ปดํ“จํ„ฐ์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๋ ˆ์ง€์Šคํ„ฐ ๊ธฐ๋ฐ˜ ์•„ํ‚คํ…์ฒ˜๊ฐ€ ์•„๋‹Œ ์Šคํƒ ๊ธฐ๋ฐ˜ ์•„ํ‚คํ…์ฒ˜์ด๋‹ค.

EVM์˜ ์Šคํƒ์—” 16์ง„์ˆ˜ 32๋ฐ”์ดํŠธ ์›Œ๋“œ(word)๋ฅผ ๋‹จ์œ„๋กœ ์ž๋ฃŒ๊ฐ€ ์ €์žฅ๋œ๋‹ค.

c#์„ ์‚ฌ์šฉํ•œ ๋ฆฌํŒฉํ† ๋ง ๊ธฐ๋ฒ•

๊ธฐ๋ฒ•1

๊ธฐ๋ฒ•2

@Violet-Bora-Lee
Violet-Bora-Lee / erc20.sol
Created March 30, 2024 18:30
erc-20 ํ† ํฐ ๋ฐœํ–‰
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("DUG Coin", "DUG") {
_mint(msg.sender, 100 * 10 ** ERC20.decimals());
}
@Violet-Bora-Lee
Violet-Bora-Lee / curl.bash
Created March 26, 2024 12:09
bitfinity test token add
curl https://testnet.bitfinity.network \
-X POST -H 'content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"67","method":"ic_mintNativeToken","params":["0x629A54Cb82f9A300a67bB77477D747a1F19815Cf", "0x100"]}'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract MoodDiary {
string mood;
function setMood(string memory _mood) public {
mood = _mood;
}
@Violet-Bora-Lee
Violet-Bora-Lee / wl_mapping.sol
Created October 4, 2023 02:21
์†”๋ฆฌ๋””ํ‹ฐ ๋งคํ•‘ ์—ฐ์Šต
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
contract Whitelist {
// ํ™”์ดํŠธ ๋ฆฌ์ŠคํŠธ์— ๋“ฑ๋ก๋œ ์‚ฌ๋žŒ์„ ๊ด€๋ฆฌํ•˜๋Š” ์šฉ๋„์˜ map์ž‘์„ฑ
// mapping ๋ณ€์ˆ˜ ์„ ์–ธ
// ํ™”์ดํŠธ ๋ฆฌ์ŠคํŠธ์— ํŠน์ • ์ฃผ์†Œ๋ฅผ ๋“ฑ๋ก์‹œํ‚ค๋Š” ํ•จ์ˆ˜ ์„ ์–ธ
}
@Violet-Bora-Lee
Violet-Bora-Lee / event_example.sol
Created October 3, 2023 14:10
์†”๋ฆฌ๋””ํ‹ฐ ์ด๋ฒคํŠธ ์˜ˆ์‹œ
pragma solidity ^0.8.0;
contract SimpleToken {
mapping(address => uint256) public balances;
// ํ† ํฐ ์ „์†ก ์ด๋ฒคํŠธ ์ •์˜
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
constructor(uint256 initialSupply) {
balances[msg.sender] = initialSupply;
@Violet-Bora-Lee
Violet-Bora-Lee / state_variable_example.sol
Last active October 3, 2023 14:06
์†”๋ฆฌ๋””ํ‹ฐ ์ƒํƒœ๋ณ€์ˆ˜ ์˜ˆ์‹œ
pragma solidity ^0.8.0;
contract SimpleToken {
// state ๋ณ€์ˆ˜๋กœ ๊ฐ ์ฃผ์†Œ์˜ ์ž”์•ก์„ ์ €์žฅ
mapping(address => uint256) public balances;
// ์ดˆ๊ธฐ ์ž”์•ก ์„ค์ •
constructor(uint256 initialSupply) {
balances[msg.sender] = initialSupply;
}
@Violet-Bora-Lee
Violet-Bora-Lee / event.sol
Last active October 3, 2023 18:58
์†”๋ฆฌ๋””ํ‹ฐ event ๊ธฐ๋ณธ ๋ฌธ๋ฒ•
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
// ์ด๋ฒคํŠธ
// ๋ธ”๋ก์ฒด์ธ์— ๋กœ๊ทธ๋ฅผ ๋‚จ๊ธธ ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋ฌธ๋ฒ•(๊ฐ์ฒด)์ด๋‹ค.
// ํ”„๋ก ํŠธ์—”๋“œ ๋“ฑ์—์„œ ํŠน์ • ์ปจํŠธ๋ž™ํŠธ์— ๋Œ€ํ•œ ๋กœ๊ทธ๋ฅผ ํŒŒ์‹ฑํ•˜์—ฌ ์‘์šฉํ•˜๋ ค ํ•  ๋•Œ ์œ ์šฉํ•˜๋‹ค.
// ๋ธ”๋ก์ฒด์ธ ์ƒํƒœ๋ณ€์ˆ˜๋ณด๋‹ค ๋‚ฎ์€ ๋น„์šฉ์œผ๋กœ ์ •๋ณด๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.
contract Events {
// sender ์ฃผ์†Œ์™€ ๋ฉ”์‹œ์ง€์— ํ•ด๋‹นํ•˜๋Š” ๋ฌธ์ž์—ด์„ ๊ธฐ๋กํ•  ์šฉ๋„์˜ ์ด๋ฒคํŠธ ์„ ์–ธ