/ docs / contracts_configuration.html
contracts_configuration.html
   1  <!DOCTYPE html>
   2  <html lang="en" dir="ltr">
   3    <head prefix="og: http://ogp.me/ns#">
   4    <meta charset="utf-8">
   5    <title>Configuring Smart Contracts | Embark</title>
   6    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
   7    <meta name="viewport" content="width=device-width, initial-scale=1">
   8    <!-- Canonical links -->
   9    <link rel="canonical" href="https://framework.embarklabs.io/docs/contracts_configuration.html">
  10    <!-- Alternative links -->
  11    
  12  
  13    <!-- Icon -->
  14    <meta name="msapplication-TileColor" content="#080E1A">
  15    <link rel="icon" type="image/png" href="/assets/images/favicon-16.png" sizes="16x16" />
  16    <link rel="icon" type="image/png" href="/assets/images/favicon-32.png" sizes="32x32" />
  17  
  18    <link rel="apple-touch-icon" sizes="76x76" href="/assets/images/apple-touch-icon-60x60-precomposed.png">
  19    <link rel="apple-touch-icon" sizes="76x76" href="/assets/images/apple-touch-icon-76x76-precomposed.png">
  20    <link rel="apple-touch-icon" sizes="120x120" href="/assets/images/apple-touch-icon-120x120-precomposed.png">
  21    <link rel="apple-touch-icon" sizes="152x152" href="/assets/images/apple-touch-icon-152x152-precomposed.png">
  22    <link rel="apple-touch-icon" sizes="180x180" href="/assets/images/apple-touch-icon-precomposed.png">
  23    <link rel="apple-touch-icon" href="/assets/images/apple-touch-icon-precomposed.png">
  24    <!-- CSS -->
  25    
  26  <link rel="stylesheet" href="/css/embark.css">
  27  
  28    <!-- endbuild -->
  29  
  30    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  31    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
  32  
  33    <!-- RSS -->
  34    <link rel="alternate" href="/atom.xml" title="Embark">
  35    <meta property="og:image" content="/img/share.png?v=0.0.5" />
  36    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.4/styles/dracula.min.css">
  37  
  38    <script async defer src="https://buttons.github.io/buttons.js"></script>
  39  
  40  
  41  <script>
  42    !function(root, factory) {
  43      "function" == typeof define && define.amd ? // AMD. Register as an anonymous module unless amdModuleId is set
  44      define([], function() {
  45          return root.svg4everybody = factory();
  46      }) : "object" == typeof module && module.exports ? // Node. Does not work with strict CommonJS, but
  47      // only CommonJS-like environments that support module.exports,
  48      // like Node.
  49      module.exports = factory() : root.svg4everybody = factory();
  50  }(this, function() {
  51      /*! svg4everybody v2.1.9 | github.com/jonathantneal/svg4everybody */
  52      function embed(parent, svg, target) {
  53          // if the target exists
  54          if (target) {
  55              // create a document fragment to hold the contents of the target
  56              var fragment = document.createDocumentFragment(), viewBox = !svg.hasAttribute("viewBox") && target.getAttribute("viewBox");
  57              // conditionally set the viewBox on the svg
  58              viewBox && svg.setAttribute("viewBox", viewBox);
  59              // copy the contents of the clone into the fragment
  60              for (// clone the target
  61              var clone = target.cloneNode(!0); clone.childNodes.length; ) {
  62                  fragment.appendChild(clone.firstChild);
  63              }
  64              // append the fragment into the svg
  65              parent.appendChild(fragment);
  66          }
  67      }
  68      function loadreadystatechange(xhr) {
  69          // listen to changes in the request
  70          xhr.onreadystatechange = function() {
  71              // if the request is ready
  72              if (4 === xhr.readyState) {
  73                  // get the cached html document
  74                  var cachedDocument = xhr._cachedDocument;
  75                  // ensure the cached html document based on the xhr response
  76                  cachedDocument || (cachedDocument = xhr._cachedDocument = document.implementation.createHTMLDocument(""),
  77                  cachedDocument.body.innerHTML = xhr.responseText, xhr._cachedTarget = {}), // clear the xhr embeds list and embed each item
  78                  xhr._embeds.splice(0).map(function(item) {
  79                      // get the cached target
  80                      var target = xhr._cachedTarget[item.id];
  81                      // ensure the cached target
  82                      target || (target = xhr._cachedTarget[item.id] = cachedDocument.getElementById(item.id)),
  83                      // embed the target into the svg
  84                      embed(item.parent, item.svg, target);
  85                  });
  86              }
  87          }, // test the ready state change immediately
  88          xhr.onreadystatechange();
  89      }
  90      function svg4everybody(rawopts) {
  91          function oninterval() {
  92              // while the index exists in the live <use> collection
  93              for (// get the cached <use> index
  94              var index = 0; index < uses.length; ) {
  95                  // get the current <use>
  96                  var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent), src = use.getAttribute("xlink:href") || use.getAttribute("href");
  97                  if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)),
  98                  svg && src) {
  99                      if (polyfill) {
 100                          if (!opts.validate || opts.validate(src, svg, use)) {
 101                              // remove the <use> element
 102                              parent.removeChild(use);
 103                              // parse the src and get the url and id
 104                              var srcSplit = src.split("#"), url = srcSplit.shift(), id = srcSplit.join("#");
 105                              // if the link is external
 106                              if (url.length) {
 107                                  // get the cached xhr request
 108                                  var xhr = requests[url];
 109                                  // ensure the xhr request exists
 110                                  xhr || (xhr = requests[url] = new XMLHttpRequest(), xhr.open("GET", url), xhr.send(),
 111                                  xhr._embeds = []), // add the svg and id as an item to the xhr embeds list
 112                                  xhr._embeds.push({
 113                                      parent: parent,
 114                                      svg: svg,
 115                                      id: id
 116                                  }), // prepare the xhr ready state change event
 117                                  loadreadystatechange(xhr);
 118                              } else {
 119                                  // embed the local id into the svg
 120                                  embed(parent, svg, document.getElementById(id));
 121                              }
 122                          } else {
 123                              // increase the index when the previous value was not "valid"
 124                              ++index, ++numberOfSvgUseElementsToBypass;
 125                          }
 126                      }
 127                  } else {
 128                      // increase the index when the previous value was not "valid"
 129                      ++index;
 130                  }
 131              }
 132              // continue the interval
 133              (!uses.length || uses.length - numberOfSvgUseElementsToBypass > 0) && requestAnimationFrame(oninterval, 67);
 134          }
 135          var polyfill, opts = Object(rawopts), newerIEUA = /\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/, webkitUA = /\bAppleWebKit\/(\d+)\b/, olderEdgeUA = /\bEdge\/12\.(\d+)\b/, edgeUA = /\bEdge\/.(\d+)\b/, inIframe = window.top !== window.self;
 136          polyfill = "polyfill" in opts ? opts.polyfill : newerIEUA.test(navigator.userAgent) || (navigator.userAgent.match(olderEdgeUA) || [])[1] < 10547 || (navigator.userAgent.match(webkitUA) || [])[1] < 537 || edgeUA.test(navigator.userAgent) && inIframe;
 137          // create xhr requests object
 138          var requests = {}, requestAnimationFrame = window.requestAnimationFrame || setTimeout, uses = document.getElementsByTagName("use"), numberOfSvgUseElementsToBypass = 0;
 139          // conditionally start the interval if the polyfill is active
 140          polyfill && oninterval();
 141      }
 142      function getSVGAncestor(node) {
 143          for (var svg = node; "svg" !== svg.nodeName.toLowerCase() && (svg = svg.parentNode); ) {}
 144          return svg;
 145      }
 146      return svg4everybody;
 147  });
 148  
 149  svg4everybody();
 150  </script>
 151  </head>
 152  
 153    <body>
 154      <header role="banner" class="c-header c-header--compact">
 155    <span class="c-header__background"></span>
 156    <div class="o-container c-header__content">
 157      <div class="c-header__top">
 158        <a href="/" title="Embark" class="c-logo c-logo--negative">Embark</a>
 159        <nav role="navigation" class="c-navigation">
 160          <div class="c-navigation__header">
 161            <a href="/" title="Embark" class="c-logo">Embark</a>
 162            <button class="c-navigation__close u-text-light" title="Close menu">
 163              <svg class="c-icon c-icon--xs"><use xlink:href="/../assets/icons/symbols.svg#icon-close"></use></svg>
 164            </button>
 165          </div>
 166          <div class="c-navigation__body">
 167            <ul class="c-navigation__list">
 168              <li class="c-navigation__item">
 169                <a href="/docs/quick_start.html" class="c-navigation__anchor " title="Quick Start">Quick Start</a>
 170              </li>
 171              <li class="c-navigation__item">
 172                <a href="/docs" class="c-navigation__anchor is-active" title="Learn">Learn</a>
 173              </li>
 174              <li class="c-navigation__item">
 175                <a href="/plugins" class="c-navigation__anchor " title="Plugins">Plugins</a>
 176              </li>
 177              <li class="c-navigation__item">
 178                <a href="/community" class="c-navigation__anchor " title="Community">Community</a>
 179              </li>
 180              <li class="c-navigation__item">
 181                <a href="https://blog.embarklabs.io" target="_blank" rel="noopener" class="c-navigation__anchor " title="Blog">Blog</a>
 182              </li>
 183            </ul>
 184          </div>
 185        </nav>
 186        <div class="o-flex o-flex-center">
 187          <form action="" class="o-flex__item u-hidden-until-large">
 188            <input type="search" placeholder="Search" id="search-input">
 189          </form>
 190          <div class="o-flex__item">
 191            <ul class="o-flex o-flex-center">
 192              <li class="o-flex__item">
 193                <a href="https://github.com/embarklabs/embark" title="Github" target="_blank" class="u-link-ghost">
 194                  <svg class="c-icon"><use xlink:href="/../assets/icons/symbols.svg#icon-github"></use></svg>
 195                </a>
 196              </li>
 197              <li class="o-flex__item">
 198                <a href="https://twitter.com/EmbarkProject" title="Twitter" target="_blank">
 199                  <svg class="c-icon"><use xlink:href="/../assets/icons/symbols.svg#icon-twitter"></use></svg>
 200                </a>
 201              </li>
 202              <li class="o-flex__item u-hidden-large-up">
 203                <button type="button"class="c-navigation__trigger u-link-ghost" title="Open menu">
 204                  <svg class="c-icon"><use xlink:href="/../assets/icons/symbols.svg#icon-navigation-menu"></use></svg>
 205                </button>
 206              </li>
 207            </ul>
 208          </div>
 209        </div>
 210      </div>
 211      <div class="c-quick-search o-distance-m u-hidden-large-up">
 212        <input type="search" id="inp-search" placeholder="Search">
 213      </div>
 214      <div class="c-header__body">
 215        <h1 class="c-title u-text-ghost">Documentation</h1>
 216  
 217        
 218  
 219        
 220        
 221      </div>
 222    </div>
 223  </header>
 224  
 225  
 226  <main role="main">
 227    <section class="o-guided-content o-distance">
 228      <div class="o-guided-content__wrapper">
 229        <button title="Open docs menu" id="guides-trigger" class="c-button c-button--minion u-hidden-large-up">
 230          <svg class="c-icon c-icon--xs"><use xlink:href="/../../assets/icons/symbols.svg#icon-navigation-menu"></use></svg>
 231          <span>Guides</span>
 232        </button>
 233        <div class="c-guide o-guided-content__guide"  id="guide-navigation">
 234          <div class="c-guide__header u-hidden-large-up">
 235            <a href="" title="Guides">
 236              Guides
 237            </a>
 238            <button type="button" title="Close menu" id="guides-close">
 239              <svg class="c-icon c-icon--xs"><use xlink:href="/../../assets/icons/symbols.svg#icon-close"></use></svg>
 240            </button>
 241          </div>
 242          <div class="c-guide__body">
 243            <nav role="navigation">
 244              
 245                <div class="">
 246                  <h3 class="c-category-title">Getting Started</h3>
 247                  <ul class="o-list-bare">
 248                    
 249                    <li class="o-list-bare__item">
 250                      <a href="/docs/overview.html" title="Overview" class="u-link-uniform ">Overview</a>
 251                      <!-- <div class="o-distance-m">
 252                        <ul class="o-list-bare c-navigation__subnav">
 253                          <li class="o-list-bare__item">
 254                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 255                          </li>
 256                        </ul>
 257                      </div> -->
 258                    </li>
 259                    
 260                    <li class="o-list-bare__item">
 261                      <a href="/docs/installation.html" title="Installation" class="u-link-uniform ">Installation</a>
 262                      <!-- <div class="o-distance-m">
 263                        <ul class="o-list-bare c-navigation__subnav">
 264                          <li class="o-list-bare__item">
 265                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 266                          </li>
 267                        </ul>
 268                      </div> -->
 269                    </li>
 270                    
 271                    <li class="o-list-bare__item">
 272                      <a href="/docs/faq.html" title="FAQ" class="u-link-uniform ">FAQ</a>
 273                      <!-- <div class="o-distance-m">
 274                        <ul class="o-list-bare c-navigation__subnav">
 275                          <li class="o-list-bare__item">
 276                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 277                          </li>
 278                        </ul>
 279                      </div> -->
 280                    </li>
 281                    
 282                  </ul>
 283                
 284              
 285                <div class="o-distance-xl">
 286                  <h3 class="c-category-title">General Usage</h3>
 287                  <ul class="o-list-bare">
 288                    
 289                    <li class="o-list-bare__item">
 290                      <a href="/docs/create_project.html" title="Creating apps" class="u-link-uniform ">Creating apps</a>
 291                      <!-- <div class="o-distance-m">
 292                        <ul class="o-list-bare c-navigation__subnav">
 293                          <li class="o-list-bare__item">
 294                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 295                          </li>
 296                        </ul>
 297                      </div> -->
 298                    </li>
 299                    
 300                    <li class="o-list-bare__item">
 301                      <a href="/docs/structure.html" title="App structure" class="u-link-uniform ">App structure</a>
 302                      <!-- <div class="o-distance-m">
 303                        <ul class="o-list-bare c-navigation__subnav">
 304                          <li class="o-list-bare__item">
 305                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 306                          </li>
 307                        </ul>
 308                      </div> -->
 309                    </li>
 310                    
 311                    <li class="o-list-bare__item">
 312                      <a href="/docs/running_apps.html" title="Running apps" class="u-link-uniform ">Running apps</a>
 313                      <!-- <div class="o-distance-m">
 314                        <ul class="o-list-bare c-navigation__subnav">
 315                          <li class="o-list-bare__item">
 316                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 317                          </li>
 318                        </ul>
 319                      </div> -->
 320                    </li>
 321                    
 322                    <li class="o-list-bare__item">
 323                      <a href="/docs/dashboard.html" title="Using the dashboard" class="u-link-uniform ">Using the dashboard</a>
 324                      <!-- <div class="o-distance-m">
 325                        <ul class="o-list-bare c-navigation__subnav">
 326                          <li class="o-list-bare__item">
 327                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 328                          </li>
 329                        </ul>
 330                      </div> -->
 331                    </li>
 332                    
 333                    <li class="o-list-bare__item">
 334                      <a href="/docs/using_the_console.html" title="Using the console" class="u-link-uniform ">Using the console</a>
 335                      <!-- <div class="o-distance-m">
 336                        <ul class="o-list-bare c-navigation__subnav">
 337                          <li class="o-list-bare__item">
 338                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 339                          </li>
 340                        </ul>
 341                      </div> -->
 342                    </li>
 343                    
 344                    <li class="o-list-bare__item">
 345                      <a href="/docs/environments.html" title="Environments" class="u-link-uniform ">Environments</a>
 346                      <!-- <div class="o-distance-m">
 347                        <ul class="o-list-bare c-navigation__subnav">
 348                          <li class="o-list-bare__item">
 349                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 350                          </li>
 351                        </ul>
 352                      </div> -->
 353                    </li>
 354                    
 355                    <li class="o-list-bare__item">
 356                      <a href="/docs/configuration.html" title="Configuration" class="u-link-uniform ">Configuration</a>
 357                      <!-- <div class="o-distance-m">
 358                        <ul class="o-list-bare c-navigation__subnav">
 359                          <li class="o-list-bare__item">
 360                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 361                          </li>
 362                        </ul>
 363                      </div> -->
 364                    </li>
 365                    
 366                    <li class="o-list-bare__item">
 367                      <a href="/docs/pipeline_and_webpack.html" title="Building & Compiling" class="u-link-uniform ">Building & Compiling</a>
 368                      <!-- <div class="o-distance-m">
 369                        <ul class="o-list-bare c-navigation__subnav">
 370                          <li class="o-list-bare__item">
 371                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 372                          </li>
 373                        </ul>
 374                      </div> -->
 375                    </li>
 376                    
 377                    <li class="o-list-bare__item">
 378                      <a href="/docs/executing_scripts.html" title="Executing Scripts" class="u-link-uniform ">Executing Scripts</a>
 379                      <!-- <div class="o-distance-m">
 380                        <ul class="o-list-bare c-navigation__subnav">
 381                          <li class="o-list-bare__item">
 382                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 383                          </li>
 384                        </ul>
 385                      </div> -->
 386                    </li>
 387                    
 388                    <li class="o-list-bare__item">
 389                      <a href="/docs/javascript_usage.html" title="Using EmbarkJS" class="u-link-uniform ">Using EmbarkJS</a>
 390                      <!-- <div class="o-distance-m">
 391                        <ul class="o-list-bare c-navigation__subnav">
 392                          <li class="o-list-bare__item">
 393                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 394                          </li>
 395                        </ul>
 396                      </div> -->
 397                    </li>
 398                    
 399                  </ul>
 400                </div>
 401              
 402                <div class="o-distance-xl">
 403                  <h3 class="c-category-title">Smart Contract Development</h3>
 404                  <ul class="o-list-bare">
 405                    
 406                    <li class="o-list-bare__item">
 407                      <a href="/docs/contracts_configuration.html" title="Configuration" class="u-link-uniform is-active">Configuration</a>
 408                      <!-- <div class="o-distance-m">
 409                        <ul class="o-list-bare c-navigation__subnav">
 410                          <li class="o-list-bare__item">
 411                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 412                          </li>
 413                        </ul>
 414                      </div> -->
 415                    </li>
 416                    
 417                    <li class="o-list-bare__item">
 418                      <a href="/docs/contracts_deployment.html" title="Accounts & Deployment" class="u-link-uniform ">Accounts & Deployment</a>
 419                      <!-- <div class="o-distance-m">
 420                        <ul class="o-list-bare c-navigation__subnav">
 421                          <li class="o-list-bare__item">
 422                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 423                          </li>
 424                        </ul>
 425                      </div> -->
 426                    </li>
 427                    
 428                    <li class="o-list-bare__item">
 429                      <a href="/docs/contracts_imports.html" title="Special Imports" class="u-link-uniform ">Special Imports</a>
 430                      <!-- <div class="o-distance-m">
 431                        <ul class="o-list-bare c-navigation__subnav">
 432                          <li class="o-list-bare__item">
 433                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 434                          </li>
 435                        </ul>
 436                      </div> -->
 437                    </li>
 438                    
 439                    <li class="o-list-bare__item">
 440                      <a href="/docs/contracts_testing.html" title="Testing" class="u-link-uniform ">Testing</a>
 441                      <!-- <div class="o-distance-m">
 442                        <ul class="o-list-bare c-navigation__subnav">
 443                          <li class="o-list-bare__item">
 444                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 445                          </li>
 446                        </ul>
 447                      </div> -->
 448                    </li>
 449                    
 450                    <li class="o-list-bare__item">
 451                      <a href="/docs/contracts_javascript.html" title="Smart Contracts in JavaScript" class="u-link-uniform ">Smart Contracts in JavaScript</a>
 452                      <!-- <div class="o-distance-m">
 453                        <ul class="o-list-bare c-navigation__subnav">
 454                          <li class="o-list-bare__item">
 455                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 456                          </li>
 457                        </ul>
 458                      </div> -->
 459                    </li>
 460                    
 461                  </ul>
 462                </div>
 463              
 464                <div class="o-distance-xl">
 465                  <h3 class="c-category-title">Blockchain Client</h3>
 466                  <ul class="o-list-bare">
 467                    
 468                    <li class="o-list-bare__item">
 469                      <a href="/docs/blockchain_configuration.html" title="Configuration" class="u-link-uniform ">Configuration</a>
 470                      <!-- <div class="o-distance-m">
 471                        <ul class="o-list-bare c-navigation__subnav">
 472                          <li class="o-list-bare__item">
 473                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 474                          </li>
 475                        </ul>
 476                      </div> -->
 477                    </li>
 478                    
 479                    <li class="o-list-bare__item">
 480                      <a href="/docs/blockchain_accounts_configuration.html" title="Managing Accounts" class="u-link-uniform ">Managing Accounts</a>
 481                      <!-- <div class="o-distance-m">
 482                        <ul class="o-list-bare c-navigation__subnav">
 483                          <li class="o-list-bare__item">
 484                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 485                          </li>
 486                        </ul>
 487                      </div> -->
 488                    </li>
 489                    
 490                  </ul>
 491                </div>
 492              
 493                <div class="o-distance-xl">
 494                  <h3 class="c-category-title">Storage (IPFS/Swarm)</h3>
 495                  <ul class="o-list-bare">
 496                    
 497                    <li class="o-list-bare__item">
 498                      <a href="/docs/storage_configuration.html" title="Configuration" class="u-link-uniform ">Configuration</a>
 499                      <!-- <div class="o-distance-m">
 500                        <ul class="o-list-bare c-navigation__subnav">
 501                          <li class="o-list-bare__item">
 502                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 503                          </li>
 504                        </ul>
 505                      </div> -->
 506                    </li>
 507                    
 508                    <li class="o-list-bare__item">
 509                      <a href="/docs/storage_deployment.html" title="Deploying apps" class="u-link-uniform ">Deploying apps</a>
 510                      <!-- <div class="o-distance-m">
 511                        <ul class="o-list-bare c-navigation__subnav">
 512                          <li class="o-list-bare__item">
 513                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 514                          </li>
 515                        </ul>
 516                      </div> -->
 517                    </li>
 518                    
 519                    <li class="o-list-bare__item">
 520                      <a href="/docs/storage_javascript.html" title="Storage APIs in JavaScript" class="u-link-uniform ">Storage APIs in JavaScript</a>
 521                      <!-- <div class="o-distance-m">
 522                        <ul class="o-list-bare c-navigation__subnav">
 523                          <li class="o-list-bare__item">
 524                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 525                          </li>
 526                        </ul>
 527                      </div> -->
 528                    </li>
 529                    
 530                  </ul>
 531                </div>
 532              
 533                <div class="o-distance-xl">
 534                  <h3 class="c-category-title">Messages (Whisper)</h3>
 535                  <ul class="o-list-bare">
 536                    
 537                    <li class="o-list-bare__item">
 538                      <a href="/docs/messages_configuration.html" title="Configuration" class="u-link-uniform ">Configuration</a>
 539                      <!-- <div class="o-distance-m">
 540                        <ul class="o-list-bare c-navigation__subnav">
 541                          <li class="o-list-bare__item">
 542                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 543                          </li>
 544                        </ul>
 545                      </div> -->
 546                    </li>
 547                    
 548                    <li class="o-list-bare__item">
 549                      <a href="/docs/messages_javascript.html" title="Messages in JavaScript" class="u-link-uniform ">Messages in JavaScript</a>
 550                      <!-- <div class="o-distance-m">
 551                        <ul class="o-list-bare c-navigation__subnav">
 552                          <li class="o-list-bare__item">
 553                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 554                          </li>
 555                        </ul>
 556                      </div> -->
 557                    </li>
 558                    
 559                  </ul>
 560                </div>
 561              
 562                <div class="o-distance-xl">
 563                  <h3 class="c-category-title">Naming Systems (ENS)</h3>
 564                  <ul class="o-list-bare">
 565                    
 566                    <li class="o-list-bare__item">
 567                      <a href="/docs/naming_configuration.html" title="Configuration" class="u-link-uniform ">Configuration</a>
 568                      <!-- <div class="o-distance-m">
 569                        <ul class="o-list-bare c-navigation__subnav">
 570                          <li class="o-list-bare__item">
 571                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 572                          </li>
 573                        </ul>
 574                      </div> -->
 575                    </li>
 576                    
 577                    <li class="o-list-bare__item">
 578                      <a href="/docs/naming_javascript.html" title="Naming Systems in JavaScript" class="u-link-uniform ">Naming Systems in JavaScript</a>
 579                      <!-- <div class="o-distance-m">
 580                        <ul class="o-list-bare c-navigation__subnav">
 581                          <li class="o-list-bare__item">
 582                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 583                          </li>
 584                        </ul>
 585                      </div> -->
 586                    </li>
 587                    
 588                  </ul>
 589                </div>
 590              
 591                <div class="o-distance-xl">
 592                  <h3 class="c-category-title">Plugins</h3>
 593                  <ul class="o-list-bare">
 594                    
 595                    <li class="o-list-bare__item">
 596                      <a href="/docs/installing_plugins.html" title="Installing plugins" class="u-link-uniform ">Installing plugins</a>
 597                      <!-- <div class="o-distance-m">
 598                        <ul class="o-list-bare c-navigation__subnav">
 599                          <li class="o-list-bare__item">
 600                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 601                          </li>
 602                        </ul>
 603                      </div> -->
 604                    </li>
 605                    
 606                    <li class="o-list-bare__item">
 607                      <a href="/docs/creating_plugins.html" title="Creating plugins" class="u-link-uniform ">Creating plugins</a>
 608                      <!-- <div class="o-distance-m">
 609                        <ul class="o-list-bare c-navigation__subnav">
 610                          <li class="o-list-bare__item">
 611                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 612                          </li>
 613                        </ul>
 614                      </div> -->
 615                    </li>
 616                    
 617                    <li class="o-list-bare__item">
 618                      <a href="/docs/plugin_reference.html" title="Plugin APIs" class="u-link-uniform ">Plugin APIs</a>
 619                      <!-- <div class="o-distance-m">
 620                        <ul class="o-list-bare c-navigation__subnav">
 621                          <li class="o-list-bare__item">
 622                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 623                          </li>
 624                        </ul>
 625                      </div> -->
 626                    </li>
 627                    
 628                  </ul>
 629                </div>
 630              
 631                <div class="o-distance-xl">
 632                  <h3 class="c-category-title">Cockpit Guides</h3>
 633                  <ul class="o-list-bare">
 634                    
 635                    <li class="o-list-bare__item">
 636                      <a href="/docs/cockpit_introduction.html" title="Introduction" class="u-link-uniform ">Introduction</a>
 637                      <!-- <div class="o-distance-m">
 638                        <ul class="o-list-bare c-navigation__subnav">
 639                          <li class="o-list-bare__item">
 640                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 641                          </li>
 642                        </ul>
 643                      </div> -->
 644                    </li>
 645                    
 646                    <li class="o-list-bare__item">
 647                      <a href="/docs/cockpit_dashboard.html" title="Using the Dashboard" class="u-link-uniform ">Using the Dashboard</a>
 648                      <!-- <div class="o-distance-m">
 649                        <ul class="o-list-bare c-navigation__subnav">
 650                          <li class="o-list-bare__item">
 651                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 652                          </li>
 653                        </ul>
 654                      </div> -->
 655                    </li>
 656                    
 657                    <li class="o-list-bare__item">
 658                      <a href="/docs/cockpit_deployment.html" title="Deployment" class="u-link-uniform ">Deployment</a>
 659                      <!-- <div class="o-distance-m">
 660                        <ul class="o-list-bare c-navigation__subnav">
 661                          <li class="o-list-bare__item">
 662                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 663                          </li>
 664                        </ul>
 665                      </div> -->
 666                    </li>
 667                    
 668                    <li class="o-list-bare__item">
 669                      <a href="/docs/cockpit_explorer.html" title="Explorer View" class="u-link-uniform ">Explorer View</a>
 670                      <!-- <div class="o-distance-m">
 671                        <ul class="o-list-bare c-navigation__subnav">
 672                          <li class="o-list-bare__item">
 673                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 674                          </li>
 675                        </ul>
 676                      </div> -->
 677                    </li>
 678                    
 679                    <li class="o-list-bare__item">
 680                      <a href="/docs/cockpit_editor.html" title="Code Editor" class="u-link-uniform ">Code Editor</a>
 681                      <!-- <div class="o-distance-m">
 682                        <ul class="o-list-bare c-navigation__subnav">
 683                          <li class="o-list-bare__item">
 684                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 685                          </li>
 686                        </ul>
 687                      </div> -->
 688                    </li>
 689                    
 690                    <li class="o-list-bare__item">
 691                      <a href="/docs/cockpit_debugger.html" title="Using the Debugger" class="u-link-uniform ">Using the Debugger</a>
 692                      <!-- <div class="o-distance-m">
 693                        <ul class="o-list-bare c-navigation__subnav">
 694                          <li class="o-list-bare__item">
 695                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 696                          </li>
 697                        </ul>
 698                      </div> -->
 699                    </li>
 700                    
 701                  </ul>
 702                </div>
 703              
 704                <div class="o-distance-xl">
 705                  <h3 class="c-category-title">Reference</h3>
 706                  <ul class="o-list-bare">
 707                    
 708                    <li class="o-list-bare__item">
 709                      <a href="/docs/embark_commands.html" title="CLI Commands" class="u-link-uniform ">CLI Commands</a>
 710                      <!-- <div class="o-distance-m">
 711                        <ul class="o-list-bare c-navigation__subnav">
 712                          <li class="o-list-bare__item">
 713                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 714                          </li>
 715                        </ul>
 716                      </div> -->
 717                    </li>
 718                    
 719                  </ul>
 720                </div>
 721              
 722                <div class="o-distance-xl">
 723                  <h3 class="c-category-title">Miscellaneous</h3>
 724                  <ul class="o-list-bare">
 725                    
 726                    <li class="o-list-bare__item">
 727                      <a href="/docs/migrating_from_3.x.html" title="Migrating from Embark 3.x" class="u-link-uniform ">Migrating from Embark 3.x</a>
 728                      <!-- <div class="o-distance-m">
 729                        <ul class="o-list-bare c-navigation__subnav">
 730                          <li class="o-list-bare__item">
 731                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 732                          </li>
 733                        </ul>
 734                      </div> -->
 735                    </li>
 736                    
 737                    <li class="o-list-bare__item">
 738                      <a href="/docs/troubleshooting.html" title="Troubleshooting" class="u-link-uniform ">Troubleshooting</a>
 739                      <!-- <div class="o-distance-m">
 740                        <ul class="o-list-bare c-navigation__subnav">
 741                          <li class="o-list-bare__item">
 742                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 743                          </li>
 744                        </ul>
 745                      </div> -->
 746                    </li>
 747                    
 748                    <li class="o-list-bare__item">
 749                      <a href="/docs/contributing.html" title="Contributing" class="u-link-uniform ">Contributing</a>
 750                      <!-- <div class="o-distance-m">
 751                        <ul class="o-list-bare c-navigation__subnav">
 752                          <li class="o-list-bare__item">
 753                            <a href="#" title="What is Embark?" class="u-link-uniform">What is Embark?</a>
 754                          </li>
 755                        </ul>
 756                      </div> -->
 757                    </li>
 758                    
 759                  </ul>
 760                </div>
 761              
 762            </nav>
 763          </div>
 764        </div>
 765        <div class="o-guided-content__content">
 766          <p class="c-meta">Last updated: February 19th 2020
 767            (<a href="https://github.com/embarklabs/embark/edit/master/site/source/docs/contracts_configuration.md" target="_blank">
 768              Improve this guide <svg class="c-icon c-icon--xs"><use xlink:href="/../../assets/icons/symbols.svg#icon-pen-write-paper"></use></svg>
 769            </a>)
 770          </p>
 771          <div class="o-standard-page">
 772            <h1>Configuring Smart Contracts</h1>
 773            <p>As many decentralized applications are powered by Smart Contracts, configuring and deploying them should be easy. That’s why Embark offers a declarative approach to define what Smart Contracts we’re interested in to deploy, what their dependencies are, as well as what they should be initialized with once instantiated. This guide will explore the different configuration options that help making deploying Smart Contracts a breeze.</p>
 774  <h2 id="Basic-Smart-Contract-Configuration"><a href="#Basic-Smart-Contract-Configuration" class="headerlink" title="Basic Smart Contract Configuration"></a>Basic Smart Contract Configuration</h2><p>Unless specified differently in our application’s <code>embark.json</code>, Smart Contracts are configured either in the <code>config/contracts.js</code> file, or, if we’re dealing with a <a href="create_project.html#Creating-%E2%80%9Ccontracts-only%E2%80%9D-apps">Smart Contract only app</a>, the <code>./contracts.js</code> file in the root of our project.</p>
 775  <p>A Smart Contract configuration is placed in an environment’s <code>deploy</code> property, with the name of the Smart Contract being the identifier. The following code creates a configuration for the <code>SimpleStorage</code> contract in the <code>development</code> environment:</p>
 776  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">module.exports &#x3D; &#123;</span><br><span class="line">  ...</span><br><span class="line">  development: &#123;</span><br><span class="line">    ...</span><br><span class="line">    deploy: &#123;</span><br><span class="line">      SimpleStorage: &#123;</span><br><span class="line">        ...</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 777  
 778  <p>Smart Contracts can be configured differently per environment just by adding a dedicated configuration to the corresponding environment. Head over to our <a href="environments.html">guide on environments</a> to learn more about this.</p>
 779  <h3 id="Configuring-constructor-parameters"><a href="#Configuring-constructor-parameters" class="headerlink" title="Configuring constructor parameters"></a>Configuring constructor parameters</h3><p>Often, Smart Contracts need to be initialized with certain values right after they have been deployed. We can configure a Smart Contract’s constructor parameters using the <code>args</code> property. <code>args</code> is either a list of values, which will be applied to the Smart Contract’s constructor parameters in the same order they are defined, or it can be an object specifying the parameters using named keys.</p>
 780  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">development: &#123;</span><br><span class="line">  deploy: &#123;</span><br><span class="line">    SimpleStorage: &#123;</span><br><span class="line">      args: [100]</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 781  
 782  <p>The following configuration configures the <code>SimpleStorage</code>‘s <code>initialValue</code> parameter, assuming that that one exists. Notice that by using this syntax, the order of constructor parameter values doesn’t matter anymore:</p>
 783  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">development: &#123;</span><br><span class="line">  deploy: &#123;</span><br><span class="line">    SimpleStorage: &#123;</span><br><span class="line">      args: &#123;</span><br><span class="line">        initialValue: 100</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 784  
 785  <h3 id="Configuring-gas-and-gas-price"><a href="#Configuring-gas-and-gas-price" class="headerlink" title="Configuring gas and gas price"></a>Configuring gas and gas price</h3><p>Both, <code>gas</code> and <code>gasPrice</code> can be configured for each Smart Contract. If we don’t want to configure that for every single contract, we can also specify <code>gas: auto</code> in the environment, like this:</p>
 786  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">development: &#123;</span><br><span class="line">  gas: &#39;auto&#39;,</span><br><span class="line">  deploy: &#123;</span><br><span class="line">    SimpleStorage: &#123;</span><br><span class="line">      args: [100],</span><br><span class="line">      gas: 800000,</span><br><span class="line">      gasPrice: 5</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 787  
 788  <p>Another cool feature of Embark is that it supports human readable ether units, to improve the developer experience.</p>
 789  <div class="c-notification c-notification--info">
 790    <p><strong>Human readable ether units</strong></p>
 791    <p><p>Embark supports <strong>human readable ether units</strong> in places where ether unit values are required. <a href="#Human-readable-Ether-units">Read here</a> for more information.</p>
 792  </p>
 793  </div> 
 794  
 795  
 796  
 797  <h2 id="Configuring-Smart-Contract-Dependencies"><a href="#Configuring-Smart-Contract-Dependencies" class="headerlink" title="Configuring Smart Contract Dependencies"></a>Configuring Smart Contract Dependencies</h2><p>When building more complex applications, it’s very common that a Smart Contract depends on another one. Embark makes it very easy to not only ensure dependency Smart Contracts are deployed before the Smart Contract in question deploys, but also accessing their deployed addresses.</p>
 798  <p>All we have to do is specifying the name of the Smart Contract we’re interested in, prefixed with a “$”. Embark will then take care of figuring out in which order our Smart Contracts need to be deployed, as well as replacing all <code>$CONTRACT_NAME</code>‘s with their corresponding addresses. Assuming <code>SimpleStorage</code> depends on <code>OtherContract</code>, this can be easily configured like this:</p>
 799  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    args: [100, &#39;$OtherContract&#39;]</span><br><span class="line">  &#125;,</span><br><span class="line">  OtherContract: &#123;...&#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 800  
 801  <h2 id="Disabling-deployment"><a href="#Disabling-deployment" class="headerlink" title="Disabling deployment"></a>Disabling deployment</h2><p>Sometimes we want to configure different behaviour for certain contracts within different <a href="environments.html">environments</a>. One of those cases could be that we don’t actually want to deploy <code>SimpleStorage</code> in the production environment as we might expect some other storage Smart Contract to already be somewhere out there.</p>
 802  <p>We can prevent Embark from deploying any of our Smart Contracts by using the <code>deploy</code> configuration and setting it to <code>false</code> like this:</p>
 803  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">development:</span><br><span class="line">  deploy: &#123;</span><br><span class="line">    SimpleStorage: &#123;</span><br><span class="line">      args: [100]</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;,</span><br><span class="line">production: &#123;</span><br><span class="line">  deploy: &#123;</span><br><span class="line">    SimpleStorage: &#123;</span><br><span class="line">      deploy: false</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 804  
 805  <h2 id="Defining-interfaces"><a href="#Defining-interfaces" class="headerlink" title="Defining interfaces"></a>Defining interfaces</h2><p>There are scenarios in which certain Smart Contract sources are used for inheritance or as interfaces. While their source has to be compiled,<br>we don’t actually want to deploy them. To prevent such Smart Contracts from deploying, we can either take advantage of the <code>deploy: false</code><br>propery discussed above, or use the more semantic <code>interfaces</code> and <code>libraries</code> configurations.</p>
 806  <p>Both of them are simple lists of Smart Contract names that should be treated as interfaces and libraries respectively. The following example<br>show how the <code>Ownable</code> Smart Contract is configured as interface and therefore won’t be deployed:</p>
 807  <figure class="highlight"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">development:</span><br><span class="line">  interfaces: ['Ownable'],</span><br><span class="line">  deploy: &#123;</span><br><span class="line">    InheritsOwnable: &#123;&#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 808  
 809  <h2 id="Deployment-strategies"><a href="#Deployment-strategies" class="headerlink" title="Deployment strategies"></a>Deployment strategies</h2><p>In order to give users full control over which Smart Contracts should be deployed, Embark comes with a configuration feature called “deployment strategies”. Deployment strategies tell Embark whether it should deploy all of the user’s Smart Contracts (and its (3rd-party) dependencies, or just deploy individual Smart Contracts.</p>
 810  <p>There are two possible strategy options:</p>
 811  <ul>
 812  <li><strong>implicit</strong> - This is the default. Using the <code>implicit</code> strategy, Embark tries to deploy all Smart Contracts configured in the <code>deploy</code> configuration, including its (3rd-party) dependencies.</li>
 813  <li><strong>explicit</strong> - Setting this option to <code>explicit</code> tells Embark to deploy the Smart Contracts specified in the <code>deploy</code> configuration without their dependencies. This can be combined with <a href="#Disabling-deployment">disabling deployment</a> of individual Smart Contracts for fine control.</li>
 814  </ul>
 815  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">strategy: &#39;explicit&#39; &#x2F;&#x2F; &#39;implicit&#39; is the default</span><br><span class="line">deploy: &#123;</span><br><span class="line">  ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 816  
 817  
 818  <h2 id="Deploying-multiple-instances"><a href="#Deploying-multiple-instances" class="headerlink" title="Deploying multiple instances"></a>Deploying multiple instances</h2><p>In cases where we want to create multiple instances of the same Smart Contract but with, for example, different initialization values per instance, we can use the <code>instanceOf</code> property and refer to the original Smart Contract that should be deployed multiple times.</p>
 819  <p>This can then be combined with <a href="#Disabling-deployment">disabling the deployment</a> of the original Smart Contract like this:</p>
 820  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  Currency: &#123;</span><br><span class="line">    deploy: false,</span><br><span class="line">  &#125;,</span><br><span class="line">  Usd: &#123;</span><br><span class="line">    instanceOf: &#39;Currency&#39;,</span><br><span class="line">    args: [200]</span><br><span class="line">  &#125;,</span><br><span class="line">  MyCoin: &#123;</span><br><span class="line">    instanceOf: &#39;Currency&#39;,</span><br><span class="line">    args: [300]</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 821  
 822  <p>In the example above, we deploy <code>Usd</code> and <code>MyCoin</code> as instances of <code>Currency</code>. Notice that <code>Currency</code> itself isn’t going to be deployed but merely functions as a “recipe” to create other instances of it.</p>
 823  <h2 id="Referencing-already-deployed-Smart-Contracts"><a href="#Referencing-already-deployed-Smart-Contracts" class="headerlink" title="Referencing already deployed Smart Contracts"></a>Referencing already deployed Smart Contracts</h2><p>Embark not only integrates with the Smart Contracts that we create and own, but also with Smart Contracts that are already deployed and potentially owned by third-parties. If we wish to reference such a Smart Contract instance, all we have to do is specify the <code>address</code> of the instance in question.</p>
 824  <p>The following example configures <code>UserStorage</code> to be a Smart Contract instance that’s already deployed:</p>
 825  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  UserStorage: &#123;</span><br><span class="line">    address: &#39;0x123456&#39;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 826  
 827  <h2 id="Using-accounts-in-arguments"><a href="#Using-accounts-in-arguments" class="headerlink" title="Using accounts in arguments"></a>Using accounts in arguments</h2><p>Accounts can be used as arguments using Embark’s built-in interpolation syntax, similar to referring to Smart Contract instances.</p>
 828  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">module.exports &#x3D; &#123;</span><br><span class="line">  development: &#123;</span><br><span class="line">    deploy: &#123;</span><br><span class="line">      MyContractThatNeedsAccountAddresses: &#123;</span><br><span class="line">        args: [&#39;$accounts[0]&#39;, &#39;$accounts[4]&#39;]</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 829  
 830  <h2 id="Dynamic-Addresses"><a href="#Dynamic-Addresses" class="headerlink" title="Dynamic Addresses"></a>Dynamic Addresses</h2><p>There are scenarios in which we want to configure a Smart Contract that is already deployed by a third-party, but its address can only be computed at run-time. For such cases, Embark supports specifying a function as <code>address</code>, which returns the address we’re interested in. Usually, other Smart Contract instances are needed to perform that computation, so the <a href="#Deployment-hooks"><code>deps</code> configuration</a> comes in handy as well:</p>
 831  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    fromIndex: 0,</span><br><span class="line">    args: [100],</span><br><span class="line">  &#125;,</span><br><span class="line">  OtherContract: &#123;</span><br><span class="line">    deps: [&#39;SimpleStorage&#39;],</span><br><span class="line">    address: async (deps) &#x3D;&gt; &#123;</span><br><span class="line">      &#x2F;&#x2F; use &#96;deps.contracts.SimpleStorage&#96; to determine and return address</span><br><span class="line">    &#125;,</span><br><span class="line">    abiDefinition: ABI</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 832  
 833  <p>In the example above, <code>OtherContract</code> will be deployed after <code>SimpleStorage</code> because it uses the <code>deps</code> property to define Smart Contracts that it depends on. All dependencies are exposed on the <code>address</code> function parameter similar to <a href="#Deployment-hooks">deployment hooks</a>. Also, notice that the <code>abiDefinition</code> is only needed if the Smart Contracts bytecode isn’t already on disk.</p>
 834  <h2 id="Configuring-source-files"><a href="#Configuring-source-files" class="headerlink" title="Configuring source files"></a>Configuring source files</h2><p>By default Embark will look for Smart Contracts inside the folder that’s configured in the application’s <a href="configuration.html#contracts">embark.json</a>, the default being the <code>contracts</code> folder. However, if we want to change the location to look for a single Smart Contract’s source, or need to compile a third-party Smart Contract to get hold of its ABI, we can do so by using the <code>file</code> property.</p>
 835  <p><code>file</code> specifies a full path to a file that contains the source code for the Smart Contract in question.</p>
 836  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    file: &#39;.&#x2F;some_folder&#x2F;simple_storage.sol&#39;,</span><br><span class="line">    args: [100]</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 837  
 838  <p>If Embark doesn’t find the file in the specified path, it’ll expect it to be a path inside installed <code>node_modules</code> dependencies. The following example configures a source file path that points to a third-party Smart Contract that is installed as a dependency:</p>
 839  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  ERC20: &#123;</span><br><span class="line">    file: &#39;openzeppelin-solidity&#x2F;contracts&#x2F;token&#x2F;ERC20&#x2F;ERC20.sol&#39;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 840  
 841  <p>Embark even supports reading the source from <code>https</code>, <code>git</code>, <code>ipfs</code> and <code>bzz</code> URIs, enabling us to compile Solidity Smart Contracts that aren’t even located in our local machine.</p>
 842  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  ERC725: &#123;</span><br><span class="line">    file: &#39;git:&#x2F;&#x2F;github.com&#x2F;status&#x2F;contracts&#x2F;contracts&#x2F;identity&#x2F;ERC725.sol#develop&#39;</span><br><span class="line">  &#125;,</span><br><span class="line">  ERC725: &#123;</span><br><span class="line">    file: &#39;github.com&#x2F;status&#x2F;contracts&#x2F;contracts&#x2F;identity&#x2F;ERC725.sol&#39;</span><br><span class="line">  &#125;,</span><br><span class="line">  Ownable: &#123;</span><br><span class="line">    file: &#39;https:&#x2F;&#x2F;github.com&#x2F;OpenZeppelin&#x2F;openzeppelin-solidity&#x2F;blob&#x2F;master&#x2F;contracts&#x2F;ownership&#x2F;Ownable.sol&#39;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 843  
 844  <h2 id="Providing-ABIs"><a href="#Providing-ABIs" class="headerlink" title="Providing ABIs"></a>Providing ABIs</h2><p>In order to use Smart Contract instances created by web3 either in <a href="Deployment-hooks">deployment hooks</a> or in <a href="contracts_javascript.html">Embark’s JavaScript client</a>, Embark needs to get hold of the Smart Contracts’ ABIs and pass those on to web3.</p>
 845  <p>This is not a problem when dealing with Smart Contracts that we own, or at least have <a href="#Configuring-source-files">access to their sources</a> so we Embark can compile them accordingly. However, if we don’t have either the source, nor do we want to create a Solidity interface ourselves for Embark to compile, we can provide an already defined ABI for a dedicated Smart Contract using the <code>abiDefinition</code> property, so Embark can make use of that.</p>
 846  <p>The following example configures <code>SimpleStorage</code> to be already deployed somewhere, but we’d still like to use the web3 instance in our <code>afterDeploy</code> hook.</p>
 847  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    address: &#39;0x0bFb07f9144729EEF54A9057Af0Fcf87aC7Cbba9&#39;,</span><br><span class="line">    abiDefinition: [...]</span><br><span class="line">  &#125;</span><br><span class="line">&#125;,</span><br><span class="line">afterDeploy: async (deps) &#x3D;&gt; &#123;</span><br><span class="line">  const value &#x3D; await deps.contracts.SimpleStorage.methods.get().call();</span><br><span class="line">  console.log(value);</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 848  
 849  <p><code>afterDeploy</code> and other deployment hooks are covered in <a href="#Deployment-hooks">Deployment Hooks</a>.</p>
 850  <h2 id="Providing-Artifacts"><a href="#Providing-Artifacts" class="headerlink" title="Providing Artifacts"></a>Providing Artifacts</h2><p>Similar to providing ABIs, providing an Embark artifact lets you configure your contract using an already generated artifact.</p>
 851  <p>That way, you don’t need to have the contract on disk or even deploy it, if the address is specified in it.</p>
 852  <p>Here is how you can do it:</p>
 853  <pre><code class="javascript">...
 854  deploy: {
 855    SimpleStorage: {
 856      artifact: './path/to/SimpleStorage.json'
 857    }
 858  }
 859  ...
 860  </code></pre>
 861  
 862  <h2 id="Proxy-Contract-Support"><a href="#Proxy-Contract-Support" class="headerlink" title="Proxy Contract Support"></a>Proxy Contract Support</h2><p>Proxy smart contracts are powerful tools usually used in more complex Dapps. They can be used for smart contracts that can be upgraded or to alleviate the deploy cost of multiple instances of a contract.</p>
 863  <p>However, interacting with Proxy contracts is usually difficult, because you have to point the Base contract to the address of the Proxy for it to work.</p>
 864  <p>Not anymore! Embark now supports a smart contract configuration named <code>proxyFor</code>.</p>
 865  <p>With it, you can specify that a Proxy smart contract is, well, a proxy <em>for</em> another one. Here’s an example:</p>
 866  <figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line">deploy: &#123;</span><br><span class="line">  <span class="built_in">Proxy</span>: &#123;</span><br><span class="line">    deploy: <span class="literal">false</span></span><br><span class="line">  &#125;,</span><br><span class="line">  BaseContract: &#123;</span><br><span class="line">    args: [<span class="string">"whatever the base contract needs"</span>]</span><br><span class="line">  &#125;,</span><br><span class="line">  ContractInstance: &#123;</span><br><span class="line">    instanceOf: <span class="string">"Proxy"</span>,</span><br><span class="line">    proxyFor: <span class="string">"BaseContract"</span>,</span><br><span class="line">    args: [<span class="string">"0x"</span>, <span class="string">"$BaseContract"</span>]</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 867  
 868  <p>With this configuration, our <code>ContractInstance</code> is an <code>instanceOf</code> <code>Proxy</code> and  a <code>proxyFor</code> <code>BaseContract</code>.<br>This is why we point to <code>BaseContract</code> in the <code>ContractInstance</code> arguments.<br>The arguments themselves depend on the implementations of your <code>BaseContract</code> and <code>Proxy</code> smart contracts.</p>
 869  <p>Note that you could have used <code>Proxy</code> itself as a <code>proxyFor</code> <code>BaseContract</code>, but it’s usually more intuitive to use <code>instanceOf</code> and then resolve the smart contract instance with the new name you gave it (<code>ContractInstance</code> in this case).</p>
 870  <p>Once the smart contracts are deployed, all you have to do is:</p>
 871  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">import ContractInstance from &#39;path&#x2F;to&#x2F;artifacts&#x2F;contracts&#x2F;ContractInstance&#39;;</span><br></pre></td></tr></table></figure>
 872  
 873  <p>Here is what it looked <strong>before</strong>:</p>
 874  <figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="keyword">import</span> BaseContract <span class="keyword">from</span> <span class="string">'path/to/artifacts/contracts/BaseContract'</span>;</span><br><span class="line"><span class="keyword">import</span> ContractProxy <span class="keyword">from</span> <span class="string">'path/to/artifacts/contracts/ContractProxy'</span>;</span><br><span class="line"></span><br><span class="line">BaseContract.options.address = ContractProxy.options.address;</span><br><span class="line"><span class="comment">// Then  you could actually interact with the BaseContract</span></span><br></pre></td></tr></table></figure>
 875  
 876  <p>Now, no need to import or use <code>BaseContract</code>, like above, since <code>ContractInstance</code> contains both the ABI of <code>BaseContract</code> and <code>Proxy</code>.</p>
 877  <h2 id="Deployment-tracking"><a href="#Deployment-tracking" class="headerlink" title="Deployment tracking"></a>Deployment tracking</h2><p>Embark’s Smart Contract deployment mechanism prevents the deployment of Smart Contracts that have already been deployed. This turns out to be a powerful feature as you don’t have to worry about keeping track of it. The way this works is that, by default, Embark creates a file <code>./.embark/chains.json</code> in which it stores the name and address of the deployed Smart Contracts. That information is then mapped to the hash of the block in which the Smart Contract have been deployed:</p>
 878  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  BLOCK_HASH &#123;</span><br><span class="line">    &quot;contracts&quot;: &#123;</span><br><span class="line">      HASH(NAME, BYTECODE, ARGS, ADDRESS): &#123;</span><br><span class="line">        &quot;name&quot;: NAME,</span><br><span class="line">        &quot;address: ADDRESS</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 879  
 880  <p>With concrete data, the contents of <code>chains.json</code> could look something like this:</p>
 881  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  &quot;0x6454b3e22cc9abe24bcd9f239687ad68ab6addb4f271a6b955f2e6111522310a&quot;: &#123;</span><br><span class="line">    &quot;contracts&quot;: &#123;</span><br><span class="line">      &quot;0x3043b04ad856d169c8f0b0509c0bc63192dc7edd92d6933c58708298a0e381be&quot;: &#123;</span><br><span class="line">        &quot;name&quot;: &quot;ENSRegistry&quot;,</span><br><span class="line">        &quot;address&quot;: &quot;0x4F75E2beCbD08c5dD67f74aA0E28558a6a596528&quot;</span><br><span class="line">      &#125;,</span><br><span class="line">      &quot;0xc51636fc4431a598f31d35de56a5e59b1a55d601babbdf5e9718a520654a4a93&quot;: &#123;</span><br><span class="line">        &quot;name&quot;: &quot;Resolver&quot;,</span><br><span class="line">        &quot;address&quot;: &quot;0xD9c5bEeD72A0f2FeAcF43730eF2B4bC86F38Cb6f&quot;</span><br><span class="line">      &#125;,</span><br><span class="line">      &quot;0x269ef61966bd985f10d8ae13d7eaa498b423372f266fb5c188f60fa5618ff334&quot;: &#123;</span><br><span class="line">        &quot;name&quot;: &quot;FIFSRegistrar&quot;,</span><br><span class="line">        &quot;address&quot;: &quot;0xe7120Bfe50b72a9629546dCe05c3821b3bb52B4E&quot;</span><br><span class="line">      &#125;,</span><br><span class="line">      &quot;0xc920172104d0372dfa1375d4c9ef05ae15569b94b88fd4b0d5a834965dc7420b&quot;: &#123;</span><br><span class="line">        &quot;name&quot;: &quot;SimpleStorage&quot;,</span><br><span class="line">        &quot;address&quot;: &quot;0x4928bFf909063465d3cc1708E5F9c6EB0E3F324E&quot;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 882  
 883  <h3 id="Disabling-tracking"><a href="#Disabling-tracking" class="headerlink" title="Disabling tracking"></a>Disabling tracking</h3><p>If we prefer to have full control over the deployment process and don’t want Embark to keep track of individual Smart Contract deployments, we use the <code>track</code> configuration and set it <code>false</code>.</p>
 884  <p>The following example ensures <code>ERC20</code> won’t be tracked and therefore redeployed in every deployment cycle.</p>
 885  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  ERC20: &#123;</span><br><span class="line">    track: false</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 886  
 887  <h3 id="Specifying-a-tracking-file"><a href="#Specifying-a-tracking-file" class="headerlink" title="Specifying a tracking file"></a>Specifying a tracking file</h3><p>In addition to enabling and disabling tracking, it’s also possible to tell Embark which file it should use for tracking. This can be useful for tracking deployed Smart Contracts on different platforms, such as testnets and the mainnet. The tracking state of those platforms should most likely be under version control, because we certainly don’t want multiple people to redeploy our Smart Contracts on multiple platforms. Putting those files under version control ensures everybody else gets the already tracked state. The contents will have the same schema as discussed above.</p>
 888  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">tracking: &#39;path&#x2F;to&#x2F;some&#x2F;file&#39;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 889  
 890  <p>Having the file referenced above under version control ensures that other users of our project don’t redeploy the Smart Contracts on different platforms.</p>
 891  <h3 id="Reducing-contract-size"><a href="#Reducing-contract-size" class="headerlink" title="Reducing contract size"></a>Reducing contract size</h3><p>To reduce the size of the contract JSON files that are included in the build directory, you can set <code>minimalContractSize</code> to <code>true</code>. It defaults to <code>false</code>.<br>When set to <code>true</code>, Embark will not put te bytecode, gas estimates and other big configurations in the JSON file.</p>
 892  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">minimalContractSize: true,</span><br></pre></td></tr></table></figure>
 893  
 894  <p>You can also have more control over the filtering by adding a <code>filteredFields</code> array. In the array, you can add the name of the fields you want to filter out.<br>This is useful for when you want to reduce the size of the contract files, but might still need a certain field, or if you want to filter even more aggressively.<br>Note that you need to have <code>minimalContractSize</code> set to <code>true</code>.</p>
 895  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">minimalContractSize: true,</span><br><span class="line">filteredFields: [&#39;runtimeBytecode&#39;, &#39;realRuntimeBytecode&#39;] &#x2F;&#x2F; This will filter out only runtimeBytecode and realRuntimeBytecode</span><br></pre></td></tr></table></figure>
 896  
 897  
 898  <h2 id="Deployment-hooks"><a href="#Deployment-hooks" class="headerlink" title="Deployment hooks"></a>Deployment hooks</h2><p>Sometimes we want to execute certain logic when Smart Contracts are being deployed or after all of them have been deployed. In other cases, we’d even like to control whether a Smart Contract should be deployed in the first place. For those scenarios, Embark lets us define the deployment hooks <code>beforeDeploy</code>, <code>deployIf</code>, <code>onDeploy</code> and <code>afterDeploy</code>.</p>
 899  <p>Deployment hooks have access to a <code>dependencies</code> object that comes with instances of all Smart Contracts that are defined as dependency of the hooks using the <code>deps</code> property of the Smart Contract in question, and the Smart Contract itself. In addition to all relevant Smart Contract instances, this object also exposes the current <code>web3</code> instance and a <code>logger</code> instance as shown in the examples below.</p>
 900  <h3 id="Conditional-Deployment-with-deployIf"><a href="#Conditional-Deployment-with-deployIf" class="headerlink" title="Conditional Deployment with deployIf"></a>Conditional Deployment with <code>deployIf</code></h3><p>We can specify a condition that decides whether a contract should be deployed by using the <code>deployIf</code> hook. <code>deployIf</code> is a function that either returns a promise or is created using <code>async/await</code> syntax and has to resolve to a boolean value. If the resolve value is <code>true</code>, the Smart Contract in question will be deployed. If it’s <code>false</code>, Embark will skip deploying the Smart Contract in question.</p>
 901  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  ERC20: &#123;</span><br><span class="line">    deployIf: async (&#123;contracts, web3, logger&#125;) &#x3D;&gt; &#123;</span><br><span class="line">      return await contracts.Manager.methods.isUpdateApproved().call();</span><br><span class="line">    &#125;,</span><br><span class="line">    deps: [&#39;Manager&#39;]</span><br><span class="line">  &#125;,</span><br><span class="line">  Manager: &#123;...&#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 902  
 903  <p>Notice how <code>contracts</code> gives access to the <code>Manager</code> contract instance. This however, is only possible because <code>Manager</code> has been defined as dependency of <code>ERC20</code> using the <code>deps</code> property.</p>
 904  <h3 id="beforeDeploy-hook"><a href="#beforeDeploy-hook" class="headerlink" title="beforeDeploy hook"></a><code>beforeDeploy</code> hook</h3><p><code>beforeDeploy</code> is a hook that, just like the name says, is executed before something is deployed. This hook is the counterparts to the <a href="#afterDeploy-hook">afterDeploy</a> and can be used in either individual Smart Contract configurations, or for all Smart Contracts. E.g. the following snippet configures <code>beforeDeploy</code> just for <code>SimpleStorage</code>:</p>
 905  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">SimpleStorage: &#123;</span><br><span class="line">  beforeDeploy: async () &#x3D;&gt; &#123;</span><br><span class="line">    console.log(&#39;before deploying SimpleStorage&#39;);</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 906  
 907  <p>Wheras this configuration here runs the hook before all Smart Contracts are being deployed:</p>
 908  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123; ... &#125;</span><br><span class="line">  beforeDeploy: async () &#x3D;&gt; &#123;</span><br><span class="line">    console.log(&#39;Before all deploy&#39;);</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 909  
 910  <h3 id="onDeploy-hook"><a href="#onDeploy-hook" class="headerlink" title="onDeploy hook"></a><code>onDeploy</code> hook</h3><p>We can specify the <code>onDeploy</code> hook to execute code, right after a contract has been deployed. Just like <code>deployIf</code> and <code>afterDeploy</code>, <code>onDeploy</code> is a function that has access to the Smart Contract’s dependencies defined in its <code>deps</code> property. The following example executes <code>SimpleStorage</code>‘s <code>set()</code> method, once deployed.</p>
 911  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    args: [100],</span><br><span class="line">    onDeploy: async (&#123;contracts, web3, logger&#125;) &#x3D;&gt; &#123;</span><br><span class="line">      await contracts.SimpleStorage.methods.set(150).send(&#123;from: web3.eth.defaultAccount&#125;);</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 912  
 913  <p>To actually <code>send</code> transactions and not just make <code>call</code>s, you will probably need to provide a <code>from</code> account. You can use the <code>web3</code> instance inside <code>dependencies</code> to get the <code>defaultAccount</code> as above.</p>
 914  <p>Also, as mentioned above, every deployment hook works with plain promises as well:</p>
 915  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">SimpleStorage: &#123;</span><br><span class="line">  args: [100],</span><br><span class="line">  onDeploy: (&#123;contracts, web3, logger&#125;) &#x3D;&gt; &#123;</span><br><span class="line">    return contracts.SimpleStorage.methods.set(150).send();</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 916  
 917  <h3 id="afterDeploy-hook"><a href="#afterDeploy-hook" class="headerlink" title="afterDeploy hook"></a><code>afterDeploy</code> hook</h3><p>If we want to execute code once all of our Smart Contracts have been deployed, Embark has got us covered with the <code>afterDeploy</code> hook. The same rules apply here. <code>afterDeploy</code> has access to all deployed contract instances through the <code>dependencies</code> object.</p>
 918  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    args: [100]</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;,</span><br><span class="line">afterDeploy: (&#123;contracts, web3, logger&#125;) &#x3D;&gt; &#123;</span><br><span class="line">  contracts.SimpleStorage.methods.set(150).send(&#123;from: web3.eth.defaultAccount&#125;);</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 919  
 920  <h3 id="Error-Handling"><a href="#Error-Handling" class="headerlink" title="Error Handling"></a>Error Handling</h3><p>Since we use functions for these deployment hooks, we have to manage errors ourselves. We skipped that step in the above examples to save space, but here is an easy example on how you can do it:</p>
 921  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">onDeploy: async (&#123;contracts, web3, logger&#125;) &#x3D;&gt; &#123;</span><br><span class="line">  try &#123;</span><br><span class="line">    await contracts.SimpleStorage.methods.set(85).send(&#123;from: web3.eth.defaultAccount&#125;);</span><br><span class="line">  &#125; catch (e) &#123;</span><br><span class="line">    console.error(&#39;Error during onDeploy&#39;, e);</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 922  
 923  <div class="c-notification c-notification--info">
 924    <p><strong>A note on deployment hook string syntax</strong></p>
 925    <p><p>In older versions of Embark, deployment hooks have been defined as an array of strings. This is due historical reasons where configuration files used to be JSON files that don’t support functions.</p>
 926  <p>The examples above can be therefore written as:</p>
 927  <pre class="highlight">afterDeploy: ['SimpleStorage.methods.set(150).send()']
 928  onDeploy: ['SimpleStorage.methods.set(150).send()']
 929  deployIf: 'await Manager.methods.isUpdateApproved()'
 930  </pre>
 931  
 932  <p>This string syntax is still supported, but will be deprecated and likely be removed in future versions of Embark.</p>
 933  </p>
 934  </div> 
 935  
 936  
 937  
 938  <h3 id="Logging-with-context"><a href="#Logging-with-context" class="headerlink" title="Logging with context"></a>Logging with context</h3><p>Often we use log statements to either debug code or simply to output what’s going on at the moment. It can be useful to output logs within deployment hooks as well. To make sure our deployment hooks don’t drown in the rest of Embark’s output, we can use the injected <code>logger</code> which prefixes every log message with a context indicator.</p>
 939  <p>For example, when logging something from within an <code>onDeploy</code> hook of a Smart Contract, the output will look like this:</p>
 940  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">SmartContractName &gt; onDeploy &gt; [YOUR MESSAGE]</span><br></pre></td></tr></table></figure>
 941  
 942  <p>The <code>logger</code> is injected as part of the <code>dependencies</code> object, so we can use it like this:</p>
 943  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    onDeploy: async (&#123;contracts, web3, logger&#125;) &#x3D;&gt; &#123;</span><br><span class="line">      logger.info(&#39;Hello from onDeploy!&#39;);</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
 944  
 945  <p>Which will result in</p>
 946  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">SimpleStorage &gt; onDeploy &gt; Hello from onDeploy!</span><br></pre></td></tr></table></figure>
 947  
 948  <h2 id="Human-readable-Ether-units"><a href="#Human-readable-Ether-units" class="headerlink" title="Human readable Ether units"></a>Human readable Ether units</h2><p>Embark supports human readable ether units in different places where Ether values can be configured. A human readable ether unit is the combination of any number value and any valid ether unit, such as <code>wei</code>, <code>kwei</code>, <code>Kwei</code>, <code>shannon</code>, <code>finney</code>, … etc.</p>
 949  <p>Let’s take the simple Smart Contract configuration from the <a href="#Configuring-gas-and-gas-price">configuring gas and gas price</a> section:</p>
 950  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    args: [100],</span><br><span class="line">    gas: 800000,</span><br><span class="line">    gasPrice: 5</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 951  
 952  <p>This can as well be written as:</p>
 953  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">...</span><br><span class="line">deploy: &#123;</span><br><span class="line">  SimpleStorage: &#123;</span><br><span class="line">    args: [100],</span><br><span class="line">    gas: &#39;800 Kwei&#39;,</span><br><span class="line">    gasPrice: 5</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
 954  
 955  <p>Embark will take care of converting those units to their dedicated Wei values.</p>
 956  
 957          </div>
 958          <div class="o-container-medium o-distance-l">
 959            <div class="o-flex o-flex-space-between">
 960    
 961    <div class="o-flex__item">
 962      <a href="/docs/javascript_usage.html" class="c-button c-button--quite" title="Previous article">Previous</a>
 963    </div>
 964    
 965    
 966    <div class="o-flex__item">
 967      <a href="/docs/contracts_deployment.html" class="c-button c-button--quite" title="Next article">Next</a>
 968    </div>
 969    
 970  </div>
 971  
 972  
 973          </div>
 974        </div>
 975        <div class="o-guided-content__addition">
 976          <h3 class="c-category-title">Contents</h3>
 977          <ol class="o-list-bare"><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Basic-Smart-Contract-Configuration" class="u-link-uniform">Basic Smart Contract Configuration</a><ol class="o-list-bare__child"><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Configuring-constructor-parameters" class="u-link-uniform">Configuring constructor parameters</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Configuring-gas-and-gas-price" class="u-link-uniform">Configuring gas and gas price</a></li></ol></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Configuring-Smart-Contract-Dependencies" class="u-link-uniform">Configuring Smart Contract Dependencies</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Disabling-deployment" class="u-link-uniform">Disabling deployment</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Defining-interfaces" class="u-link-uniform">Defining interfaces</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Deployment-strategies" class="u-link-uniform">Deployment strategies</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Deploying-multiple-instances" class="u-link-uniform">Deploying multiple instances</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Referencing-already-deployed-Smart-Contracts" class="u-link-uniform">Referencing already deployed Smart Contracts</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Using-accounts-in-arguments" class="u-link-uniform">Using accounts in arguments</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Dynamic-Addresses" class="u-link-uniform">Dynamic Addresses</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Configuring-source-files" class="u-link-uniform">Configuring source files</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Providing-ABIs" class="u-link-uniform">Providing ABIs</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Providing-Artifacts" class="u-link-uniform">Providing Artifacts</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Proxy-Contract-Support" class="u-link-uniform">Proxy Contract Support</a></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Deployment-tracking" class="u-link-uniform">Deployment tracking</a><ol class="o-list-bare__child"><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Disabling-tracking" class="u-link-uniform">Disabling tracking</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Specifying-a-tracking-file" class="u-link-uniform">Specifying a tracking file</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Reducing-contract-size" class="u-link-uniform">Reducing contract size</a></li></ol></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Deployment-hooks" class="u-link-uniform">Deployment hooks</a><ol class="o-list-bare__child"><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Conditional-Deployment-with-deployIf" class="u-link-uniform">Conditional Deployment with deployIf</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#beforeDeploy-hook" class="u-link-uniform">beforeDeploy hook</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#onDeploy-hook" class="u-link-uniform">onDeploy hook</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#afterDeploy-hook" class="u-link-uniform">afterDeploy hook</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Error-Handling" class="u-link-uniform">Error Handling</a></li><li class="o-list-bare__item o-list-bare-level-3 o-ellipsis"><a href="#Logging-with-context" class="u-link-uniform">Logging with context</a></li></ol></li><li class="o-list-bare__item o-list-bare-level-2 o-ellipsis"><a href="#Human-readable-Ether-units" class="u-link-uniform">Human readable Ether units</a></li></ol>
 978        </div>
 979      </div>
 980    </section>
 981  </main>
 982  
 983  <script src="/js/linkjuice/dist/linkjuice.min.js"></script>
 984  
 985      <footer role="contentinfo" class="c-footer o-distance-xxl">
 986    <div class="o-container">
 987      <div class="c-footer__top">
 988        <p class="c-category-title c-footer__top__title u-text-light">
 989          <a href="/" class="c-logo c-logo--negative" title="Embark">Embark</a>
 990        </p>
 991      </div>
 992      <div class="c-footer__body">
 993        <div class="o-grid">
 994          <div class="o-grid__column--1-1 o-grid__column--medium-1-2 o-grid__column--large-1-5">
 995            <p class="c-category-title u-text-light">Resources</p>
 996            <ul class="o-list-bare">
 997              <li class="o-list-bare__item">
 998                <a href="/docs/quick_start.html" class="u-link-ghost" title="Quick Start">Quick Start</a>
 999              </li>
1000              <li class="o-list-bare__item">
1001                <a href="/docs" class="u-link-ghost" title="Documentation">Documentation</a>
1002              </li>
1003              <li class="o-list-bare__item">
1004                <a href="https://blog.embarklabs.io" target="_blank" rel="noopener" class="u-link-ghost" title="Blog">Blog</a>
1005              </li>
1006              <li class="o-list-bare__item">
1007                <a href="/docs/faq.html" class="u-link-ghost" title="FAQ">FAQ</a>
1008              </li>
1009              <li class="o-list-bare__item">
1010                <a href="/docs/troubleshooting.html" class="u-link-ghost" title="Troubleshooting">Troubleshooting</a>
1011              </li>
1012            </ul>
1013          </div>
1014          <div class="o-grid__column--1-1 o-grid__column--medium-1-2 o-grid__column--large-1-5">
1015            <p class="c-category-title u-text-light">Help</p>
1016            <ul class="o-list-bare">
1017              <li class="o-list-bare__item">
1018                <a href="https://stackoverflow.com/questions/tagged/embark" target="_blank" rel="noopener" class="u-link-ghost" title="Embark Questions">Stack Overflow</a>
1019              </li>
1020              <li class="o-list-bare__item">
1021                <a href="https://gitter.im/embark-framework/Lobby" target="_blank" rel="noopener" class="u-link-ghost" title="Gitter">Gitter</a>
1022              </li>
1023              <li class="o-list-bare__item">
1024                <a href="https://github.com/embarklabs/embark/issues" target="_blank" rel="noopener" class="u-link-ghost" title="Report issues">Report issues</a>
1025              </li>
1026              <li class="o-list-bare__item">
1027                <a href="https://github.com/embarklabs/embark/blob/master/CODE_OF_CONDUCT.md" target="_blank" rel="noopener" class="u-link-ghost" title="Code of Conduct">Code of Conduct</a>
1028              </li>
1029            </ul>
1030          </div>
1031          <div class="o-grid__column--1-1 o-grid__column--medium-1-2 o-grid__column--large-1-5">
1032            <p class="c-category-title u-text-light">Community</p>
1033            <ul class="o-list-bare">
1034              <li class="o-list-bare__item">
1035                <a href="https://github.com/embarklabs" target="_blank" rel="noopener" class="u-link-ghost" title="Github">Github</a>
1036              </li>
1037              <li class="o-list-bare__item">
1038                <a href="https://twitter.com/EmbarkProject" target="_blank" rel="noopener" class="u-link-ghost" title="Twitter">Twitter</a>
1039              </li>
1040              <li class="o-list-bare__item">
1041                <a href="/docs/contributing.html" class="u-link-ghost" title="Contribute">Contribute</a>
1042              </li>
1043              <li class="o-list-bare__item">
1044                <a href="/community/#team" class="u-link-ghost" title="Team">Team</a>
1045              </li>
1046            </ul>
1047          </div>
1048  
1049          <div class="o-grid__column--1-1 o-grid__column--medium-1-2 o-grid__column--large-1-4">
1050            <p class="c-category-title u-text-light">The Status Network</p>
1051            <ul class="o-list-bare two-columns">
1052              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://status.im/" target="_blank">Status</a></li>
1053              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://keycard.tech/" target="_blank">Keycard</a></li>
1054              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://dap.ps/" target="_blank">dap.ps</a></li>
1055              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://teller.exchange/" target="_blank">Teller</a></li>
1056              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://assemble.fund/" target="_blank">Assemble</a></li>
1057              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://subspace.embarklabs.io/" target="_blank">Subspace</a></li>
1058              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://vac.dev/" target="_blank">Vac</a></li>
1059              <li class="o-list-bare__item"><a class="u-link-ghost" href="https://nimbus.team/" target="_blank">Nimbus</a></li>
1060            </ul>
1061          </div>
1062        </div>
1063      </div>
1064      <div class="c-footer__bottom">
1065        <p class="u-text-light">
1066          <a href="https://status.im/privacy-policy.html" title="Privacy Policy" target="_blank" class="u-text-light">Privacy Policy</a>
1067          / © 2019-2020 Embark
1068        </p>
1069      </div>
1070    </div>
1071  </footer>
1072  
1073  
1074  
1075  
1076      <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.4/highlight.min.js"></script>
1077      <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
1078      <script>
1079        const EMBARK_DOC_VERSIONS = {
1080          'latest': 'https://framework.embarklabs.io/docs','3.2': 'https://5ca4e0fdb29712000adde37f--embark-site-versions.netlify.com/docs/'
1081        };
1082      </script>
1083  
1084      
1085      <!-- Fathom - simple website analytics - https://github.com/usefathom/fathom -->
1086      <script>
1087      (function(f, a, t, h, o, m){
1088          a[h]=a[h]||function(){(a[h].q=a[h].q||[]).push(arguments)};
1089          o=f.createElement('script'),
1090          m=f.getElementsByTagName('script')[0];
1091          o.async=1; o.src=t; o.id='fathom-script';
1092          m.parentNode.insertBefore(o,m)
1093      })(document, window, '//fathom.status.im/tracker.js', 'fathom');
1094      fathom('set', 'siteId', 'YDUQQ');
1095      fathom('trackPageview');
1096      </script>
1097      <!-- / Fathom -->
1098      
1099  
1100      <script src="/js/index.js"></script>
1101  
1102      
1103      <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
1104      <script type="text/javascript">
1105        docsearch({
1106          apiKey: '439d8dc2add18007a2f31be4a9c0ed70',
1107          indexName: 'embark',
1108          inputSelector: '#search-input'
1109        });
1110      </script>
1111      
1112    </body>
1113  </html>
1114