mirror of
https://github.com/embarklabs/web3.js.git
synced 2026-08-31 14:41:17 +00:00
148 lines
7.6 KiB
HTML
148 lines
7.6 KiB
HTML
<!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="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>Getting Started — 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">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: '1.0.0',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</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>
|
|
<link rel="index" title="Index" href="genindex.html" />
|
|
<link rel="search" title="Search" href="search.html" />
|
|
<link rel="top" title="web3.js 1.0.0 documentation" href="index.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 role="document">
|
|
<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> »</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 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"><span class="pre">web3-eth</span></code> is for the ethereum blockchain and smart contracts</li>
|
|
<li>The <code class="docutils literal"><span class="pre">web3-shh</span></code> is for the whisper protocol to communicate p2p and broadcast</li>
|
|
<li>The <code class="docutils literal"><span class="pre">web3-bzz</span></code> is for the swarm protocol, the decentralized file storage</li>
|
|
<li>The <code class="docutils literal"><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"><span class="pre">npm</span> <span class="pre">install</span> <span class="pre">web3</span></code></li>
|
|
<li>meteor: <code class="docutils literal"><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"><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"><span class="pre">ethereumProvider</span></code> or <code class="docutils literal"><span class="pre">web3.currentProvider</span></code> available, web3.js is setting this one to <code class="docutils literal"><span class="pre">Web3.givenProvider</span></code>.
|
|
If this property is <code class="docutils literal"><span class="pre">null</span></code> you need to connect to a remote/local node.</p>
|
|
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="c1">// in node.js use: var Web3 = require('web3');</span>
|
|
|
|
<span class="kd">var</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">"ws://localhost:8546"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>That’s it! now you can use the <code class="docutils literal"><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.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchbox" style="display: none" role="search">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<div><input type="text" name="q" /></div>
|
|
<div><input type="submit" value="Go" /></div>
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</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> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer" role="contentinfo">
|
|
© Copyright 2016, Ethereum.
|
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
|
|
</div>
|
|
</body>
|
|
</html> |