분류 전체보기

    [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..

    [BlockChain] truffle로 스마트컨트랙트 배포하기

    1. geth geth --datadir node --http --http.addr "127.0.0.1" --http.port 8000 --http.corsdomain "*" \--http.api "admin,eth,debug,miner,net,txpool,personal,web3" --syncmode full --networkid 1234 \--port 30300 --ws --ws.addr "127.0.0.1" --ws.port 8001 --ws.origins "*" \--ws.api "admin,eth,debug,miner,net,txpool,personal,web3" \--allow-insecure-unlock --unlock "0,1" --password "./node/password.txt" 2..