├── 6-Todolist ├── react-frontend │ ├── .gitignore │ ├── .babelrc │ ├── dist │ │ └── index.html │ ├── README.md │ ├── webpack.config.js │ ├── package.json │ └── src │ │ └── index.jsx ├── Readme.md └── contract │ └── todo.cpp ├── 7-EOSblog ├── react-frontend │ ├── src │ │ ├── Posts │ │ │ ├── Post │ │ │ │ ├── Post.css │ │ │ │ └── Post.js │ │ │ ├── Posts.js │ │ │ └── EditPost │ │ │ │ └── EditPost.js │ │ ├── index.css │ │ ├── index.js │ │ ├── App.test.js │ │ ├── App.css │ │ ├── lib │ │ │ └── eos-client.js │ │ ├── CreatePost │ │ │ └── CreatePost.js │ │ ├── App.js │ │ └── registerServiceWorker.js │ ├── public │ │ ├── favicon.ico │ │ ├── manifest.json │ │ └── index.html │ ├── config-overrides.js │ ├── .env │ ├── .gitignore │ └── package.json ├── contract │ ├── blog.hpp │ └── blog.cpp └── README.md ├── 1-HelloWorld ├── hello │ ├── hello.wasm │ ├── hello.cpp │ ├── .vscode │ │ └── c_cpp_properties.json │ └── hello.abi ├── cleosd.md └── Readme.md ├── 8-Ballot ├── contract │ ├── ballot.wasm │ ├── ballot.abi │ └── ballot.cpp ├── ballot-front │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── createvote.html │ ├── addproposal.html │ ├── index.html │ └── detail.html └── README.md ├── 3-Wallet ├── eosjs │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── balance.html │ └── index.html ├── scatter │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── balance.html │ └── index.html └── Readme.md ├── 4-Browser ├── front │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── index.html │ └── account.html └── Readme.md ├── 5-TicTacToe ├── front │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── create.html │ ├── index.html │ └── play.html ├── README.md └── contract │ ├── tic_tac_toe.abi │ ├── tic_tac_toe.hpp │ └── tic_tac_toe.cpp ├── README.md ├── 2-Token ├── eosio.token │ ├── CMakeLists.txt │ ├── eosio.token.abi │ ├── eosio.token.hpp │ └── eosio.token.cpp └── Readme.md └── page.html /6-Todolist/react-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /6-Todolist/react-frontend/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react", "stage-2"] 3 | } -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/src/Posts/Post/Post.css: -------------------------------------------------------------------------------- 1 | .Post { 2 | margin: 15px; 3 | } 4 | -------------------------------------------------------------------------------- /1-HelloWorld/hello/hello.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/1-HelloWorld/hello/hello.wasm -------------------------------------------------------------------------------- /8-Ballot/contract/ballot.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/8-Ballot/contract/ballot.wasm -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/7-EOSblog/react-frontend/public/favicon.ico -------------------------------------------------------------------------------- /7-EOSblog/contract/blog.hpp: -------------------------------------------------------------------------------- 1 | // Required generic eosio library provides print, type, math etc 2 | #include 3 | #include -------------------------------------------------------------------------------- /3-Wallet/eosjs/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/3-Wallet/eosjs/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /3-Wallet/eosjs/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/3-Wallet/eosjs/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /3-Wallet/eosjs/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/3-Wallet/eosjs/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /3-Wallet/scatter/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/3-Wallet/scatter/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /3-Wallet/scatter/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/3-Wallet/scatter/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /4-Browser/front/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/4-Browser/front/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /4-Browser/front/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/4-Browser/front/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /4-Browser/front/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/4-Browser/front/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /3-Wallet/scatter/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/3-Wallet/scatter/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /5-TicTacToe/front/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/5-TicTacToe/front/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /5-TicTacToe/front/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/5-TicTacToe/front/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /5-TicTacToe/front/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/5-TicTacToe/front/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /8-Ballot/ballot-front/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/8-Ballot/ballot-front/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /8-Ballot/ballot-front/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/8-Ballot/ballot-front/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /6-Todolist/Readme.md: -------------------------------------------------------------------------------- 1 | # Todolist 2 | 3 | 查看代码 4 | 5 | https://github.com/eosasia/eos-todo 6 | 7 | ## Start the react app 8 | ```bash 9 | cd frontend 10 | npm start 11 | ``` -------------------------------------------------------------------------------- /8-Ballot/ballot-front/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericfish/EOS-Dev-Book/HEAD/8-Ballot/ballot-front/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 25px 50px 0px 50px; 4 | font-family: 'Roboto', sans-serif; 5 | color: #4a4a4a; 6 | background-color: #f8f7f7 !important; 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EOS Dev Book Repo 2 | 3 | ## 1-HelloWorld 4 | 5 | ## 2-Token 6 | 7 | ## 3-Wallet 8 | 9 | ## 4-Browser 10 | 11 | ## 5-TicTacToe 12 | 13 | ## 6-Todolist 14 | 15 | ## 7-EOSblog 16 | 17 | ## 8-Ballot 18 | -------------------------------------------------------------------------------- /6-Todolist/react-frontend/dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EOS Ping 5 | 6 | 7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/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 registerServiceWorker from './registerServiceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | registerServiceWorker(); 9 | -------------------------------------------------------------------------------- /2-Token/eosio.token/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB ABI_FILES "*.abi") 2 | configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) 3 | 4 | add_wast_executable(TARGET eosio.token 5 | INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" 6 | LIBRARIES libc++ libc eosiolib 7 | DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} 8 | ) 9 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /6-Todolist/react-frontend/README.md: -------------------------------------------------------------------------------- 1 | # Front-end for EOS TODO 2 | 3 | ## Getting started 4 | 5 | - Get the code: `git clone repo && cd repo/frontend` 6 | - Download/install dependencies: `npm install` 7 | - Modify `const config` in the `src/index.jsx` file. 8 | - Start it up: `npm start`, then open `http://localhost:8080/` to try it out. 9 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/config-overrides.js: -------------------------------------------------------------------------------- 1 | const { injectBabelPlugin } = require('react-app-rewired'); 2 | 3 | module.exports = function override(config, env) { 4 | config = injectBabelPlugin( 5 | ['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }], 6 | config 7 | ); 8 | return config; 9 | }; 10 | -------------------------------------------------------------------------------- /1-HelloWorld/cleosd.md: -------------------------------------------------------------------------------- 1 | # 常用 cleos 命令 2 | 3 | cleos push action hello hi '{"name":"bob"}' 4 | 5 | cleos push action eosio.token transfer '{"from":"eosjustaward","to":"justtest2222","quantity":"1000.0000 EOS","memo":""}' -p eosaccount 6 | 7 | cleos get account bob 8 | 9 | cleos set contract hello ~/projects/eos/lesson/examples/build/hello 10 | 11 | -------------------------------------------------------------------------------- /5-TicTacToe/README.md: -------------------------------------------------------------------------------- 1 | ## 测试 2 | 3 | 启动两个独立的 Chrome 进程,并配置Kylin测试账户 4 | 5 | /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/Users/[MacUserName]/temp/Google/Chrome/SystemA/dev" 6 | 7 | 重新安装 Scatter 插件和 SwitchSharp 插件 8 | 9 | ## 测试地址: 10 | 11 | Kylin 测试网合约账户:erictest1113 12 | 13 | https://ericfish.github.io/eostic/index.html 14 | 15 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/.env: -------------------------------------------------------------------------------- 1 | REACT_APP_EOS_ENV= 2 | REACT_APP_EOS_ACCOUNT= 3 | REACT_APP_EOS_PRIVATE_KEY= 4 | REACT_APP_EOS_CHAIN_ID= 5 | 6 | REACT_APP_EOS_LOCAL_CONTRACT_ACCOUNT=blog 7 | REACT_APP_EOS_TEST_CONTRACT_ACCOUNT=testblogeos 8 | 9 | REACT_APP_EOS_LOCAL_HTTP_URL=http://localhost:8888 10 | REACT_APP_EOS_TEST_HTTP_URL=http://jungle.cryptolions.io:38888 11 | -------------------------------------------------------------------------------- /1-HelloWorld/hello/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace eosio; 5 | 6 | class hello : public contract { 7 | public: 8 | using contract::contract; 9 | 10 | /// @abi action 11 | void hi( account_name user ) { 12 | print( "Hello, ", name{user} ); 13 | } 14 | }; 15 | EOSIO_ABI( hello, (hi)) -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/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 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/src/Posts/Posts.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Post from './Post/Post'; 4 | 5 | const Posts = ({ posts, deletePost, editPost, likePost }) => { 6 | return posts.map((post, index) => { 7 | return ( 8 | 15 | ); 16 | }); 17 | }; 18 | 19 | export default Posts; 20 | -------------------------------------------------------------------------------- /6-Todolist/react-frontend/webpack.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | 3 | module.exports = { 4 | entry: ['react-hot-loader/patch', './src/index.jsx'], 5 | module: { 6 | rules: [{ test: /\.(js|jsx)$/, exclude: /node_modules/, use: ['babel-loader'] }] 7 | }, 8 | resolve: { extensions: ['*', '.js', '.jsx'] }, 9 | output: { path: __dirname + '/dist', publicPath: '/', filename: 'bundle.js' }, 10 | plugins: [ new webpack.HotModuleReplacementPlugin() ], 11 | devServer: { contentBase: './dist', hot: true } 12 | }; 13 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 80px; 8 | } 9 | 10 | .App-header { 11 | background-color: #222; 12 | height: 150px; 13 | padding: 20px; 14 | color: white; 15 | } 16 | 17 | .App-title { 18 | font-size: 1.5em; 19 | } 20 | 21 | .App-intro { 22 | font-size: large; 23 | } 24 | 25 | @keyframes App-logo-spin { 26 | from { transform: rotate(0deg); } 27 | to { transform: rotate(360deg); } 28 | } 29 | -------------------------------------------------------------------------------- /1-HelloWorld/hello/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "macFrameworkPath": [ 10 | "/System/Library/Frameworks", 11 | "/Library/Frameworks" 12 | ], 13 | "compilerPath": "/usr/bin/clang", 14 | "cStandard": "c11", 15 | "cppStandard": "c++17", 16 | "intelliSenseMode": "clang-x64" 17 | } 18 | ], 19 | "version": 4 20 | } -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "antd": "^3.5.4", 7 | "eosjs": "^15.0.3", 8 | "react": "^16.4.0", 9 | "react-dom": "^16.4.0", 10 | "react-scripts": "1.1.4" 11 | }, 12 | "scripts": { 13 | "start": "react-app-rewired start", 14 | "build": "react-app-rewired build", 15 | "test": "react-app-rewired test --env=jsdom", 16 | "eject": "react-scripts eject" 17 | }, 18 | "devDependencies": { 19 | "babel-plugin-import": "^1.7.0", 20 | "react-app-rewired": "^1.5.2" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /1-HelloWorld/hello/hello.abi: -------------------------------------------------------------------------------- 1 | { 2 | "____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-10-24T06:16:16", 3 | "version": "eosio::abi/1.0", 4 | "types": [], 5 | "structs": [{ 6 | "name": "hi", 7 | "base": "", 8 | "fields": [{ 9 | "name": "user", 10 | "type": "name" 11 | } 12 | ] 13 | } 14 | ], 15 | "actions": [{ 16 | "name": "hi", 17 | "type": "hi", 18 | "ricardian_contract": "" 19 | } 20 | ], 21 | "tables": [], 22 | "ricardian_clauses": [], 23 | "error_messages": [], 24 | "abi_extensions": [], 25 | "variants": [] 26 | } -------------------------------------------------------------------------------- /3-Wallet/Readme.md: -------------------------------------------------------------------------------- 1 | # Wallet 2 | 3 | ### eosjs 版本 4 | 5 | /eosjs 6 | 7 | eosjs 文档 8 | 9 | https://github.com/eoshackathon/eos_dapp_development_cn/blob/master/docs/eosjs_manual.md 10 | 11 | 注1:eosjs 版本需修改 js 中的本地测试环境 12 | 13 | 注2:书中提到的 eosjs2 库已经和 eosjs 库合并 14 | 15 | ### scatter 版本 16 | 17 | /scatter 18 | 19 | 测试地址: 20 | https://ericfish.github.io/eoswallet/ 21 | 22 | scatter 文档 23 | 24 | https://get-scatter.com/docs/getting-started 25 | 26 | 注:Scatter 版本不能在本地运行,需要部署到服务器 27 | 28 | ### 其它参考 29 | 30 | #### Scatter API 示例 31 | 32 | https://github.com/MediShares/scatter-eos-sample 33 | 34 | #### 麦子钱包 mds-eosjs 示例 35 | 36 | https://github.com/MediShares/mds-eosjs -------------------------------------------------------------------------------- /6-Todolist/react-frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eos-todo", 3 | "version": "1.0.0", 4 | "description": "Manage your TODOs with EOS!", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "webpack-dev-server --config webpack.config.js --mode development", 8 | "test": "echo \"No test specified\" && exit 0" 9 | }, 10 | "keywords": [ 11 | "react", 12 | "eos", 13 | "eos.js" 14 | ], 15 | "author": "Tyler Diaz", 16 | "license": "ISC", 17 | "devDependencies": { 18 | "babel-core": "^6.23.1", 19 | "babel-loader": "^7.1.2", 20 | "babel-preset-react": "^6.23.0", 21 | "babel-preset-stage-2": "^6.22.0", 22 | "react-hot-loader": "^3.1.3", 23 | "webpack": "^4.6.0", 24 | "webpack-cli": "^2.0.10", 25 | "webpack-dev-server": "^3.1.0" 26 | }, 27 | "dependencies": { 28 | "babel-preset-env": "^1.6.1", 29 | "eosjs": "^10.0.0", 30 | "immutability-helper": "^2.7.0", 31 | "react": "^16.3.2", 32 | "react-addons-update": "^15.6.2", 33 | "react-dom": "^16.2.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /4-Browser/Readme.md: -------------------------------------------------------------------------------- 1 | # Browser 2 | 3 | ## get_info 4 | 获取节点相关的最新信息 5 | http://api.eosbeijing.one/v1/chain/get_info 6 | 7 | ## get_block 8 | 获取一个块的信息 9 | http://api.eosbeijing.one/v1/chain/get_block 10 | 11 | ## get_account 12 | 获取账户的信息 13 | http://api.eosbeijing.one/v1/chain/get_account 14 | 15 | ## get_currency_balance 16 | 获取账户的Token余额 17 | http://api.eosbeijing.one/v1/chain/get_currency_balance 18 | 19 | ## get_account history 20 | 获取账户的转账记录 21 | 22 | 注:History 插件太占资源,一般不开放 23 | http://api.eosbeijing.one/v1/history/get_account 24 | 25 | 所以使用 EOS Park 的接口(or 需要使用 mongodb 同步区块数据) 26 | https://developer.eospark.com/api-doc/account/#get-account-transactions 27 | 28 | ## get_transaction history 29 | 获取转账记录详情 30 | 31 | 注:History 插件太占资源,一般不开放 32 | http://api.eosbeijing.one/v1/history/get_transaction 33 | 34 | 所以使用 EOS Park 的接口(or 需要使用 mongodb 同步区块数据) 35 | https://developer.eospark.com/api-doc/transaction/#get-transaction 36 | 37 | ## EOS Park API 38 | 39 | https://developer.eospark.com/api-doc/ 40 | 41 | ## 测试地址: 42 | 43 | https://ericfish.github.io/eosbrowser/ 44 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/src/lib/eos-client.js: -------------------------------------------------------------------------------- 1 | import Eos from 'eosjs'; 2 | 3 | const EOS_CONFIG = { 4 | chainId: process.env.REACT_APP_EOS_CHAIN_ID, 5 | keyProvider: [process.env.REACT_APP_EOS_PRIVATE_KEY], 6 | broadcast: true, 7 | sign: true 8 | }; 9 | 10 | 11 | export default class EOSClient { 12 | constructor(contractName, contractSender) { 13 | this.contractName = contractName; 14 | this.contractSender = contractSender; 15 | 16 | this.eos = Eos(EOS_CONFIG); 17 | } 18 | 19 | getTableRows = table => { 20 | return this.eos.getTableRows(true, this.contractName, this.contractSender, table); 21 | }; 22 | 23 | transaction = (action, data) => { 24 | return this.eos.transaction({ 25 | actions: [ 26 | { 27 | account: this.contractName, 28 | name: action, 29 | authorization: [ 30 | { 31 | actor: actor, 32 | permission: 'active' 33 | } 34 | ], 35 | data: { 36 | ...data 37 | } 38 | } 39 | ] 40 | }); 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /2-Token/Readme.md: -------------------------------------------------------------------------------- 1 | # Token 部署到 eosio.token 账户 2 | 3 | cleos create account eosio eosio.token EOS5TGs5dGK4BMC6Qwc2mbWzp1wn1pjrY3D1JFeybb22vRJ1qeLGg 4 | 5 | cd /eos/contracts/eosio.token 6 | 7 | eosiocpp -o eosio.token.wasm eosio.token.cpp 8 | 9 | cd .. 10 | cleos set contract eosio.token eosio.token --abi eosio.token.abi -p eosio.token@active 11 | 12 | cleos push action eosio.token create '[ "eosio", "1000000000.0000 SYS"]' -p eosio.token@active 13 | 14 | cleos push action eosio.token issue '[ "bob", "100.0000 SYS", "memo" ]' -p eosio@active 15 | 16 | cleos push action eosio.token transfer '[ "bob", "alice", "25.0000 SYS", "m" ]' -p bob@active 17 | 18 | cleos get currency balance eosio.token bob SYS 19 | cleos get currency balance eosio.token alice SYS 20 | 21 | # Token 部署到 SelfToken 账户 22 | 23 | cleos create account eosio selftoken EOS5TGs5dGK4BMC6Qwc2mbWzp1wn1pjrY3D1JFeybb22vRJ1qeLGg 24 | cleos create account eosio selftoken2 EOS5TGs5dGK4BMC6Qwc2mbWzp1wn1pjrY3D1JFeybb22vRJ1qeLGg 25 | cleos create account eosio selftoken3 EOS5TGs5dGK4BMC6Qwc2mbWzp1wn1pjrY3D1JFeybb22vRJ1qeLGg 26 | 27 | cd /eos/contracts/eosio.token 28 | 29 | eosiocpp -o eosio.token.wasm eosio.token.cpp 30 | 31 | cd .. 32 | cleos set contract selftoken eosio.token --abi eosio.token.abi -p selftoken@active 33 | 34 | cleos push action selftoken create '[ "selftoken2", "1000000000.0000 SYS"]' -p selftoken@active 35 | 36 | cleos push action selftoken issue '[ "selftoken2", "100.0000 SYS", "memo" ]' -p selftoken2@active 37 | 38 | cleos get currency balance selftoken selftoken2 SYS 39 | 40 | cleos push action selftoken transfer '[ "selftoken2", "selftoken3", "35.0000 SYS", "m" ]' -p selftoken2@active 41 | 42 | cleos get currency balance selftoken selftoken3 SYS 43 | 44 | -------------------------------------------------------------------------------- /6-Todolist/contract/todo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class todo_contract : public eosio::contract { 5 | public: 6 | todo_contract(account_name self) 7 | :eosio::contract(self), 8 | todos(_self, _self) 9 | {} 10 | 11 | // @abi action 12 | void create(account_name author, const uint32_t id, const std::string& description) { 13 | todos.emplace(author, [&](auto& new_todo) { 14 | new_todo.id = id; 15 | new_todo.description = description; 16 | new_todo.completed = 0; 17 | }); 18 | 19 | eosio::print("todo#", id, " created"); 20 | } 21 | 22 | // @abi action 23 | void destroy(account_name author, const uint32_t id) { 24 | auto todo_lookup = todos.find(id); 25 | todos.erase(todo_lookup); 26 | 27 | eosio::print("todo#", id, " destroyed"); 28 | } 29 | 30 | // @abi action 31 | void complete(account_name author, const uint32_t id) { 32 | auto todo_lookup = todos.find(id); 33 | eosio_assert(todo_lookup != todos.end(), "Todo does not exist"); 34 | 35 | todos.modify(todo_lookup, author, [&](auto& modifiable_todo) { 36 | modifiable_todo.completed = 1; 37 | }); 38 | 39 | eosio::print("todo#", id, " marked as complete"); 40 | } 41 | 42 | private: 43 | // @abi table todos i64 44 | struct todo { 45 | uint64_t id; 46 | std::string description; 47 | uint64_t completed; 48 | 49 | uint64_t primary_key() const { return id; } 50 | EOSLIB_SERIALIZE(todo, (id)(description)(completed)) 51 | }; 52 | 53 | typedef eosio::multi_index todo_table; 54 | todo_table todos; 55 | }; 56 | 57 | EOSIO_ABI(todo_contract, (create)(complete)(destroy)) 58 | -------------------------------------------------------------------------------- /8-Ballot/README.md: -------------------------------------------------------------------------------- 1 | # EOS 投票工具说明 2 | 3 | ## 合约开发步骤 4 | 5 | 1 基础框架 6 | 7 | include 8 | 9 | namespace 10 | 11 | class 继承 / public / private 12 | 13 | 2 数据结构 14 | 15 | 定义类型和 multi-index 16 | 17 | 注:如果有 hpp,struct 放在 hpp 中更好 18 | 19 | 3 构造函数 20 | 21 | 4 函数 22 | 23 | 权限检查: 24 | require_auth (_self); // 合约创建者才有权限 25 | require_auth (account); // 调用该action的account,和传入的account需要一致 26 | 27 | 5 ABI 28 | 29 | ## 合约部署和测试 30 | 31 | 1 创建和配置 Scatter 插件中的合约测试账号 32 | 33 | 2 https://dev4eos.com/#/ 编译并部署合约 34 | 35 | 选择 ballot.cpp 为 Main 36 | 37 | 检查部署账户有足够的内存 38 | 39 | 如果部署失败,试下浏览器挂梯子 40 | 41 | 3 https://kylin.bloks.io 对合约的 Action 进行测试并查看 Table 数据 42 | 43 | ### cleos 部署和测试命令 44 | 45 | eosiocpp -g ballot.abi ballot.cpp 46 | 47 | eosiocpp -o ballot.wast ballot.cpp 48 | 49 | cleos create account eosio ballot EOS5TGs5dGK4BMC6Qwc2mbWzp1wn1pjrY3D1JFeybb22vRJ1qeLGg 50 | 51 | cd .. 52 | cleos set contract ballot ballot 53 | 54 | cleos get table ballot ballot vote 55 | cleos get table ballot ballot proposal 56 | cleos get table ballot ballot ppslvoter 57 | 58 | cleos push action ballot addvote '["bob","中午吃什么?"]' -p bob@active 59 | 60 | cleos push action ballot addproposal '["bob",0,"时差七小时"]' -p bob@active 61 | cleos push action ballot addproposal '["bob",0,"汉堡王"]' -p bob@active 62 | 63 | cleos push action ballot startvote '["bob",0]' -p bob@active 64 | 65 | cleos push action ballot voteproposal '["bob",0]' -p bob@active 66 | 67 | cleos push action ballot delvoteppsl '["hello",0]' -p hello@active 68 | 69 | cleos push action ballot winproposal '["bob",0]' -p bob@active 70 | 71 | ## 前端开发步骤 72 | 73 | 1 设计界面原型 74 | 75 | 2 完成基础登录登出模块配置 76 | 77 | 注:测试网与主网交叉登录时,需要清理Scatter账户缓存,否则会导致账号登录失败 78 | 79 | 3 绑定 Table 数据 80 | 81 | 注:multi-index 索引可以对索引的列做条件过滤 82 | 83 | 4 业务逻辑关联 Action 84 | 85 | ## 测试地址: 86 | 87 | Kylin 测试网合约账户:erictest1112 88 | 89 | https://ericfish.github.io/eosvote/ 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 23 | 25 | 26 | BlogEOS 27 | 28 | 29 | 30 | 33 |
34 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /2-Token/eosio.token/eosio.token.abi: -------------------------------------------------------------------------------- 1 | { 2 | "version": "eosio::abi/1.0", 3 | "types": [{ 4 | "new_type_name": "account_name", 5 | "type": "name" 6 | }], 7 | "structs": [{ 8 | "name": "transfer", 9 | "base": "", 10 | "fields": [ 11 | {"name":"from", "type":"account_name"}, 12 | {"name":"to", "type":"account_name"}, 13 | {"name":"quantity", "type":"asset"}, 14 | {"name":"memo", "type":"string"} 15 | ] 16 | },{ 17 | "name": "create", 18 | "base": "", 19 | "fields": [ 20 | {"name":"issuer", "type":"account_name"}, 21 | {"name":"maximum_supply", "type":"asset"} 22 | ] 23 | },{ 24 | "name": "issue", 25 | "base": "", 26 | "fields": [ 27 | {"name":"to", "type":"account_name"}, 28 | {"name":"quantity", "type":"asset"}, 29 | {"name":"memo", "type":"string"} 30 | ] 31 | },{ 32 | "name": "account", 33 | "base": "", 34 | "fields": [ 35 | {"name":"balance", "type":"asset"} 36 | ] 37 | },{ 38 | "name": "currency_stats", 39 | "base": "", 40 | "fields": [ 41 | {"name":"supply", "type":"asset"}, 42 | {"name":"max_supply", "type":"asset"}, 43 | {"name":"issuer", "type":"account_name"} 44 | ] 45 | } 46 | ], 47 | "actions": [{ 48 | "name": "transfer", 49 | "type": "transfer", 50 | "ricardian_contract": "" 51 | },{ 52 | "name": "issue", 53 | "type": "issue", 54 | "ricardian_contract": "" 55 | }, { 56 | "name": "create", 57 | "type": "create", 58 | "ricardian_contract": "" 59 | } 60 | 61 | ], 62 | "tables": [{ 63 | "name": "accounts", 64 | "type": "account", 65 | "index_type": "i64", 66 | "key_names" : ["currency"], 67 | "key_types" : ["uint64"] 68 | },{ 69 | "name": "stat", 70 | "type": "currency_stats", 71 | "index_type": "i64", 72 | "key_names" : ["currency"], 73 | "key_types" : ["uint64"] 74 | } 75 | ], 76 | "ricardian_clauses": [], 77 | "abi_extensions": [] 78 | } 79 | -------------------------------------------------------------------------------- /7-EOSblog/react-frontend/src/CreatePost/CreatePost.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Form, Icon, Input, Button } from 'antd'; 3 | const FormItem = Form.Item; 4 | const { TextArea } = Input; 5 | 6 | class CreatePost extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.state = { 10 | title: '', 11 | content: '', 12 | tag: '' 13 | }; 14 | } 15 | 16 | handleOnChange = e => { 17 | this.setState({ [e.target.name]: e.target.value }); 18 | }; 19 | 20 | createPost = e => { 21 | e.preventDefault(); 22 | this.props.createPost({ ...this.state, likes: 0 }); 23 | this.setState({ 24 | title: '', 25 | content: '', 26 | tag: '' 27 | }); 28 | }; 29 | 30 | render() { 31 | return ( 32 |
33 |
34 |
35 |
36 | 37 | } 42 | placeholder="Title" 43 | /> 44 | 45 | 46 |