Socket
Book a DemoInstallSign in
Socket

@aeternity/contract-builder

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aeternity/contract-builder

Sophia smart contracts builder

0.1.0
latest
Source
npmnpm
Version published
Weekly downloads
2
100%
Maintainers
5
Weekly downloads
 
Created
Source

@aeternity/contract-builder

npm npm

This package simplifies contract preparation to be used in production by providing:

  • a webpack loader to import .aes files directly to JavaScript modules;
  • a CLI tool called ae-contract-builder to be used if webpack is not available or not configurable.

Usage guide

Installation

Firstly, you need to add this package to your project

$ npm install @aeternity/contract-builder --save-dev

To use aesophia_cli (enabled by default), escript needs to be available in PATH.

Setup as a webpack loader

Add the loader to your webpack config. For example:

webpack.config.js

module.exports = {
  module: {
    rules: [{
+      test: /\.aes$/,
+      use: [{
+        loader: `@aeternity/contract-builder`,
+        options: {
+          compilerType: 'http', // or 'cli'
+          compilerPath: './foo/aesophia_cli',
+          compilerUrl: 'http://localhost:3080/',
+          // the above is optional, uses CLI compiler by default
+        },
      }],
    }],
  },
};

And run webpack via your preferred method.

Use as a separate tool

To build a smart contract into JavaScript module use

$ npx ae-contract-builder <path-to-contract-source.aes>

Also, you can add --watch flag to watch for smart contract changes, specify multiple contracts one by one, or add this script to package.json.

The output file will be located in the same directory with .js extension instead of .aes.

Output format

In both cases, you would get a Contract's child class with inlined ACI and compiled bytecode. It can be used the same as Contract class but not needed to provide aci, bytecode, or sourceCode.

import MyContract from './MyContract.aes';
// or import MyContract.js in case using ae-contract-builder

const myContract = await MyContract.initialize(aeSdk._getOptions());
await myContract.$deploy()
await myContract.foo('arg1', 'arg2')

Examples

Changelog

We keep our Changelog up to date.

Keywords

aeternity

FAQs

Package last updated on 08 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.