개발/BlockChain

    [BlockChain] ERC20 Token - openzeppelin 사용

    1. openzeppelin 오픈제플린은 토큰의 표준 인터페이스를 모아놓은 라이브러리다. 이 라이브러리를 통해 토큰을 편하게 만들수 있다. npm install openzeppelin-solidity 오픈제플린을 설치하면 node_modules/openzeppelin-solidity/contracts/token 폴더 안에 표준 컨트랙트들이 있다. 2. 초기 설정 트러플 초기설정 npx truffle init truffle-config.js module.exports = { networks: { development: { host: "127.0.0.1", port: 8545, network_id: 7722, }, }, compilers: { solc: { version: "0.8.17", }, }, }; ..

    [BlockChain] ERC20 Token 만들기

    1. 초기 설정 트러플 초기 설정 npx truffle init truffle-config.js module.exports = { networks: { development: { host: "127.0.0.1", port: 8545, network_id: "7722", }, }, compilers: { solc: { version: "0.8.17", }, }, }; 가나쉬 실행 npx ganache-cli --chainId 7722 --networkId 7722 2. 스마트 컨트랙트 (1) contracts/ERC20.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract ERC20{ // 표준토큰 규격 string public nam..

    [BlockChain] 사과 판매 앱 만들기

    1. 초기 설정 트러플 초기 설정 npx truffle init 가나쉬 실행 npx ganache-cli 리액트 폴더 만들기 npx create-react-app myapp src 폴더 안에 contracts폴더 생성 truffle-config.js module.exports = { contracts_build_directory: "myapp/src/contracts", networks: { development: { host: "127.0.0.1", port: 8545, network_id: "*", }, }, compilers: { solc: { version: "0.8.17", }, }, }; contracts_build_directory : 배포시 빌드되는 폴더를 정해준다. migrations/2..

    [BlockChain] 스마트컨트랙트로 투표 Dapp 만들기

    1. 초기설정 npx truffle init 다른 터미널로 가나쉬 실행 npx ganache-cli truffle-config.js module.exports = { networks: { development: { host: "127.0.0.1", port: 8545, network_id: "*", }, }, compilers: { solc: { version: "0.8.17", }, }, }; 2. 스마트 컨트랙트 /contracts/Voting.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract Voting{ string[] public candidateList; mapping(string=> uint8) public votes..

    [BlockChain] 메타마스크 토큰추가

    1. 트러플 초기설정 npx truffle init truffle-config.js module.exports = { networks: { development: { host: "127.0.0.1", port: 8545, // 가나쉬 포트 network_id: "*", }, }, compilers: { solc: { version: "0.8.17", }, }, }; 2. 스마트 컨트랙트 /contracts/Token.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract Token{ mapping(address=>uint256) public balances; string public name = "tetedoToken"; // 토큰의 ..

    [BlockChain] ganache, react, express로 메타마스크 연결하기

    1. 초기설정 react 폴더 설치 npx create-react-app front 프론트는 리액트로 구성, 메타마스크 연결은 가나쉬 네트워크에 연결, 스마트컨트랙트 배포는 트러플로 구성했다. 가나쉬 실행 npx ganache-cli 트러플 초기 설정 npx truffle init 리액트폴더안에서 라이브러리 설치 npm i axios web3 2. 스마트 컨트랙트 /contracts/Counter.sol // SPDX-License-Identifier:MIT pragma solidity ^0.8.17; contract Counter{ uint256 private _count; event Count(uint256 count); function current() public view returns(uint2..