GithubHelp home page GithubHelp logo

saltyskip / ethereum-demo-tools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tectract/ethereum-demo-tools

0.0 2.0 0.0 132 KB

Useful tool info and examples for learning to write Ethereum smart-contracts, to accompany my BlockGeeks article

License: Mozilla Public License 2.0

HTML 2.52% CSS 2.49% JavaScript 94.99%

ethereum-demo-tools's Introduction

ethereum-demo-tools

###dependencies

(install nodejs and npm, latest versions if you can)

npm i -g ethereumjs-testrpc

npm i -g ethereumjs-util # see note below

npm i -g truffle

Useful tool info and examples for learning to write Ethereum smart-contracts, to accompany my BlockGeeks article

truffle commands:

truffle init

truffle compile

truffle migrate

truffle console

testrpc startup with pre-set seed phrase and pre-defined networkID

COMMAND FROM DEMO ARTICLE: testrpc -m "sample dog come year spray crawl learn general detect silver jelly pilot" --network-id 20

networkID needs to be below decimal(108) for tx signature to work properly (tx.v must be one byte only)

note: ethereumjs-testrpc depends on OUTDATED ethereumjs-util, which has a signing bug which prevents Metamask from signing properly LOCALLY,

but it works ok on mainnet. In order to fix this, you should:

npm i -g ethereumjs-util@latest # separately from ethereumjs-testrpc

now: you need to find where ethereumjs-testrpc and ethereumjs-util actually got installed, then go to the

cd path-to/ethereumjs-util/node_modules

mv ethereumjs-util ethereumjs-util_old

ln -s path-to/ethereumjs-util .

this symlink will trick ethereumjs-testrpc into using the latest version of ethereumjs-util, and solve the "signing bug" for local deployment

###examples of interacting with Geekt contract via truffle console:

Geekt = Geekt.deployed()

Geekt.then(function(instance){return instance.registerNewUser("Tectract","Denver","CO","USA");})

Geekt.then(function(instance){return instance.addImageToUser('https://avatars1.githubusercontent.com/u/3859005?v=3&u=f4863d518451ebe42c16c776930e913335eb837b&s=400','0x6c3e007e281f6948b37c511a11e43c8026d2a16a8a45fed4e83379b66b0ab927');})

Geekt.then(function(instance){return instance.addImageToUser('https://avatars1.githubusercontent.com/u/3859005?v=3&u=f4863d518451ebe42c16c776930e913335eb837b&s=400','');})

Geekt.then(function(instance){return instance.getUser('0x0ac21f1a6fe22241ccd3af85477e5358ac5847c2');})

Geekt.then(function(instance){return JSON.stringify(instance.abi);})

Geekt.then(function(instance){return instance.getUsers();})

Geekt.then(function(instance){return instance.getImages();})

Geekt.then(function(instance){return instance.getImage('0x6c3e007e281f6948b37c511a11e43c8026d2a16a8a45fed4e83379b66b0ab927');})

Geekt.then(function(instance){return instance.removeImage('0x6c3e007e281f6948b37c511a11e43c8026d2a16a8a45fed4e83379b66b0ab927');})

Geekt.then(function(instance){return instance.removeUser('0x0ac21f1a6fe22241ccd3af85477e5358ac5847c2');})

###app creation

this app was created with: create-react-app (see: https://github.com/facebookincubator/create-react-app)

this app uses a cors-anywhere proxy (deployed at heroku with a domain whitelist and rate-limit), to grab image data for sha256 hashing

see https://github.com/Rob--W/cors-anywhere for details on deploying a cors-anywhere proxy

deployment info

to install the app locally

git clone https://www.github.com/tectract/ethereum-demo-tools/

cd ethereum-demo-tools/GeekReactApp

npm i

npm start

(or) npm run build

if testing against a localhost and local deployment of the contract, you'll have to update the contract address in App.js!

otherwise just use metamask plugin and connect to mainnet to test the app, even if running locally :)

ethereum-demo-tools's People

Contributors

tectract avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.