본문 바로가기

WATTO 프로젝트9

web3, 컨트렉트 연결 Eth - version 순서 프론트에서 컨트렉트 호출 api를 날린다 서버단에서 api를 받고 컨트렉트로 신호를 보낸다 server web3와 연결 const Web3 = require('web3'); const web3 = new Web3( new Web3.providers.HttpProvider( 'https://ropsten.infura.io/v3/c2cc008afe67457fb9a4ee32408bcac6' ) ); abi 읽어 오고 변환해주기 const fs = require('fs'); const WTABI = fs.readFileSync('server/abi/WTToken.json', 'utf-8'); const NWTABI = fs.readFileSync('server/abi/NWTToke.. 2022. 2. 15.
Ethereum 기반 컨트렉트 klaytn 환경으로 변경 수정 중 2022. 2. 14.
NFT 경매 NFT 관련 글이 길어 경매 파트는 따로 정리 event Start(); event Bid(address indexed sender, uint amount); event Withdraw(address indexed bidder, uint amount); event End(address winner, uint amount); event Endedat(uint a); struct Auction { bool started; address owner; uint nftId; bool status; uint endAt; address highestBidder; uint highestBid; bool ended; } mapping(uint => Auction) auction; mapping(uint => mappin.. 2022. 2. 13.
NFT 컨트렉트 NFT는 ERC-721로 구성되어 있으며 NWT_Token으로 구매가 가능하다. // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "../node_modules/@openzeppelin/contracts/utils/Counters.sol"; import "../node_modules/@openzeppelin/contracts/access/Ownable.sol"; import "../node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStor.. 2022. 2. 13.
Token_Swap WT_Token과 NWT_Token을 교환 해주는 컨트렉트 // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.10; import "../node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract TokenSwap{ IERC20 public token1; // stable coin IERC20 public token2; // 유동성 코인 address public owner2; // server address constructor (address _token1,.. 2022. 2. 13.
WT_Token 배팅 컨트렉트가 포함된 stable coin // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; import "../node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "../node_modules/@openzeppelin/contracts/access/Ownable.sol"; contract WTToken is ERC20, Ownable { uint256 _amountToken; //배팅을 하는 플레이어에 대한 구조체 struct Player { address addr; // 주소 uint256 playerBetAmount; // 베팅 금액 string vote; // 후보에게 .. 2022. 2. 12.