Skip to content

Instantly share code, notes, and snippets.

@hswick
Last active June 28, 2017 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hswick/1fc0377f5644d4d2d81609bca7c1c560 to your computer and use it in GitHub Desktop.
Save hswick/1fc0377f5644d4d2d81609bca7c1c560 to your computer and use it in GitHub Desktop.
Notes on how to get started with ethereum

Install ethereum by following these instructions:

For example on Mac:

brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
brew linkapps solidity

This installs geth an ethereum public node and solc the solidity compiler

IGNORE GETH STUFF, geth will take a long time to run and it takes up a lot of memory on your computer!!! Skip to testrpc for dev purposes

You will have to wait a while for the sync to happen because it is downloading a copy of the ethereum blockchain. The decentralization aspect of the blockchain means each peer has a copy of the blockchain.

Currently following this tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2

For development purposes you can download test rpc via node package manager: npm install ethereumjs-testrpc web3

This will download the packages into a local directory

Try starting testrpc by running: node_modules/bin/testrpc

If you get an error like this: $ testrpc /usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/index.js:29 function VM (opts = {}) { ^

SyntaxError: Unexpected token = at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/hooked.js:6:12) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10)

You'll need to update Node to version 6 like so: brew upgrade nodejs Look here for the solution:

I've found this tutorial works pretty well so far: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2

However the instructions for compiling a contract do not work. You will need to compile the solidity contract into an ABI. You can do this using remix or solc See here for more information

To compile with solc use this command: solc --optimize --combined-json abi,bin,interface Test.sol > test.json

Then in node use JSON.parse(test.json) to read the abi interface

Once you have the abi parsed you will need to wait for the event to be emitted: https://media.consensys.net/technical-introduction-to-events-and-logs-in-ethereum-a074d65dd61e

You can set the event in the smart contract or you can wait for the contract to be mined. And once that happens you can make all sorts of calls that you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment