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 / 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 주소와 메시지에 해당하는 문자열을 기록할 용도의 이벤트 선언
@Violet-Bora-Lee
Violet-Bora-Lee / lw3_sophomore_solidity.sol
Last active March 26, 2024 12:48
솔리디티 문법 정리, 이보라의 포켓 솔리디티
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
// 매핑(Mapping)은 해시맵, 객채, 딕셔너리처럼 키-값 쌍이 있는 데이터를 저장할 때 사용한다.
contract Mapping {
// 주소(키)와 uint(값)쌍을 매핑함
mapping(address => uint) public myMap;
function get(address _addr) public view returns (uint) {
// 매핑은 항상 값을 반환하는데,
@Violet-Bora-Lee
Violet-Bora-Lee / myFirstDapp.html
Created March 30, 2023 08:05
LW3DAO-Freshmen-1
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My First dapp</title>
<script
src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js"
type="application/javascript"
></script>
// in util.js
export function times(x) {
return x * x;
}
export function plusTwo(number) {
return number + 2;
}
// in app.js
import { times as multiplication, plusTwo as plus2 } from './util.js';