This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://testnet.bitfinity.network \ | |
-X POST -H 'content-Type: application/json' \ | |
-d '{"jsonrpc":"2.0","id":"67","method":"ic_mintNativeToken","params":["0x629A54Cb82f9A300a67bB77477D747a1F19815Cf", "0x100"]}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.19; | |
contract MoodDiary { | |
string mood; | |
function setMood(string memory _mood) public { | |
mood = _mood; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.10; | |
contract Whitelist { | |
// 화이트 리스트에 등록된 사람을 관리하는 용도의 map작성 | |
// mapping 변수 선언 | |
// 화이트 리스트에 특정 주소를 등록시키는 함수 선언 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
contract SimpleToken { | |
// state 변수로 각 주소의 잔액을 저장 | |
mapping(address => uint256) public balances; | |
// 초기 잔액 설정 | |
constructor(uint256 initialSupply) { | |
balances[msg.sender] = initialSupply; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.10; | |
// 이벤트 | |
// 블록체인에 로그를 남길 때 사용하는 문법(객체)이다. | |
// 프론트엔드 등에서 특정 컨트랙트에 대한 로그를 파싱하여 응용하려 할 때 유용하다. | |
// 블록체인 상태변수보다 낮은 비용으로 정보를 저장할 수 있다. | |
contract Events { | |
// sender 주소와 메시지에 해당하는 문자열을 기록할 용도의 이벤트 선언 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { | |
// 매핑은 항상 값을 반환하는데, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'; |
NewerOlder