├── projects ├── .keep ├── CryptoKitties │ ├── docs │ │ └── .keep │ └── README.md └── dAes │ ├── contest1 │ ├── src │ │ ├── components │ │ │ ├── App1.css │ │ │ ├── App1.js │ │ │ ├── show.css │ │ │ └── show.js │ │ ├── 提示.png │ │ ├── backgrounf.png │ │ ├── setupTests.js │ │ ├── App.test.js │ │ ├── index.css │ │ ├── reportWebVitals.js │ │ ├── index.js │ │ ├── App.css │ │ ├── App.js │ │ ├── logo.svg │ │ └── abi │ │ │ └── index.js │ ├── public │ │ ├── robots.txt │ │ ├── favicon.ico │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── index.html │ ├── .gitignore │ ├── package.json │ └── README.md │ ├── .gitignore │ ├── Introduce.md │ ├── dAes │ ├── hardhat.config.js │ ├── scripts │ │ └── deploy.js │ ├── package.json │ ├── contracts │ │ ├── extensions │ │ │ ├── ICanvas.sol │ │ │ └── IERC721ExMetadata.sol │ │ └── Canvas.sol │ ├── test │ │ └── Canvas.js │ └── tasks │ │ └── faucet.js │ └── README.md ├── .gitignore ├── README.md └── LICENSE /projects/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/CryptoKitties/docs/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/components/App1.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode/ 2 | .DS_Store 3 | yarn.lock 4 | -------------------------------------------------------------------------------- /projects/dAes/.gitignore: -------------------------------------------------------------------------------- 1 | **/node_modules/ 2 | **/cache/ 3 | **/artifacts/ -------------------------------------------------------------------------------- /projects/dAes/contest1/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/提示.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/2021Q2-hackathon/main/projects/dAes/contest1/src/提示.png -------------------------------------------------------------------------------- /projects/dAes/contest1/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/2021Q2-hackathon/main/projects/dAes/contest1/public/favicon.ico -------------------------------------------------------------------------------- /projects/dAes/contest1/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/2021Q2-hackathon/main/projects/dAes/contest1/public/logo192.png -------------------------------------------------------------------------------- /projects/dAes/contest1/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/2021Q2-hackathon/main/projects/dAes/contest1/public/logo512.png -------------------------------------------------------------------------------- /projects/dAes/contest1/src/backgrounf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lite/2021Q2-hackathon/main/projects/dAes/contest1/src/backgrounf.png -------------------------------------------------------------------------------- /projects/dAes/contest1/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /projects/dAes/Introduce.md: -------------------------------------------------------------------------------- 1 | ## 参赛项目: 2 | 3 | Pixel(像素画布) 4 | 5 | ## 队伍名 6 | 7 | Art Of Aesthetic 8 | 9 | ## 作品链接 10 | 11 | https://github.com/SeavantUUz/2021Q2-hackathon 12 | 13 | ## 队员介绍 14 | 15 | caijiawen: 来自嘉楠慧光 , 主业做量化交易 16 | 17 | xingyue : 来自嘉楠慧光 , 前端 18 | 19 | AprocySanae: 干啥啥会,干啥啥不行,擅长摸鱼和撸猫 20 | 21 | liduan: 憨厚沉稳的合约开发者 22 | 23 | Boss Wan: 区块链爱好者 -------------------------------------------------------------------------------- /projects/dAes/dAes/hardhat.config.js: -------------------------------------------------------------------------------- 1 | require("@nomiclabs/hardhat-waffle"); 2 | 3 | require("./tasks/faucet"); 4 | 5 | /** 6 | * @type import('hardhat/config').HardhatUserConfig 7 | */ 8 | module.exports = { 9 | solidity: "0.8.0", 10 | paths: { 11 | artifacts: './src/artifacts', 12 | }, 13 | networks: { 14 | hardhat: { 15 | chainId: 1337 16 | } 17 | } 18 | }; -------------------------------------------------------------------------------- /projects/CryptoKitties/README.md: -------------------------------------------------------------------------------- 1 | # 编号 1 2 | 3 | 4 | 5 | ## 队名 6 | 7 | CryptoKittes 8 | 9 | 10 | 11 | 队员: 12 | 13 | Frozen Rebase的码农一名 sdfsadfsdf https://github.com/xrdavies 14 | 15 | Harry Rebase的码农一名 asdfasdf https://github.com/harry 16 | 17 | 18 | 19 | 20 | 21 | ## 作品信息 22 | 23 | 阿水淀粉撒地方撒的 24 | 25 | 撒的发水淀粉撒地方 26 | 27 | 28 | 29 | 30 | 31 | Github: https://github.com/cryptokitties/ 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /projects/dAes/contest1/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /projects/dAes/dAes/scripts/deploy.js: -------------------------------------------------------------------------------- 1 | async function main() { 2 | // We get the contract to deploy 3 | const Canvas = await ethers.getContractFactory("Canvas"); 4 | const canvas = await Canvas.deploy('pixel' , 'PXL' , 36 , 20); 5 | 6 | console.log("Canvas deployed to:", canvas.address); 7 | } 8 | 9 | main() 10 | .then(() => process.exit(0)) 11 | .catch(error => { 12 | console.error(error); 13 | process.exit(1); 14 | }); -------------------------------------------------------------------------------- /projects/dAes/dAes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "daes", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@nomiclabs/hardhat-ethers": "^2.0.2", 14 | "@nomiclabs/hardhat-waffle": "^2.0.1", 15 | "@openzeppelin/contracts": "^4.1.0", 16 | "chai": "^4.3.4", 17 | "ethereum-waffle": "^3.3.0", 18 | "ethers": "^5.1.4", 19 | "hardhat": "^2.2.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /projects/dAes/contest1/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /projects/dAes/README.md: -------------------------------------------------------------------------------- 1 | # dAes - dencentrialize aesthetic 2 | 3 | # team: Art of Folks 4 | 5 | ## 简介 6 | 7 | 一句话:**社区参与的数字艺术创作工具** 8 | 9 | 目标用户: 10 | 11 | - 参与数字艺术创作的群体,不同于专业的创作者,群体相互激发,创作的冲动源于社会事件; 12 | - 能使用简单的创作工具对数字作品进行改编 13 | 14 | 用户的痛点: 15 | 16 | - 在传统市场中低共识低价值 17 | - 责权利不清 18 | 19 | 解决方案: 20 | 21 | - 引导性主题:社会事件-如日本核废料等 22 | - 简单创作工具,一键发布到NFT平台 23 | - 通过meme做社交性解读和传播 24 | - NFT确权,并分配收益 25 | 26 | ## 界面及功能 27 | 28 | 主要界面及功能包括: 29 | 30 | 集体创作界面: 31 | 32 | - 引导性主题-社会事件,每5分钟新闻热点刷新 33 | - 创作工具-涂色36x36 34 | - 5分钟创作倒计时 35 | 36 | 一键发布到NFT平台: 37 | 38 | - 支持承销员(策展人)使用Metamask钱包登陆 39 | - 自动铸造ERC-1155(数量1) 中包含ERC-721(数量36x36) 40 | - 自动发布ERC-1155 到 NFT平台opensea 41 | 42 | 作品展示及分享: 43 | 44 | - 作品详情展示 45 | - 社交性解读 46 | - 分享到社交平台 47 | -------------------------------------------------------------------------------- /projects/dAes/dAes/contracts/extensions/ICanvas.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | interface ICanvas { 6 | 7 | event Color(address indexed operator, uint16 indexed xAxis, uint16 indexed yAxis, uint8 r, uint8 g, uint8 b, uint8 a); 8 | 9 | /** 10 | * set color into a position 11 | */ 12 | function setColor(uint16 xAxis, uint16 yAxis, uint8 r, uint8 g, uint8 b, uint8 a) external; 13 | 14 | /** 15 | * get color from a position 16 | */ 17 | function getColor(uint16 xAxis, uint16 yAxis) external returns(uint8, uint8, uint8, uint8); 18 | 19 | /** 20 | * claim a token by position 21 | */ 22 | function claim(address claimer, uint16 xAxis, uint16 yAxis) external returns (uint256); 23 | } -------------------------------------------------------------------------------- /projects/dAes/contest1/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | background-color:#f7f4e6; 4 | position:relative; 5 | 6 | width:100%; 7 | height: 100vh; 8 | overflow: hidden; 9 | 10 | } 11 | 12 | .header{ 13 | position:absolute; 14 | z-index:2; 15 | min-height: calc(100vh / 3); 16 | width:100%; 17 | background-image: repeating-linear-gradient( 18 | -45deg 19 | ,#ffcad2,#ffcad2 20px,#ffd8e2 0,#ffd8e2 40px); 20 | background-size: 200% 200%; 21 | animation-duration: 20s; 22 | animation-timing-function: linear; 23 | animation-delay: 0s; 24 | animation-iteration-count: infinite; 25 | animation-direction: normal; 26 | animation-fill-mode: none; 27 | animation-play-state: running; 28 | animation-name: barberpole-data-v-6b3d2142; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /projects/dAes/dAes/contracts/extensions/IERC721ExMetadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; 6 | 7 | /** 8 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension 9 | * @dev See https://eips.ethereum.org/EIPS/eip-721 10 | */ 11 | interface IERC721ExMetadata is IERC721 { 12 | 13 | /** 14 | * @dev Returns the token collection name. 15 | */ 16 | function name() external view returns (string memory); 17 | 18 | /** 19 | * @dev Returns the token collection symbol. 20 | */ 21 | function symbol() external view returns (string memory); 22 | 23 | /** 24 | * @dev Returns the painting's witdh 25 | */ 26 | function width() external view returns (uint16); 27 | 28 | /** 29 | * @dev Returns the painting's height 30 | */ 31 | function height() external view returns (uint16); 32 | } 33 | -------------------------------------------------------------------------------- /projects/dAes/contest1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "contest1", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.12.0", 7 | "@testing-library/react": "^11.2.7", 8 | "@testing-library/user-event": "^12.8.3", 9 | "ethers": "^5.1.4", 10 | "react": "^17.0.2", 11 | "react-countdown-circle-timer": "^2.5.3", 12 | "react-dom": "^17.0.2", 13 | "react-input-color": "^4.0.0", 14 | "react-router": "^5.2.0", 15 | "react-scripts": "^4.0.3", 16 | "react-use-web3": "^1.1.2", 17 | "web-vitals": "^1.1.2", 18 | "web3": "^1.3.6" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": [ 28 | "react-app", 29 | "react-app/jest" 30 | ] 31 | }, 32 | "browserslist": { 33 | "production": [ 34 | ">0.2%", 35 | "not dead", 36 | "not op_mini all" 37 | ], 38 | "development": [ 39 | "last 1 chrome version", 40 | "last 1 firefox version", 41 | "last 1 safari version" 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /projects/dAes/dAes/test/Canvas.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | 3 | describe("Token contract", function() { 4 | it("Deployment should assign the total supply of tokens to the owner", async function() { 5 | 6 | const Canvas = await ethers.getContractFactory("Canvas"); 7 | const canvas = await Canvas.deploy('pixel' , 'PXL' , 128 , 128); 8 | var symbol = await canvas.symbol(); 9 | console.log(symbol); 10 | await canvas.deployed(); 11 | 12 | 13 | var init_color = await canvas.getColor( 7 , 7); 14 | console.log(init_color); 15 | 16 | await canvas.setColor(7,7 , 1,2,3,4); 17 | var next_color = await canvas.getColor( 7 , 7); 18 | console.log(next_color); 19 | }); 20 | 21 | describe("claim position", function() { 22 | it("To proof claim method can run normally", async function() { 23 | const [caller] = await ethers.getSigners(); 24 | 25 | console.log(caller.address); 26 | 27 | const Canvas = await ethers.getContractFactory("Canvas"); 28 | const canvas = await Canvas.deploy('pixel' , 'PXL' , 128 , 128); 29 | 30 | await canvas.deployed(); 31 | 32 | await canvas.claim(caller.address, 0, 0); 33 | let count = await canvas.balanceOf(caller.address); 34 | console.log(count); 35 | let owner = await canvas.ownerOf(0); 36 | console.log(owner); 37 | }); 38 | }); 39 | }); -------------------------------------------------------------------------------- /projects/dAes/contest1/src/App.js: -------------------------------------------------------------------------------- 1 | 2 | import React, { createContext } from 'react'; 3 | import './App.css'; 4 | import Board from './components/show.js' 5 | import App1 from './components/App1.js' 6 | // import useWeb3 from 'react-use-web3'; 7 | import Web3 from "web3" 8 | export const Web3Context = createContext(); 9 | function App() { 10 | 11 | // const { web3, network } = useWeb3(); 12 | let web3 = null 13 | // metamask 14 | if (window.ethereum) { 15 | web3 = new Web3(window.ethereum) 16 | window.ethereum.enable().then(() => { 17 | web3.eth.getAccounts((_, accounts) => { 18 | window.defaultAccount = accounts[0]; 19 | console.log(window.defaultAccount); 20 | }) 21 | }) 22 | } 23 | // } else if (typeof web3 !== 'undefined') { 24 | // web3 = new Web3(web3.currentProvider); 25 | // window.defaultAccount = web3.eth.accounts[0]; 26 | // console.log(window.defaultAccount) 27 | // } else { 28 | // let provider = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/0e68b6ad41f24d6f975fbcd16f82dfec")) 29 | // web3 = new Web3(provider) 30 | // } 31 | return ( 32 |
33 |
34 |
35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | ); 45 | } 46 | 47 | export default App; 48 | -------------------------------------------------------------------------------- /projects/dAes/dAes/tasks/faucet.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | // This file is only here to make interacting with the Dapp easier, 4 | // feel free to ignore it if you don't need it. 5 | 6 | task("faucet", "Sends ETH and tokens to an address") 7 | .addPositionalParam("receiver", "The address that will receive them") 8 | .setAction(async ({ receiver }) => { 9 | if (network.name === "hardhat") { 10 | console.warn( 11 | "You are running the faucet task with Hardhat network, which" + 12 | "gets automatically created and destroyed every time. Use the Hardhat" + 13 | " option '--network localhost'" 14 | ); 15 | } 16 | const [sender] = await ethers.getSigners(); 17 | const tx = await sender.sendTransaction({ 18 | to: receiver, 19 | value: ethers.constants.WeiPerEther, 20 | }); 21 | await tx.wait(); 22 | 23 | console.log(`Transferred 1 ETH and 100 tokens to ${receiver}`); 24 | 25 | 26 | // const addressesFile = 27 | // __dirname + "/../src/artifacts/contracts/Canvas.sol/Canvas.json"; 28 | 29 | // console.log(addressesFile); 30 | // if (!fs.existsSync(addressesFile)) { 31 | // console.error("You need to deploy your contract first"); 32 | // return; 33 | // } 34 | 35 | // const addressJson = fs.readFileSync(addressesFile); 36 | // const address = JSON.parse(addressJson); 37 | 38 | // if ((await ethers.provider.getCode(address.Token)) === "0x") { 39 | // console.error("You need to deploy your contract first"); 40 | // return; 41 | // } 42 | 43 | // const token = await ethers.getContractAt("Token", address.Token); 44 | // const tx2 = await token.transfer(receiver, 100); 45 | // await tx2.wait(); 46 | }); -------------------------------------------------------------------------------- /projects/dAes/contest1/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/components/App1.js: -------------------------------------------------------------------------------- 1 | import './App1.css'; 2 | import { useState } from 'react'; 3 | import { ethers } from 'ethers' 4 | //import Greeter from './artifacts/contracts/Greeter.sol/Greeter.json' 5 | //import Token from './artifacts/contracts/Token.sol/Token.json' 6 | 7 | const greeterAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" 8 | const tokenAddress = "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" 9 | const Greeter={} 10 | const Token={} 11 | 12 | function App1() { 13 | const [greeting, setGreetingValue] = useState() 14 | const [userAccount, setUserAccount] = useState() 15 | const [amount, setAmount] = useState() 16 | 17 | async function requestAccount() { 18 | await window.ethereum.request({ method: 'eth_requestAccounts' }); 19 | } 20 | 21 | async function fetchGreeting() { 22 | if (typeof window.ethereum !== 'undefined') { 23 | const provider = new ethers.providers.Web3Provider(window.ethereum) 24 | console.log({ provider }) 25 | const contract = new ethers.Contract(greeterAddress, Greeter.abi, provider) 26 | try { 27 | const data = await contract.greet() 28 | console.log('data: ', data) 29 | } catch (err) { 30 | console.log("Error: ", err) 31 | } 32 | } 33 | } 34 | 35 | async function getBalance() { 36 | if (typeof window.ethereum !== 'undefined') { 37 | const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' }) 38 | const provider = new ethers.providers.Web3Provider(window.ethereum); 39 | const contract = new ethers.Contract(tokenAddress, Token.abi, provider) 40 | const balance = await contract.balanceOf(account); 41 | console.log("Balance: ", balance.toString()); 42 | } 43 | } 44 | 45 | async function setGreeting() { 46 | if (!greeting) return 47 | if (typeof window.ethereum !== 'undefined') { 48 | await requestAccount() 49 | const provider = new ethers.providers.Web3Provider(window.ethereum); 50 | console.log({ provider }) 51 | const signer = provider.getSigner() 52 | const contract = new ethers.Contract(greeterAddress, Greeter.abi, signer) 53 | const transaction = await contract.setGreeting(greeting) 54 | await transaction.wait() 55 | fetchGreeting() 56 | } 57 | } 58 | 59 | async function sendCoins() { 60 | if (typeof window.ethereum !== 'undefined') { 61 | await requestAccount() 62 | const provider = new ethers.providers.Web3Provider(window.ethereum); 63 | const signer = provider.getSigner(); 64 | const contract = new ethers.Contract(tokenAddress, Token.abi, signer); 65 | const transaction = await contract.transfer(userAccount, amount); 66 | await transaction.wait(); 67 | console.log(`${amount} Coins successfully sent to ${userAccount}`); 68 | } 69 | } 70 | 71 | return ( 72 |
73 |
74 | 75 | 76 | setGreetingValue(e.target.value)} placeholder="Set greeting" /> 77 | 78 |
79 | 80 | 81 | setUserAccount(e.target.value)} placeholder="Account ID" /> 82 | setAmount(e.target.value)} placeholder="Amount" /> 83 |
84 |
85 | ); 86 | } 87 | 88 | export default App1; -------------------------------------------------------------------------------- /projects/dAes/contest1/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2021Q2 Rebase Hackathon 2 | 3 | 办一场 Hacker 们的聚会是作为松散 Hacker 组织的一个想法! 于是诞生了这次 Rebase Hackathon。 4 | 5 | **一场 Hacker 们为 Hacker 们举办的一场「五城同时开赛,线上跨城互动」的黑客松** 6 | 7 | 8 | **时间:** 9 | 2021年5月14日 到 2021年5月16日 10 | 11 | **赛程:** 12 | 比赛阶段分为三个环节,开场、现场编程和奖项评选 13 | * 5.14日上午 9:30 到5.14日上午 12:00 为开场环节 14 | * 5.14日上午 12:00 到5.16日上午 12:00 为48小时编程环节 15 | * 5.16日下午 12:00 到 5.16日下午 16:00 为 Demo 和 奖项评选 16 | 5.16日下午 16:00 到 5.16日下午 18:00 为双选会和自由社交环节 17 | 18 | **奖项设置** 19 | 通过现场评委评选的奖项有: 20 | * **一等奖 一名 奖金 20000 USDT** 21 | * **二等奖 两名 奖金 5000 USDT** 22 | * **三等奖 三名 奖金 2000 USDT** 23 | 24 | 通过现场观众评选的奖项有: 25 | * 最佳创意奖 两名 1000 USDT 26 | * 最受欢迎奖 两名 1000 USDT 27 | 28 | 通过线上观众评选的奖项有: 29 | * 最佳社区奖 两名 1000 USDT 30 | 31 | 详情参见 [参赛手册](https://mp.weixin.qq.com/s/ZWcd2LQm_PBwvOFuevpdIw) 32 | 33 | 34 | # 参赛队伍注意事项 35 | 36 | ## 项目提交流程 37 | 38 | 1. fork 这个代码仓库 39 | 2. 先在 `projects` 内生成一个目录,以你们团队或作品命名,里面先放个空档案,或 README.md 简单介绍团队 40 | 3. 创建一个 PR,目的是预留一个 PR 编号作为队伍或作品编号,在提交的 PR 名字中请包含 PR 编号和作品或团队名称 41 | 4. 在 Github 上将 PR 转成 Draft 42 | 5. 之后将所有参赛相关信息放在该目录中,当完成作品时请修改 PR 状态为 Ready For Review,会有咱们的工作人员来合并 PR 43 | 44 | 所有参赛作品相关资料都放在你们的团队名称里的目录里,可以按照以下方式: 45 | 46 | ``` 47 | projects 48 | L 01-CryptoKitties 49 | L docs // 这里放所有文档,项目资料,规划,demo 链接, ppt (链接) 50 | L README.md // 作品、团队介绍信息、项目代码Github链接等 51 | ``` 52 | 53 | **该提交流程为方便整个沟通工作,提升多城之间的协同效率。** 54 | 55 | 56 | ## 评审流程 57 | 参加最终评审的作品将以PR更新时间不超过 2021 年 5 月 16 日 中午 12:00 为准,筹备小组会依据现场情况适当调整。 58 | 59 | 每一队伍演示时间为 5 分钟,然后会有 2 分钟评委们提问及点评。 60 | 61 | ### 黑客松大赛奖 62 | 评委们根据以下维度打分: 63 | * 商业价值 (25%):是否解决问题,是否具备应用场景,是否具备潜在商业价值; 64 | * 创新性 (25%):作品立意新颖,打破常规思维,突破局限,具备创新性; 65 | * 技术挑战 (25%):作品技术方案具备一定技术难度,或在技术上具备新的突破; 66 | * 作品完成度 (25%):作品完成如何,现场编码占比如何,可演示,避免PPT作品; 67 | 68 | 每位评委各有 5 票,可以投给通过以上四个维度评选出的五支队伍,每支队伍仅限一票。 69 | 70 | 演示时需要尽可能的将作品解决的问题、具有的意义以及如何贴近主题等讲解出来是展示作品的最佳方式。以下小提示将会帮助到你: 71 | * 快速讲解项目源起,解决的问题,现实意义,商业模式等 72 | * 可以讲解在黑客松期间完成的内容是什么 73 | * 现在做到什么程度,未来半年到一年有什么发展计划 74 | * 简单的录屏有时能避免复杂的交互过程带来的翻车问题 75 | * 尽量精炼语言表达,充分准备 76 | * 其他更多方面 77 | 78 | ### 大赛观众奖 79 | 参赛队伍在参赛时可以领取选票,每支队伍可以选择两个其他最具创意作品和两个最受欢迎组品。 80 | 81 | ### 线上观众奖 82 | 在现场评选过程中通过线上社区投票票选出最佳社区奖两个。 83 | 投票方式将在现场公布。 84 | 85 | 86 | 请注意: 87 | - 参赛作品若出现剽窃其他作品行为,取消参赛资格。 88 | 89 | ## Workshop 90 | - 到我们 [B 站频道](https://space.bilibili.com/382886213) 观看过往录播 91 | 92 | ## 其他 93 | 94 | ### 合法合规性 95 | 96 | 本次黑客松为符合国内法规,我们不会触碰以下任何有关题目 97 | 98 | - 和发币 (Initial Coin Offering) 相关。 99 | - 和数字资产交易相关 100 | - 任何币价的讨论 (Decentralized Exchange 主题可讨论技术,不涉及币价) 101 | - 和博彩相关和有博彩成分的游戏 102 | 103 | ### 参赛项目协议 (License) 104 | 105 | 所有参赛项目协议必须选用其中一个开源软件项目协议。下面有对主流协议的介绍 (包括 GPLv3, Apache License 2.0, BSD, MIT License)。如果真不知道怎么选,可考虑使用 MIT License。这协议给予其他开发者很大的自由度。 106 | 107 | 参考链接 108 | 109 | - [主流开源协议介绍 - 英文](https://www.freecodecamp.org/news/how-open-source-licenses-work-and-how-to-add-them-to-your-projects-34310c3cf94/) 110 | - [主流开源协议介绍 - 中文](https://www.runoob.com/w3cnote/open-source-license.html) 111 | 112 | 113 | 114 | ## 联络我们 115 | 116 | 对黑客松有任何疑问,可以下方法联系我们: 117 | 118 | * 微信 119 | 小助手 120 | 121 | 122 | ## 过往信息 123 | [报名文章](https://mp.weixin.qq.com/s/-DeOn_mElWTK0p3jcKI7ww) 124 | [进展汇报一](https://mp.weixin.qq.com/s/5_4uGEvtfvxqqTBrUQD9og) 125 | [进展汇报二](https://mp.weixin.qq.com/s/QItthGYHAEKEYkWiAmo1MA) 126 | [参赛手册](https://mp.weixin.qq.com/s/ZWcd2LQm_PBwvOFuevpdIw) 127 | 128 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/components/show.css: -------------------------------------------------------------------------------- 1 | 2 | .board-row{ 3 | display: flex; 4 | flex-direction: row; 5 | } 6 | .center{ 7 | width:calc(60vw + 147px); 8 | height:600px; 9 | margin:20px 0px 0px 50px; 10 | background-color: #8c7c64; 11 | border-radius: 10px; 12 | padding:20px; 13 | background-image: radial-gradient(#a39277 2px,transparent 0),radial-gradient(#a39277 2px,transparent 0); 14 | background-position: 0 0,50px 50px; 15 | background-size: 20px 20px; 16 | background-repeat: repeat; 17 | box-shadow: 0 10px 20px rgba(0,0,0,.2); 18 | 19 | } 20 | .center::before{ 21 | position: absolute; 22 | content: 'Welcome To Pixel'; 23 | width:300px; 24 | height: 50px; 25 | background-color: #f7f4e6; 26 | left: 100px; 27 | top:-30px; 28 | border-radius: 5px 5px 0 0; 29 | font-size: 25px; 30 | font-weight: 800; 31 | line-height: 50px; 32 | color:#503c35; 33 | } 34 | .box{ 35 | min-width:calc(60vw / 36) ; 36 | min-height:calc(60vw / 36); 37 | margin-right:2px; 38 | margin-bottom: 2px; 39 | background-color: rgb(127, 255, 212); 40 | border:solid 1px 41 | } 42 | .box:hover{ 43 | border:solid 1px #feab88!important; 44 | cursor: pointer; 45 | } 46 | 47 | 48 | .text{ 49 | font-size: 20px; 50 | font-weight: 600; 51 | } 52 | .value{ 53 | font-size: 20px; 54 | font-weight: 800; 55 | } 56 | .right{ 57 | margin-top:40px; 58 | margin-left:40px; 59 | background-color:#ffcad2; 60 | width:210px; 61 | height: 210px; 62 | padding:15px; 63 | box-sizing: border-box; 64 | border-radius: 23px; 65 | box-shadow: 0 10px 20px rgba(0,0,0,.2); 66 | } 67 | .Board{ 68 | position: relative; 69 | height:100%; 70 | width:100%; 71 | display: flex; 72 | z-index: 10; 73 | 74 | } 75 | 76 | 77 | .flex-row{ 78 | display: flex; 79 | flex-direction: row; 80 | justify-content: center; 81 | margin-bottom: 15px; 82 | color:#cdeddf; 83 | font-weight: 800; 84 | font-size: 22px; 85 | 86 | } 87 | .btn{ 88 | /*background-image: linear-gradient(180deg, #6536FB 0%, rgba(109,72,226,0.27) 100%);*/ 89 | border :5px solid #cdeddf; 90 | 91 | border-radius: 30px; 92 | width:100px; 93 | height:30px; 94 | font-size: 16px; 95 | line-height: 30px; 96 | color:#cdeddf; 97 | font-weight: 600; 98 | 99 | 100 | 101 | } 102 | .btn ,.btn1:hover{ 103 | cursor: pointer; 104 | } 105 | .flex-row12{ 106 | 107 | display: flex; 108 | flex-direction: row; 109 | justify-content: space-between; 110 | width:240px; 111 | margin:0 auto; 112 | } 113 | 114 | .dialog{ 115 | z-index: 5; 116 | height:178px; 117 | position:absolute; 118 | width: 288px; 119 | top:350px; 120 | 121 | right:25px; 122 | background-color:#00d2c2; 123 | border-radius: 30px; 124 | 125 | font-size: 16px; 126 | color: #FFFFFF; 127 | line-height: 16px; 128 | display: flex; 129 | flex-direction:column; 130 | justify-content: center; 131 | box-shadow: 0 10px 20px rgba(0,0,0,.2); 132 | 133 | 134 | } 135 | .dialog::after{ 136 | position:absolute; 137 | content:''; 138 | height:50px; 139 | width: 25px; 140 | background-color: #8c7c64; 141 | border-radius: 5px; 142 | top: -10px; 143 | transform: rotate(-45deg); 144 | background-image: radial-gradient(#a39277 2px,transparent 0),radial-gradient(#a39277 2px,transparent 0); 145 | background-size: 20px 20px; 146 | background-repeat: repeat; 147 | 148 | 149 | } 150 | .dialog::before{ 151 | position:absolute; 152 | content:''; 153 | height:50px; 154 | width: 25px; 155 | background-color: #8c7c64; 156 | border-radius: 5px; 157 | top: -10px; 158 | right:0; 159 | transform: rotate(45deg); 160 | background-image: radial-gradient(#a39277 2px,transparent 0),radial-gradient(#a39277 2px,transparent 0); 161 | background-size: 20px 20px; 162 | background-repeat: repeat; 163 | box-shadow: 0 10px 20px rgba(0,0,0,.2); 164 | 165 | 166 | } 167 | .btn1{ 168 | 169 | 170 | border-radius: 5px; 171 | width:calc(100% - 100px); 172 | height:30px; 173 | font-size: 16px; 174 | line-height: 30px; 175 | background: #8c7c64; 176 | background-image: url('../backgrounf.png'); 177 | background-size: cover; 178 | margin:0 auto; 179 | margin-top:10px; 180 | position: absolute; 181 | bottom:-10px; 182 | right: 30px; 183 | font-weight: 800; 184 | color:#f7f4e6; 185 | background-image: radial-gradient(#a39277 2px,transparent 0),radial-gradient(#a39277 2px,transparent 0); 186 | background-size: 20px 20px; 187 | background-repeat: repeat; 188 | box-shadow: 0 10px 20px rgba(0,0,0,.2); 189 | 190 | 191 | } 192 | 193 | .btn1:hover::after{ 194 | position: absolute; 195 | left: -10px; 196 | top: 50px; 197 | padding: 5px; 198 | background-color: #b4bdfd; 199 | border-radius: 15px; 200 | color: #fff; 201 | height:100px; 202 | width:200px; 203 | color:#4d3d36; 204 | font-size: 15px; 205 | font-weight: 800; 206 | padding:20px; 207 | line-height: 30px; 208 | 209 | 210 | 211 | content: attr(title); 212 | box-shadow: 0 10px 20px rgba(0,0,0,.2); 213 | 214 | 215 | } 216 | 217 | .btn1:hover::before{ 218 | position: absolute; 219 | 220 | 221 | background-color: #f7f4e5; 222 | background-image: url('../提示.png'); 223 | background-size:28px 28px ; 224 | background-repeat: no-repeat; 225 | content: ''; 226 | box-shadow: 0 10px 20px rgba(0,0,0,.2); 227 | height: 30px; 228 | width: 30px; 229 | left:-15px; 230 | top: 40px; 231 | border-radius: 15px; 232 | z-index:4; 233 | 234 | } 235 | 236 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /projects/dAes/contest1/src/abi/index.js: -------------------------------------------------------------------------------- 1 | const abi = [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "string", 6 | "name": "name_", 7 | "type": "string" 8 | }, 9 | { 10 | "internalType": "string", 11 | "name": "symbol_", 12 | "type": "string" 13 | }, 14 | { 15 | "internalType": "uint16", 16 | "name": "width_", 17 | "type": "uint16" 18 | }, 19 | { 20 | "internalType": "uint16", 21 | "name": "height_", 22 | "type": "uint16" 23 | } 24 | ], 25 | "stateMutability": "nonpayable", 26 | "type": "constructor" 27 | }, 28 | { 29 | "anonymous": false, 30 | "inputs": [ 31 | { 32 | "indexed": true, 33 | "internalType": "address", 34 | "name": "owner", 35 | "type": "address" 36 | }, 37 | { 38 | "indexed": true, 39 | "internalType": "address", 40 | "name": "approved", 41 | "type": "address" 42 | }, 43 | { 44 | "indexed": true, 45 | "internalType": "uint256", 46 | "name": "tokenId", 47 | "type": "uint256" 48 | } 49 | ], 50 | "name": "Approval", 51 | "type": "event" 52 | }, 53 | { 54 | "anonymous": false, 55 | "inputs": [ 56 | { 57 | "indexed": true, 58 | "internalType": "address", 59 | "name": "owner", 60 | "type": "address" 61 | }, 62 | { 63 | "indexed": true, 64 | "internalType": "address", 65 | "name": "operator", 66 | "type": "address" 67 | }, 68 | { 69 | "indexed": false, 70 | "internalType": "bool", 71 | "name": "approved", 72 | "type": "bool" 73 | } 74 | ], 75 | "name": "ApprovalForAll", 76 | "type": "event" 77 | }, 78 | { 79 | "inputs": [ 80 | { 81 | "internalType": "address", 82 | "name": "to", 83 | "type": "address" 84 | }, 85 | { 86 | "internalType": "uint256", 87 | "name": "tokenId", 88 | "type": "uint256" 89 | } 90 | ], 91 | "name": "approve", 92 | "outputs": [], 93 | "stateMutability": "nonpayable", 94 | "type": "function" 95 | }, 96 | { 97 | "inputs": [ 98 | { 99 | "internalType": "address", 100 | "name": "claimer", 101 | "type": "address" 102 | }, 103 | { 104 | "internalType": "uint16", 105 | "name": "xAxis", 106 | "type": "uint16" 107 | }, 108 | { 109 | "internalType": "uint16", 110 | "name": "yAxis", 111 | "type": "uint16" 112 | } 113 | ], 114 | "name": "claim", 115 | "outputs": [ 116 | { 117 | "internalType": "uint256", 118 | "name": "", 119 | "type": "uint256" 120 | } 121 | ], 122 | "stateMutability": "nonpayable", 123 | "type": "function" 124 | }, 125 | { 126 | "anonymous": false, 127 | "inputs": [ 128 | { 129 | "indexed": true, 130 | "internalType": "address", 131 | "name": "operator", 132 | "type": "address" 133 | }, 134 | { 135 | "indexed": true, 136 | "internalType": "uint16", 137 | "name": "xAxis", 138 | "type": "uint16" 139 | }, 140 | { 141 | "indexed": true, 142 | "internalType": "uint16", 143 | "name": "yAxis", 144 | "type": "uint16" 145 | }, 146 | { 147 | "indexed": false, 148 | "internalType": "uint8", 149 | "name": "r", 150 | "type": "uint8" 151 | }, 152 | { 153 | "indexed": false, 154 | "internalType": "uint8", 155 | "name": "g", 156 | "type": "uint8" 157 | }, 158 | { 159 | "indexed": false, 160 | "internalType": "uint8", 161 | "name": "b", 162 | "type": "uint8" 163 | }, 164 | { 165 | "indexed": false, 166 | "internalType": "uint8", 167 | "name": "a", 168 | "type": "uint8" 169 | } 170 | ], 171 | "name": "Color", 172 | "type": "event" 173 | }, 174 | { 175 | "inputs": [ 176 | { 177 | "internalType": "address", 178 | "name": "from", 179 | "type": "address" 180 | }, 181 | { 182 | "internalType": "address", 183 | "name": "to", 184 | "type": "address" 185 | }, 186 | { 187 | "internalType": "uint256", 188 | "name": "tokenId", 189 | "type": "uint256" 190 | } 191 | ], 192 | "name": "safeTransferFrom", 193 | "outputs": [], 194 | "stateMutability": "nonpayable", 195 | "type": "function" 196 | }, 197 | { 198 | "inputs": [ 199 | { 200 | "internalType": "address", 201 | "name": "from", 202 | "type": "address" 203 | }, 204 | { 205 | "internalType": "address", 206 | "name": "to", 207 | "type": "address" 208 | }, 209 | { 210 | "internalType": "uint256", 211 | "name": "tokenId", 212 | "type": "uint256" 213 | }, 214 | { 215 | "internalType": "bytes", 216 | "name": "_data", 217 | "type": "bytes" 218 | } 219 | ], 220 | "name": "safeTransferFrom", 221 | "outputs": [], 222 | "stateMutability": "nonpayable", 223 | "type": "function" 224 | }, 225 | { 226 | "inputs": [ 227 | { 228 | "internalType": "address", 229 | "name": "operator", 230 | "type": "address" 231 | }, 232 | { 233 | "internalType": "bool", 234 | "name": "approved", 235 | "type": "bool" 236 | } 237 | ], 238 | "name": "setApprovalForAll", 239 | "outputs": [], 240 | "stateMutability": "nonpayable", 241 | "type": "function" 242 | }, 243 | { 244 | "inputs": [ 245 | { 246 | "internalType": "uint16", 247 | "name": "xAxis_", 248 | "type": "uint16" 249 | }, 250 | { 251 | "internalType": "uint16", 252 | "name": "yAxis_", 253 | "type": "uint16" 254 | }, 255 | { 256 | "internalType": "uint8", 257 | "name": "r_", 258 | "type": "uint8" 259 | }, 260 | { 261 | "internalType": "uint8", 262 | "name": "g_", 263 | "type": "uint8" 264 | }, 265 | { 266 | "internalType": "uint8", 267 | "name": "b_", 268 | "type": "uint8" 269 | }, 270 | { 271 | "internalType": "uint8", 272 | "name": "a_", 273 | "type": "uint8" 274 | } 275 | ], 276 | "name": "setColor", 277 | "outputs": [], 278 | "stateMutability": "nonpayable", 279 | "type": "function" 280 | }, 281 | { 282 | "anonymous": false, 283 | "inputs": [ 284 | { 285 | "indexed": true, 286 | "internalType": "address", 287 | "name": "from", 288 | "type": "address" 289 | }, 290 | { 291 | "indexed": true, 292 | "internalType": "address", 293 | "name": "to", 294 | "type": "address" 295 | }, 296 | { 297 | "indexed": true, 298 | "internalType": "uint256", 299 | "name": "tokenId", 300 | "type": "uint256" 301 | } 302 | ], 303 | "name": "Transfer", 304 | "type": "event" 305 | }, 306 | { 307 | "inputs": [ 308 | { 309 | "internalType": "address", 310 | "name": "from", 311 | "type": "address" 312 | }, 313 | { 314 | "internalType": "address", 315 | "name": "to", 316 | "type": "address" 317 | }, 318 | { 319 | "internalType": "uint256", 320 | "name": "tokenId", 321 | "type": "uint256" 322 | } 323 | ], 324 | "name": "transferFrom", 325 | "outputs": [], 326 | "stateMutability": "nonpayable", 327 | "type": "function" 328 | }, 329 | { 330 | "inputs": [ 331 | { 332 | "internalType": "address", 333 | "name": "owner", 334 | "type": "address" 335 | } 336 | ], 337 | "name": "balanceOf", 338 | "outputs": [ 339 | { 340 | "internalType": "uint256", 341 | "name": "", 342 | "type": "uint256" 343 | } 344 | ], 345 | "stateMutability": "view", 346 | "type": "function" 347 | }, 348 | { 349 | "inputs": [ 350 | { 351 | "internalType": "uint256", 352 | "name": "tokenId", 353 | "type": "uint256" 354 | } 355 | ], 356 | "name": "getApproved", 357 | "outputs": [ 358 | { 359 | "internalType": "address", 360 | "name": "", 361 | "type": "address" 362 | } 363 | ], 364 | "stateMutability": "view", 365 | "type": "function" 366 | }, 367 | { 368 | "inputs": [ 369 | { 370 | "internalType": "uint16", 371 | "name": "xAxis_", 372 | "type": "uint16" 373 | }, 374 | { 375 | "internalType": "uint16", 376 | "name": "yAxis_", 377 | "type": "uint16" 378 | } 379 | ], 380 | "name": "getColor", 381 | "outputs": [ 382 | { 383 | "internalType": "uint8", 384 | "name": "", 385 | "type": "uint8" 386 | }, 387 | { 388 | "internalType": "uint8", 389 | "name": "", 390 | "type": "uint8" 391 | }, 392 | { 393 | "internalType": "uint8", 394 | "name": "", 395 | "type": "uint8" 396 | }, 397 | { 398 | "internalType": "uint8", 399 | "name": "", 400 | "type": "uint8" 401 | } 402 | ], 403 | "stateMutability": "view", 404 | "type": "function" 405 | }, 406 | { 407 | "inputs": [], 408 | "name": "height", 409 | "outputs": [ 410 | { 411 | "internalType": "uint16", 412 | "name": "", 413 | "type": "uint16" 414 | } 415 | ], 416 | "stateMutability": "view", 417 | "type": "function" 418 | }, 419 | { 420 | "inputs": [ 421 | { 422 | "internalType": "address", 423 | "name": "owner", 424 | "type": "address" 425 | }, 426 | { 427 | "internalType": "address", 428 | "name": "operator", 429 | "type": "address" 430 | } 431 | ], 432 | "name": "isApprovedForAll", 433 | "outputs": [ 434 | { 435 | "internalType": "bool", 436 | "name": "", 437 | "type": "bool" 438 | } 439 | ], 440 | "stateMutability": "view", 441 | "type": "function" 442 | }, 443 | { 444 | "inputs": [], 445 | "name": "name", 446 | "outputs": [ 447 | { 448 | "internalType": "string", 449 | "name": "", 450 | "type": "string" 451 | } 452 | ], 453 | "stateMutability": "view", 454 | "type": "function" 455 | }, 456 | { 457 | "inputs": [ 458 | { 459 | "internalType": "uint256", 460 | "name": "tokenId", 461 | "type": "uint256" 462 | } 463 | ], 464 | "name": "ownerOf", 465 | "outputs": [ 466 | { 467 | "internalType": "address", 468 | "name": "", 469 | "type": "address" 470 | } 471 | ], 472 | "stateMutability": "view", 473 | "type": "function" 474 | }, 475 | { 476 | "inputs": [ 477 | { 478 | "internalType": "bytes4", 479 | "name": "interfaceId", 480 | "type": "bytes4" 481 | } 482 | ], 483 | "name": "supportsInterface", 484 | "outputs": [ 485 | { 486 | "internalType": "bool", 487 | "name": "", 488 | "type": "bool" 489 | } 490 | ], 491 | "stateMutability": "view", 492 | "type": "function" 493 | }, 494 | { 495 | "inputs": [], 496 | "name": "symbol", 497 | "outputs": [ 498 | { 499 | "internalType": "string", 500 | "name": "", 501 | "type": "string" 502 | } 503 | ], 504 | "stateMutability": "view", 505 | "type": "function" 506 | }, 507 | { 508 | "inputs": [], 509 | "name": "width", 510 | "outputs": [ 511 | { 512 | "internalType": "uint16", 513 | "name": "", 514 | "type": "uint16" 515 | } 516 | ], 517 | "stateMutability": "view", 518 | "type": "function" 519 | } 520 | ] 521 | 522 | export default abi 523 | -------------------------------------------------------------------------------- /projects/dAes/dAes/contracts/Canvas.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; 6 | import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; 7 | import "@openzeppelin/contracts/utils/Counters.sol"; 8 | import "@openzeppelin/contracts/utils/Address.sol"; 9 | import "@openzeppelin/contracts/utils/Context.sol"; 10 | import "@openzeppelin/contracts/utils/Strings.sol"; 11 | import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; 12 | import "./extensions/IERC721ExMetadata.sol"; 13 | import "./extensions/ICanvas.sol"; 14 | 15 | contract Canvas is Context, ERC165, IERC721, IERC721ExMetadata, ICanvas{ 16 | using Address for address; 17 | using Strings for uint256; 18 | 19 | // Token name 20 | string private _name; 21 | 22 | // Token symbol 23 | string private _symbol; 24 | 25 | // Canvas's width 26 | uint16 private _width; 27 | 28 | // Canvas's height 29 | uint16 private _height; 30 | 31 | struct Pixel { 32 | uint8 R; 33 | uint8 G; 34 | uint8 B; 35 | uint8 A; 36 | } 37 | 38 | // Mapping all pixels in canvas 39 | mapping (uint256 => Pixel) private _canvas; 40 | 41 | // Mapping from token ID to owner address 42 | mapping (uint256 => address) private _owners; 43 | 44 | // Mapping owner address to token count 45 | mapping (address => uint256) private _balances; 46 | 47 | // Mapping from token ID to approved address 48 | mapping (uint256 => address) private _tokenApprovals; 49 | 50 | // Mapping from owner to operator approvals 51 | mapping (address => mapping (address => bool)) private _operatorApprovals; 52 | 53 | constructor (string memory name_, string memory symbol_, uint16 width_, uint16 height_) { 54 | _name = name_; 55 | _symbol = symbol_; 56 | _width = width_; 57 | _height = height_; 58 | } 59 | 60 | /** 61 | * @dev See {IERC165-supportsInterface}. 62 | */ 63 | function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { 64 | return interfaceId == type(IERC721).interfaceId 65 | || interfaceId == type(IERC721ExMetadata).interfaceId 66 | || super.supportsInterface(interfaceId); 67 | } 68 | 69 | /** 70 | * @dev See {IERC721-balanceOf}. 71 | */ 72 | function balanceOf(address owner) public view virtual override returns (uint256) { 73 | require(owner != address(0), "ERC721: balance query for the zero address"); 74 | return _balances[owner]; 75 | } 76 | 77 | /** 78 | * @dev See {IERC721-ownerOf}. 79 | */ 80 | function ownerOf(uint256 tokenId) public view virtual override returns (address) { 81 | address owner = _owners[tokenId]; 82 | require(owner != address(0), "ERC721: owner query for nonexistent token"); 83 | return owner; 84 | } 85 | 86 | /** 87 | * @dev See {IERC721Metadata-name}. 88 | */ 89 | function name() public view virtual override returns (string memory) { 90 | return _name; 91 | } 92 | 93 | /** 94 | * @dev See {IERC721Metadata-symbol}. 95 | */ 96 | function symbol() public view virtual override returns (string memory) { 97 | return _symbol; 98 | } 99 | 100 | function width() public view virtual override returns (uint16) { 101 | return _width; 102 | } 103 | 104 | function height() public view virtual override returns (uint16) { 105 | return _height; 106 | } 107 | 108 | /** 109 | * @dev See {IERC721-approve}. 110 | */ 111 | function approve(address to, uint256 tokenId) public virtual override { 112 | address owner = Canvas.ownerOf(tokenId); 113 | require(to != owner, "ERC721: approval to current owner"); 114 | 115 | require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), 116 | "ERC721: approve caller is not owner nor approved for all" 117 | ); 118 | 119 | _approve(to, tokenId); 120 | } 121 | 122 | /** 123 | * @dev See {IERC721-getApproved}. 124 | */ 125 | function getApproved(uint256 tokenId) public view virtual override returns (address) { 126 | require(_exists(tokenId), "ERC721: approved query for nonexistent token"); 127 | 128 | return _tokenApprovals[tokenId]; 129 | } 130 | 131 | /** 132 | * @dev See {IERC721-setApprovalForAll}. 133 | */ 134 | function setApprovalForAll(address operator, bool approved) public virtual override { 135 | require(operator != _msgSender(), "ERC721: approve to caller"); 136 | 137 | _operatorApprovals[_msgSender()][operator] = approved; 138 | emit ApprovalForAll(_msgSender(), operator, approved); 139 | } 140 | 141 | /** 142 | * @dev See {IERC721-isApprovedForAll}. 143 | */ 144 | function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { 145 | return _operatorApprovals[owner][operator]; 146 | } 147 | 148 | /** 149 | * @dev See {IERC721-transferFrom}. 150 | */ 151 | function transferFrom(address from, address to, uint256 tokenId) public virtual override { 152 | //solhint-disable-next-line max-line-length 153 | require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); 154 | 155 | _transfer(from, to, tokenId); 156 | } 157 | 158 | /** 159 | * @dev See {IERC721-safeTransferFrom}. 160 | */ 161 | function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { 162 | safeTransferFrom(from, to, tokenId, ""); 163 | } 164 | 165 | /** 166 | * @dev See {IERC721-safeTransferFrom}. 167 | */ 168 | function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { 169 | require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); 170 | _safeTransfer(from, to, tokenId, _data); 171 | } 172 | 173 | /** 174 | * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients 175 | * are aware of the ERC721 protocol to prevent tokens from being forever locked. 176 | * 177 | * `_data` is additional data, it has no specified format and it is sent in call to `to`. 178 | * 179 | * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. 180 | * implement alternative mechanisms to perform token transfer, such as signature-based. 181 | * 182 | * Requirements: 183 | * 184 | * - `from` cannot be the zero address. 185 | * - `to` cannot be the zero address. 186 | * - `tokenId` token must exist and be owned by `from`. 187 | * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. 188 | * 189 | * Emits a {Transfer} event. 190 | */ 191 | function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { 192 | _transfer(from, to, tokenId); 193 | require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); 194 | } 195 | 196 | /** 197 | * @dev Returns whether `tokenId` exists. 198 | * 199 | * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. 200 | * 201 | * Tokens start existing when they are minted (`_mint`), 202 | * and stop existing when they are burned (`_burn`). 203 | */ 204 | function _exists(uint256 tokenId) internal view virtual returns (bool) { 205 | return _owners[tokenId] != address(0); 206 | } 207 | 208 | /** 209 | * @dev Returns whether `spender` is allowed to manage `tokenId`. 210 | * 211 | * Requirements: 212 | * 213 | * - `tokenId` must exist. 214 | */ 215 | function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { 216 | require(_exists(tokenId), "ERC721: operator query for nonexistent token"); 217 | address owner = Canvas.ownerOf(tokenId); 218 | return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); 219 | } 220 | 221 | /** 222 | * @dev Safely mints `tokenId` and transfers it to `to`. 223 | * 224 | * Requirements: 225 | * 226 | * - `tokenId` must not exist. 227 | * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. 228 | * 229 | * Emits a {Transfer} event. 230 | */ 231 | function _safeMint(address to, uint256 tokenId) internal virtual { 232 | _safeMint(to, tokenId, ""); 233 | } 234 | 235 | /** 236 | * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is 237 | * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. 238 | */ 239 | function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { 240 | _mint(to, tokenId); 241 | require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); 242 | } 243 | 244 | /** 245 | * @dev Mints `tokenId` and transfers it to `to`. 246 | * 247 | * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible 248 | * 249 | * Requirements: 250 | * 251 | * - `tokenId` must not exist. 252 | * - `to` cannot be the zero address. 253 | * 254 | * Emits a {Transfer} event. 255 | */ 256 | function _mint(address to, uint256 tokenId) internal virtual { 257 | require(to != address(0), "ERC721: mint to the zero address"); 258 | require(!_exists(tokenId), "ERC721: token already minted"); 259 | 260 | _beforeTokenTransfer(address(0), to, tokenId); 261 | 262 | _balances[to] += 1; 263 | _canvas[tokenId] = Pixel(255, 255, 255, 10); 264 | _owners[tokenId] = to; 265 | 266 | emit Transfer(address(0), to, tokenId); 267 | } 268 | 269 | /** 270 | * @dev Destroys `tokenId`. 271 | * The approval is cleared when the token is burned. 272 | * 273 | * Requirements: 274 | * 275 | * - `tokenId` must exist. 276 | * 277 | * Emits a {Transfer} event. 278 | */ 279 | function _burn(uint256 tokenId) internal virtual { 280 | address owner = Canvas.ownerOf(tokenId); 281 | 282 | _beforeTokenTransfer(owner, address(0), tokenId); 283 | 284 | // Clear approvals 285 | _approve(address(0), tokenId); 286 | 287 | _balances[owner] -= 1; 288 | delete _owners[tokenId]; 289 | 290 | emit Transfer(owner, address(0), tokenId); 291 | } 292 | 293 | /** 294 | * @dev Transfers `tokenId` from `from` to `to`. 295 | * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. 296 | * 297 | * Requirements: 298 | * 299 | * - `to` cannot be the zero address. 300 | * - `tokenId` token must be owned by `from`. 301 | * 302 | * Emits a {Transfer} event. 303 | */ 304 | function _transfer(address from, address to, uint256 tokenId) internal virtual { 305 | require(Canvas.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); 306 | require(to != address(0), "ERC721: transfer to the zero address"); 307 | 308 | _beforeTokenTransfer(from, to, tokenId); 309 | 310 | // Clear approvals from the previous owner 311 | _approve(address(0), tokenId); 312 | 313 | _balances[from] -= 1; 314 | _balances[to] += 1; 315 | _owners[tokenId] = to; 316 | 317 | emit Transfer(from, to, tokenId); 318 | } 319 | 320 | /** 321 | * @dev Approve `to` to operate on `tokenId` 322 | * 323 | * Emits a {Approval} event. 324 | */ 325 | function _approve(address to, uint256 tokenId) internal virtual { 326 | _tokenApprovals[tokenId] = to; 327 | emit Approval(Canvas.ownerOf(tokenId), to, tokenId); 328 | } 329 | 330 | /** 331 | * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. 332 | * The call is not executed if the target address is not a contract. 333 | * 334 | * @param from address representing the previous owner of the given token ID 335 | * @param to target address that will receive the tokens 336 | * @param tokenId uint256 ID of the token to be transferred 337 | * @param _data bytes optional data to send along with the call 338 | * @return bool whether the call correctly returned the expected magic value 339 | */ 340 | function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) 341 | private returns (bool) 342 | { 343 | if (to.isContract()) { 344 | try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { 345 | return retval == IERC721Receiver(to).onERC721Received.selector; 346 | } catch (bytes memory reason) { 347 | if (reason.length == 0) { 348 | revert("ERC721: transfer to non ERC721Receiver implementer"); 349 | } else { 350 | // solhint-disable-next-line no-inline-assembly 351 | assembly { 352 | revert(add(32, reason), mload(reason)) 353 | } 354 | } 355 | } 356 | } else { 357 | return true; 358 | } 359 | } 360 | 361 | /** 362 | * @dev Hook that is called before any token transfer. This includes minting 363 | * and burning. 364 | * 365 | * Calling conditions: 366 | * 367 | * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be 368 | * transferred to `to`. 369 | * - When `from` is zero, `tokenId` will be minted for `to`. 370 | * - When `to` is zero, ``from``'s `tokenId` will be burned. 371 | * - `from` and `to` are never both zero. 372 | * 373 | * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. 374 | */ 375 | function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } 376 | 377 | function claim(address claimer, uint16 xAxis, uint16 yAxis) 378 | public virtual override 379 | returns (uint256) 380 | { 381 | uint256 tokenId = _mappingPositionToTokenId(xAxis, yAxis); 382 | if (_owners[tokenId] == address(0)) { 383 | _mint(claimer, tokenId); 384 | return tokenId; 385 | } else { 386 | return 0; 387 | } 388 | } 389 | 390 | function _overflowXAxis(uint16 xAxis_) private view returns (bool) { 391 | if (xAxis_ >= _width) { 392 | return true; 393 | } else { 394 | return false; 395 | } 396 | } 397 | 398 | function _overflowYAxis(uint16 yAxis_) private view returns (bool) { 399 | if (yAxis_ >= _height) { 400 | return true; 401 | } else { 402 | return false; 403 | } 404 | } 405 | 406 | function _validPixel(Pixel memory pixel_) private returns (bool) { 407 | return pixel_.A <= 100; 408 | } 409 | 410 | function _mappingPositionToTokenId(uint16 xAxis_, uint16 yAxis_) private view returns (uint256) { 411 | require(!_overflowXAxis(xAxis_), "X axis overflow"); 412 | require(!_overflowYAxis(yAxis_), "Y axis overflow"); 413 | return xAxis_ + yAxis_ * _width; 414 | } 415 | 416 | function setColor(uint16 xAxis_, uint16 yAxis_, uint8 r_, uint8 g_, uint8 b_, uint8 a_) public virtual override { 417 | uint256 tokenId = _mappingPositionToTokenId(xAxis_, yAxis_); 418 | _color(tokenId, r_, g_, b_, a_); 419 | emit Color(_msgSender(), xAxis_, yAxis_, r_, g_, b_, a_); 420 | } 421 | 422 | function _color(uint256 tokenId_, uint8 r_, uint8 g_, uint8 b_, uint8 a_) internal virtual { 423 | Pixel memory pixel = Pixel(r_, g_, b_, a_); 424 | require(_validPixel(pixel), "invalid rgba string"); 425 | _canvas[tokenId_] = Pixel(r_, g_, b_, a_); 426 | } 427 | 428 | function getColor(uint16 xAxis_, uint16 yAxis_) public view override returns (uint8, uint8, uint8, uint8) { 429 | uint256 tokenId = _mappingPositionToTokenId(xAxis_, yAxis_); 430 | Pixel memory color = _canvas[tokenId]; 431 | return (color.R, color.G, color.B, color.A); 432 | } 433 | 434 | // function lock(uint16 xAxis_, uint16 yAxis_) public { 435 | // uint256 tokenId = _mappingPositionToTokenId(xAxis_, yAxis_); 436 | // require(_exists(tokenId), "ERC721: lock nonexistent token"); 437 | 438 | // address owner = Canvas.ownerOf(tokenId); 439 | 440 | // require(_msgSender() == owner , "need owner to lock"); 441 | // _lock(xAxis_, yAxis_); 442 | // } 443 | 444 | // function _lock(uint16 xAxis_, uint16 yAxis_) internal virtual { 445 | 446 | // } 447 | } -------------------------------------------------------------------------------- /projects/dAes/contest1/src/components/show.js: -------------------------------------------------------------------------------- 1 | 2 | import './show.css'; 3 | import InputColor from 'react-input-color'; 4 | import {CountdownCircleTimer } from 'react-countdown-circle-timer' 5 | import React, { useState ,useContext } from 'react'; 6 | import {Web3Context} from "../App.js"; 7 | 8 | //import Claim from './artifacts/contracts/Greeter.sol/Greeter.json' 9 | const v =['#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#1bb86b', '#50514d', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#a2a49f', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#a2a49f', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#a2a49f', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#ffffff', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#facDC7', '#facDC7', '#facDC7', '#ffffff', '#ffffff', '#50514d', '#74eefd', '#74eefd', '#74eefd', '#facDC7', '#facDC7', '#facDC7', '#ffffff', '#ffffff', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#a2a49f', '#ffffff', '#ffffff', '#facDC7', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#74eefd', '#74eefd', '#74eefd', '#ffffff', '#facDC7', '#ffffff', '#ffffff', '#a2a49f', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#50514d', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#74eefd', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b', '#1bb86b'] 10 | const v1=[] 11 | const shuffleIndex = [...Array(720).keys()].sort(function() { 12 | return .5 - Math.random(); 13 | }) 14 | 15 | /* 用户染色 setcolor 函数然后就染色 getcolor */ 16 | 17 | /*claim 获取方框所有权*/ 18 | 19 | /* 应该是是像充值购买一样的东西吧,我充值购买代币然后可以花钱控制一个色块多久不变色 话题停留多久吧 这样才会好写一点*/ 20 | /*最后要截图,要重新开始,页面要刷新,色块颜色变化,*/ 21 | /* 把之前方块之前的颜色去掉 不按确定就不正式修改*/ 22 | function Board(props){ 23 | 24 | const lockTime=10000 25 | const rows = props.rows 26 | const cols = props.cols 27 | const [visible,setVisible] = useState(false) 28 | const [colors, setColors] = useState(Array(rows*cols).fill('#FFFFFF')) 29 | //const [colors, setColors] = useState(v) 30 | const [choosei,setChoosei]=useState(0) 31 | const [chooser,setChooser]=useState(0) 32 | const [choosec,setChoosec]=useState(0) 33 | const [org,setOrg]=useState('#FFFFFF') 34 | const [lock,setLock]=useState(Array(rows*cols).fill(false)) 35 | //var show_board=[] 36 | /* function painting(){ 37 | [...Array(720).keys()].forEach((i)=>{setTimeout(()=>{const colors1=colors.slice(); 38 | //console.log('第几个',chooser*cols+choosec,chooser,choosec) 39 | colors1[shuffleIndex[i]] = v[shuffleIndex[i]]; 40 | setColors(colors1);setColors()},1000*i)}) 41 | 42 | }*/ 43 | 44 | function lockUp(index){ 45 | const lock1=lock.slice(); 46 | 47 | lock1[index] = !lock[index] 48 | setLock(lock1) 49 | setTimeout(()=>{ 50 | const lock1=lock.slice() 51 | lock1[index] = !lock[index] 52 | },lockTime) 53 | 54 | } 55 | function changeColor(color){ 56 | var c=false 57 | if (!lock[chooser*cols+choosec]){ 58 | const colors1=colors.slice(); 59 | //console.log('第几个',chooser*cols+choosec,chooser,choosec) 60 | colors1[chooser*cols+choosec] = color; 61 | setColors(colors1); 62 | //console.log('changecolor',colors) 63 | }else{ 64 | alert('The square is locked and cannot be changed in color') 65 | return 'close' 66 | } 67 | 68 | } 69 | 70 | function restart(){ 71 | /*保存现在数据发送*/ 72 | setColors(Array(rows*cols).fill('#FFFFFF')) 73 | setLock(Array(rows*cols).fill(false)) 74 | } 75 | 76 | function handleClick(r,j){ 77 | 78 | console.log('点击',r,j,visible) 79 | 80 | if (!visible){ 81 | console.log('点击',r,j,visible) 82 | setOrg(colors[chooser*cols+choosec]) 83 | setVisible(!visible) 84 | setChooser(r) 85 | setChoosec(j) 86 | setChoosei(r*cols+j) 87 | } 88 | 89 | 90 | } 91 | function close(){ 92 | console.log(11); 93 | if (visible){ 94 | setVisible(!visible)} 95 | } 96 | function BoardRow(props){ 97 | const r=props.r 98 | const cols=props.cols 99 | const colors=props.colors 100 | const handleClick = props.handleClick 101 | const choosei =props.choosei 102 | //console.log(handleClick) 103 | 104 | const listItem= [...Array(cols).keys()].map((index,j)=>{return {handleClick(r,j)}}>}) 105 | 106 | return ( 107 |
108 | {listItem} 109 |
110 | ) 111 | } 112 | /*for (var r=0 ;r{}) 120 | const show_board= [...Array(rows).keys()].map((index,r)=>{ return }) 121 | // console.log(show_board) 122 | // ) 123 | 124 | 125 | // } 126 | const renderTime = ({ remainingTime }) => { 127 | if (remainingTime === 0) { 128 | return
A new round will start
; 129 | } 130 | 131 | return ( 132 |
133 |
Remaining
134 |
{remainingTime}
135 |
seconds
136 |
137 | ); 138 | }; 139 | 140 | return ( 141 |
142 | 143 |
144 |
145 | {show_board} 146 |
147 |
148 |
149 | 150 | { restart();return [true, 1000]}} 155 | onComplete={() =>{setColors(v);return [true, 1000]}} 156 | > 157 | {renderTime} 158 | 159 |
160 | 161 | 162 | 163 | 164 | 165 | 166 |
167 | 168 | 169 | ) 170 | } 171 | 172 | 173 | 174 | 175 | function Box(props){ 176 | //console.log('--------------',props.color) 177 | //console.log(props.id ,'box key') 178 | return ( 179 |
{props.onClick()}}>
180 | ) 181 | } 182 | 183 | function ChoosePanel(props){ 184 | const [params,setParams]=useState([]) 185 | const visible= props.visible 186 | const changeColor=props.changeColor 187 | const { web3 } = useContext(Web3Context); 188 | const {r,c,cols,close,org,lockUp,colors}= props.index 189 | window.test = web3 190 | const contractAddress = '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512' 191 | //实例化合约 192 | const abi = require("../abi").default 193 | window.myContract = new web3.eth.Contract(abi, contractAddress) 194 | console.log(web3) 195 | // web3.eth.getAccounts((_, accounts) => { 196 | // window.defaultAccount = accounts[0]; 197 | // console.log(window.defaultAccount); 198 | // }) 199 | 200 | // window.defaultAccount = web3.eth.accounts[0].toLowerCase() 201 | console.log(window.defaultAccount ) 202 | const purchase = async () => { 203 | const account=await web3.eth.getAccounts() 204 | console.log(account) 205 | window.myContract.methods.claim(account[0],c,r ).send({from:account[0]}) 206 | .on('transactionHash',(transactionHash)=>{ 207 | console.log('transactionHash',transactionHash) 208 | }) 209 | .on('confirmation',(confirmationNumber,receipt)=>{ 210 | console.log({ confirmationNumber: confirmationNumber, receipt: receipt }); 211 | lockUp(r*cols+c); 212 | close() 213 | 214 | }) 215 | .on('receipt',(receipt)=>{ 216 | console.log({ receipt: receipt }) 217 | }) 218 | .on('error',(error,receipt)=>{ 219 | console.log({ error: error, receipt: receipt }); 220 | changeColor(org); 221 | close() 222 | }) 223 | } 224 | const sendColor = async () => { 225 | const account=await web3.eth.getAccounts() 226 | console.log(account) 227 | window.myContract.methods.setColor(c,r, ...params ).send({from:account[0]}) 228 | .on('transactionHash',(transactionHash)=>{ 229 | console.log('transactionHash',transactionHash) 230 | }) 231 | .on('confirmation',(confirmationNumber,receipt)=>{ 232 | console.log({ confirmationNumber: confirmationNumber, receipt: receipt }); 233 | 234 | }) 235 | .on('receipt',(receipt)=>{ 236 | console.log({ receipt: receipt }) 237 | }) 238 | .on('error',(error,receipt)=>{ 239 | console.log({ error: error, receipt: receipt }); 240 | changeColor(org); 241 | close() 242 | }) 243 | } 244 | //console.log('index',props.index,r) 245 | //const originalColor 246 | const cc=colors.slice() 247 | const originalColor = cc[r*cols+c] 248 | 249 | function handelChange(color){ 250 | // console.log(111111,color) 251 | // console.log('zuoseqi',color) 252 | setParams([color.r,color.g,color.b,color.a]) 253 | 254 | console.log(color,'yanssssss') 255 | var signal=changeColor(color.hex) 256 | if (signal){ 257 | close()} 258 | } 259 | //console.log(org,'颜色') 260 | 261 | return ( 262 | visible &&
263 |
264 |
Choose color:
265 | 270 |
271 |
272 |
{ sendColor();close()}}>Confirm
273 |
{console.log('gggg',org);changeColor(org);close()}}>Cancle
274 |
275 | 276 |
{purchase()}}>Purchase
277 |
278 | ) 279 | } 280 | 281 | export default Board 282 | 283 | 284 | --------------------------------------------------------------------------------