Git Product home page Git Product logo

seven-beta's Introduction

Get Started

You will need Truffle and Ganache

To install truffle globally first make sure you are using the right node version:

nvm use
npm install -g truffle

Install your deps so compilations work:

yarn

Make sure Ganache is running and then compile and migrate the contracts:

truffle compile
truffle migrate

Symlink contracts because create-react-app says so and there is no gosh

cd node_modules
ln -s ../build/contracts contracts

Note: If you have restarted ganache and redeployed contracts you must delete .cache from node_modules. You must also delete the symlinked contracts and redo the symlink. Also, don't forget to restore your MetaMask with the new seed.

You did it, you can now start the webserver

yarn start

You will need MetaMask. From the network dropdown choose Custom RPC and enter the RPC server displayed in Ganache. You can also use the Mnemonic from Ganache as the seed to view your accounts.

When you run into issues pray and tell yourself everything will be alright

MetaMask Common Issues

  • Did you choose the right network?
  • Did you enter your mnemonic for the most recent time you restarted Ganache?
  • When in doubt go to Settings > Reset Account

Using Truffle Console

truffle console

SimpleStorage.deployed() // return the deployed contract...
.then(function(instance) {
  return instance.set(7); // call a method of the contract...
}).then(function(value) {
  return value;
});
SimpleStorage.deployed()
.then(function(instance) {
  return instance.get.call();
}).then(function(value) {
  return value.toString()
});

Copy Paste Friendly:

SimpleStorage.deployed().then(function(instance) {return instance.set(2);}).then(function(value) {return value;});

// and

SimpleStorage.deployed().then(function(instance) {return instance.get.call();}).then(function(value) {return value.toString()});

What is actually happening (ie. The Stack)

I need to wrap my head around working in Ethereum so hopefully writing it down helps.

Ganache

Ganache is just a local ethereum node with an RPC server @ http://127.0.0.1:7545

MetaMask's Role

MetaMask injects their own provider (using the provider engine). They do this to intercept certain RPC calls for example, where they intercept the sendTransaction call and do their own signing and stuff on MetaMask.

Also worth noting this github comment explaining the state of things with subproviders and why MetaMask doesn't support websockets yet

Front End

React App connects to a web3 instance provided by MetaMask usually (src/utils/getWeb3.js). Though one could manually connect to the node like so:

// RANDOM JSON RPC TEST
// Create a web3 provider: the Ganache node (but this could be your own full node or whatever)
const clientProvider = new Web3.providers.HttpProvider('http://127.0.0.1:7545')
// Create a client using the given provider: this is gives us the abstractions
// of the Javascript JSON RPC API (https://github.com/ethereum/wiki/wiki/JSON-RPC#javascript-api)
const client = new Web3(clientProvider)
// Use the abstractions to do stuff...
client.eth.getAccounts().then(accounts => console.log(accounts))

Or somehow modify the above to use MetaMask's provider engine to do fancier stuff.

Testing

Yeah right...

seven-beta's People

Contributors

leobauza avatar

Watchers

 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.