Name Notes Examples
fixed array: Array the contains a single type of element. length is fixed. int —> [1,2,3]
dynamic array: Array the contains a single type of element. length can change over time. int —>[1,2,3]
mapping: Collection of key value pairs. mapping(string => int)
struct: Collection of key value pairs that can have different types
msg.data: ‘Data’ field from the call or transaction that invoked the current function
msg.gas: Amount of gas the current function invocation has available
msg.sender: Address of account that started the current function invocation
msg.value: Amount of ether (in wei) that was sent along with the function invocation
pragma solidity ^0.4.17;
You can test this on remix.
const assert = require('assert');
const path = require('path');
npm run test
mac@HansonMac ~/Code/blockchain npm run test
Metamask running in Chrome will inject web3 v2.0 automatically.
Our app will use web3 v1.0, and we want to hijack our provider into Metamask one.
mac@HansonMac ~/Code: sudo npm install -g create-react-app
import Web3 from 'web3';
// add this to App.js
const HDWalletProvider = require('truffle-hdwallet-provider');
Attempting to deploy from account 0x01C65bfDeD8c69ef3C28d4EF58F1dA46DeAF13Cd
create a new file
src folder. And copy all the ABI and deployed address.
import web3 from `./web3`;
src/App.js code. See source code here:
create a new repository, and connect your project.
npm install gh-pages --save-dev
Add some properties to the app’s package.json file
Generate a production build of your app, and deploy it to GitHub Pages
npm run deploy
You can see the example on http://xszhao.science/lottery