plugeth-utils/documentation/_build/html/build.html
2021-09-27 14:26:42 -07:00

183 lines
12 KiB
HTML

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Build and Deploy &mdash; Plugeth Austin Roberts documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Building a Custom Plugin" href="custom.html" />
<link rel="prev" title="Run" href="run.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Plugeth
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption"><span class="caption-text">Overview</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="project.html">Project Design</a></li>
<li class="toctree-l1"><a class="reference internal" href="types.html">Basic Types of Plugins</a></li>
</ul>
<p class="caption"><span class="caption-text">Tutorials</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="run.html">Run</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Build and Deploy</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#setting-up-the-environment">Setting up the environment</a></li>
<li class="toctree-l2"><a class="reference internal" href="#build-a-plugin">Build a plugin</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="custom.html">Building a Custom Plugin</a></li>
</ul>
<p class="caption"><span class="caption-text">Reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="system_req.html">System Requirements</a></li>
<li class="toctree-l1"><a class="reference internal" href="plugin_loader.html">Plugin Loader</a></li>
<li class="toctree-l1"><a class="reference internal" href="plugin_hooks.html">Plugin Hooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="core_restricted.html">Core vs Restricted packages in Plugeth-utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API</a></li>
</ul>
<p class="caption"><span class="caption-text">Contact</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="contact.html">Get in touch with us</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Plugeth</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>Build and Deploy</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/build.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="build-and-deploy">
<span id="build"></span><h1>Build and Deploy<a class="headerlink" href="#build-and-deploy" title="Permalink to this headline"></a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#setting-up-the-environment" id="id1">Setting up the environment</a></p></li>
<li><p><a class="reference internal" href="#build-a-plugin" id="id2">Build a plugin</a></p></li>
</ul>
</div>
<p>If you are ready to start building your own plugins go ahead and start <a href="#id3"><span class="problematic" id="id4">`here`_</span></a></p>
<div class="section" id="setting-up-the-environment">
<h2><a class="toc-backref" href="#id1">Setting up the environment</a><a class="headerlink" href="#setting-up-the-environment" title="Permalink to this headline"></a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Plugeth is built on a fork of <a class="reference external" href="https://geth.ethereum.org/">Geth</a> and as such requires familiarity with <a class="reference external" href="https://golang.org/doc/">Go</a> and a funtional <a class="reference external" href="https://golang.org/doc/code">environment</a> in which to build Go projects. Thankfully for everyone Go provides a compact and useful <a class="reference external" href="https://tour.golang.org/welcome/1">tutorial</a> as well as a <a class="reference external" href="https://tour.golang.org/welcome/1">space for practice</a>.</p>
</div>
<p>PluGeth is an application built in three seperate repositories.</p>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/openrelayxyz/plugeth">PluGeth</a></p></li>
<li><p><a class="reference external" href="https://github.com/openrelayxyz/plugeth-utils">PluGeth-Utils</a></p></li>
<li><p><a class="reference external" href="https://github.com/openrelayxyz/plugeth-plugins">PluGeth-Plugins</a></p></li>
</ul>
<p>For our purposed here you will only need to clone Plugeth and Plugeth-Plugins. Once you have them cloned you are ready to begin. First we need to build geth though the PluGeth project. Navigate to <code class="docutils literal notranslate"><span class="pre">plugeth/cmd/geth</span></code> and run:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ go get
</pre></div>
</div>
<p>This will download all dependencies needed for the project. This process will take a moment or two the first time through. Next run:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ go build
</pre></div>
</div>
<p>Once this is complete you should see a <code class="docutils literal notranslate"><span class="pre">.ethereum</span></code> folder in your home directory.</p>
<p>At this point you are ready to start downloading local ethereum nodes. In order to do so, from <code class="docutils literal notranslate"><span class="pre">plugeth/cmd/geth</span></code> run:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ ./geth
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">./geth</span></code> is the primary command to build a <em>Mainnet</em> node. Building a mainnet node requires at least 8 GB RAM, 2 CPUs, and 350 GB of SSD disks. However, dozens of available flags will change the behavior of whichever network you choose to connect to. <code class="docutils literal notranslate"><span class="pre">--help</span></code> is your friend.</p>
</div>
</div>
<div class="section" id="build-a-plugin">
<h2><a class="toc-backref" href="#id2">Build a plugin</a><a class="headerlink" href="#build-a-plugin" title="Permalink to this headline"></a></h2>
<p>For the sake of this tutorial we will be building the Hello plugin. Navigate to <code class="docutils literal notranslate"><span class="pre">plugethPlugins/packages/hello</span></code>. Inside you will see a <code class="docutils literal notranslate"><span class="pre">main.go</span></code> file. From this location run:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ go build -buildmode<span class="o">=</span>plugin
</pre></div>
</div>
<p>This will compile the plugin and produce a <code class="docutils literal notranslate"><span class="pre">hello.so</span></code> file. Move <code class="docutils literal notranslate"><span class="pre">hello.so</span></code> into <code class="docutils literal notranslate"><span class="pre">~/.ethereum/plugins</span></code> . In order to use this plugin geth will need to be started with a <code class="docutils literal notranslate"><span class="pre">http.api=mymamespace</span></code> flag. Additionally you will need to include a <code class="docutils literal notranslate"><span class="pre">--http</span></code> flag in order to access the standard json rpc methods.</p>
<p>Once geth has started you should see that the first <code class="docutils literal notranslate"><span class="pre">INFO</span></code> log reads: <code class="docutils literal notranslate"><span class="pre">initialized</span> <span class="pre">hello</span></code> . A new json rpc method, called hello, has been been appended to the list of available json rpc methods. In order to access this method you will need to <code class="docutils literal notranslate"><span class="pre">curl</span></code> into the network with this command:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ curl <span class="m">127</span>.0.0.1:8545 -H <span class="s2">&quot;Content-Type: application/json&quot;</span> --data <span class="s1">&#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;method&quot;:&quot;mynamespace_hello&quot;,&quot;params&quot;:[],&quot;id&quot;:0}&#39;</span>
</pre></div>
</div>
<p>You should see that the network has responded with:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="sb">``</span><span class="o">{</span><span class="s2">&quot;jsonrpc&quot;</span>:<span class="s2">&quot;2.0&quot;</span>,<span class="s2">&quot;id&quot;</span>:0,<span class="s2">&quot;result&quot;</span>:<span class="s2">&quot;Hello world&quot;</span><span class="o">}</span><span class="sb">``</span>
</pre></div>
</div>
<p>Congradulations. You have just built and run your first Plugeth plugin. From here you can follow the steps above to build any of the plugins you choose.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Each plugin will vary in terms of the requirements to deploy. Refer to the documentation of the plugin itself in order to assure
that you know how to use it.</p>
</div>
</div>
</div>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="run.html" class="btn btn-neutral float-left" title="Run" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="custom.html" class="btn btn-neutral float-right" title="Building a Custom Plugin" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2021, Philip Morlier.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>