Files
web3.js/docs/_build/html/getting-started.html
T
2019-01-27 16:55:45 +01:00

141 lines
7.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting Started &#8212; web3.js 1.0.0 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Callbacks Promises Events" href="callbacks-promises-events.html" />
<link rel="prev" title="web3.js - Ethereum JavaScript API" href="index.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="callbacks-promises-events.html" title="Callbacks Promises Events"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="web3.js - Ethereum JavaScript API"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">web3.js 1.0.0 documentation</a> &#187;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This documentation is work in progress and web3.js 1.0 stable is not yet released! You can find the current documentation for web3 0.x.x at <a class="reference external" href="https://github.com/ethereum/wiki/wiki/JavaScript-API">github.com/ethereum/wiki/wiki/JavaScript-API</a>.</p>
</div>
<div class="section" id="getting-started">
<h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline"></a></h1>
<p>The web3.js library is a collection of modules which contain specific functionality for the ethereum ecosystem.</p>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">web3-eth</span></code> is for the ethereum blockchain and smart contracts</li>
<li>The <code class="docutils literal notranslate"><span class="pre">web3-shh</span></code> is for the whisper protocol to communicate p2p and broadcast</li>
<li>The <code class="docutils literal notranslate"><span class="pre">web3-bzz</span></code> is for the swarm protocol, the decentralized file storage</li>
<li>The <code class="docutils literal notranslate"><span class="pre">web3-utils</span></code> contains useful helper functions for Dapp developers.</li>
</ul>
<div class="section" id="adding-web3-js">
<span id="adding-web3"></span><h2>Adding web3.js<a class="headerlink" href="#adding-web3-js" title="Permalink to this headline"></a></h2>
<span class="target" id="index-0"></span><span class="target" id="index-1"></span><p id="index-2">First you need to get web3.js into your project. This can be done using the following methods:</p>
<ul class="simple">
<li>npm: <code class="docutils literal notranslate"><span class="pre">npm</span> <span class="pre">install</span> <span class="pre">web3</span></code></li>
<li>meteor: <code class="docutils literal notranslate"><span class="pre">meteor</span> <span class="pre">add</span> <span class="pre">ethereum:web3</span></code></li>
<li>pure js: link the <code class="docutils literal notranslate"><span class="pre">dist/web3.min.js</span></code></li>
</ul>
<p>After that you need to create a web3 instance and set a provider.
Ethereum supported Browsers like Mist or MetaMask will have a <code class="docutils literal notranslate"><span class="pre">ethereumProvider</span></code> or <code class="docutils literal notranslate"><span class="pre">web3.currentProvider</span></code> available. For web3.js, check <code class="docutils literal notranslate"><span class="pre">Web3.givenProvider</span></code>.
If this property is <code class="docutils literal notranslate"><span class="pre">null</span></code> you should connect to a remote/local node.</p>
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="c1">// in node.js use: const Web3 = require(&#39;web3&#39;);</span>
<span class="kr">const</span> <span class="nx">web3</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Web3</span><span class="p">(</span><span class="nx">Web3</span><span class="p">.</span><span class="nx">givenProvider</span> <span class="o">||</span> <span class="s2">&quot;ws://localhost:8546&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>Thats it! now you can use the <code class="docutils literal notranslate"><span class="pre">web3</span></code> object.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Getting Started</a><ul>
<li><a class="reference internal" href="#adding-web3-js">Adding web3.js</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">web3.js - Ethereum JavaScript API</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="callbacks-promises-events.html"
title="next chapter">Callbacks Promises Events</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/getting-started.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="callbacks-promises-events.html" title="Callbacks Promises Events"
>next</a> |</li>
<li class="right" >
<a href="index.html" title="web3.js - Ethereum JavaScript API"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">web3.js 1.0.0 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2016, Ethereum.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.3.
</div>
</body>
</html>