Giter Site home page Giter Site logo

ethereum_contract's Introduction

Ethereum Tutorials

These contracts come from the Ethereum Go Wiki Tutorial section. I have modified the build process, but the contract code is exactly the same.

TL;DR

Deploy these contracts with the following commands:

yarn deployGreeterContract

yarn deployCoinContract

TOKEN_CONTRACT_ADDRESS='token_address' yarn deployCrowdfundContract

Background

In order to test these contracts, I advise you to run a node connected to an Ethereum testnet like ropsten. These instructions include connecting to the ropsten test net.

Setup

These contracts were compliled and deployed with the following software versions:

  • Geth/v1.8.3-stable
  • Node v6.11.1
  • Yarn 1.3.2

After cloning this repository, install dependencies.

yarn install

Make sure geth is running with the testnet and rpc options, if it's not already. If this is your first time running geth on the testnet, you will most likely need to let your node sync the blockchain (30 minutes).

geth --testnet --rpc

Jump into the geth console. The following path assumes MacOS. Adjust accordingly.

geth attach '/Users/USER_HERE/Library/Ethereum/testnet/geth.ipc'

If you don't have an account yet then create one in the geth console. After creating an account, use a testnet faucet to send Ether to it. You'll need to spend it to mine a contract into the blockchain.

> personal.newAccount();

Then unlock your account for spending money to mine a contract.

> personal.unlockAccount(eth.accounts[0], <Password here>, 50000);

Now, assuming you are in this project's directory, compile and run one of the scripts to deploy a contract:

yarn deployGreeterContract

This will reach out to geth via over your local network via it's API, and attempt to create the contract.

If geth has synced to the latest block, then you'll see an object containing the address and abi for the contract printed, as well as a helpful command to initialize the contract in the geth console.

Inside the geth javascript console, create your initialize your contract with the following code, or use the command printed out by the build script.

> var myContract = web3.eth.contract(YOUR_ABI).at(YOUR_CONTRACT_ADDRESS);

You can now call your contract methods. For example:

> myContract.greet();

and

> myContract.kill();

ethereum_contract's People

Contributors

yuyanakai128 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.