All pages
Powered by GitBook
1 of 10

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Upcoming Version Support

Aeproject can already be used for testing and setup with the upcoming node versions.

Automatic update

Use aeproject init --next to initialize a new project that has the necessary adjustments to use the latest versions.

Use aeproject init --update --next to update an existing project with the adjustments to use the latest versions.

Manual update

  • change occurrences of utils.getSdk() to use utils.getSdk({ ignoreVersion: true }) if needed or use the same option for manually initialized sdk Node and CompilerHttp

  • update docker-compose.yml to use the latest node and compiler tags or specify it manually in running with aeproject env --nodeVersion latest --compilerVersion latest

docs

Local Environment

The command is responsible for setting up a healthy local environment. The env command helps developers run a local node and a local compiler in dev-mode using docker. To spawn a fully functional environment it can take a couple of minutes depending on your system.

If using Windows, WSL 2 needs to be used for AEproject to work normally, see https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers

You can stop both the node and the compiler by running

There are optional parameters --nodeVersion and --compilerVersion. To specify a specific version of node or compiler, or both

This also applies to the commands aeproject node and aeproject compiler.

To see whether you have running instances of the nodes along with a compiler you could run the following command

Note: By default AEproject uses the latest-bundle tag of the official docker images.

Compatibility:

  • the sdk from @aeternity/aepp-sdk@14 >= v14.0.0 is compatible with NODE_TAG >= v7.1.0 and COMPILER_TAG >= v8.0.0

  • due to a bug in the devmode plugin, NODE_TAG = v7.1.0 is not compatible with aeproject

Disclaimer

  • Firewalls and any other security feature can block your docker/docker-compose requests. Please check that docker/docker-compose is NOT in its blocked list or has permission to make requests.

aeproject env
aeproject env --stop
aeproject env --nodeVersion v7.2.0
# or
aeproject env --compilerVersion v8.0.0
# or
aeproject env --nodeVersion v7.2.0 --compilerVersion v8.0.0
aeproject env --info

Quick Start

Requirements

In order to have AEproject working you must have installed the following:

Note: on windows WSL 2 must be used

Install

Init a project

This will create the project scaffold with an example contract including tests as well as a sample deployment script inside the specified folder. If no folder is specified the artifacts will be initialized in the current directory.

Further explained in .

Running a local environment

This will run a local æternity network in dev-mode (node, compiler and nginx-proxy).

To stop an already spawned local environment use aeproject env --stop

Further explained in .

Testing

This will run the tests located in ./test folder. Further explained in .

Help

Run this command to give you all possible commands of aeproject with help and info

Version

Running this command will give you the current installed aeproject version

Migration from 4.x.x to 5.x.x

AEproject v5.0.0 underwent some breaking changes.

Install the latest AEproject version

Various Changes

  • dropped commonjs support, newly created projects will be created as esm projects, old cjs projects will not continue to work with newer aeproject versions, to keep using old cjs projects,

AEproject Library

Installed automatically with each project initialized with aeproject init, otherwise can be installed using npm i @aeternity/aeproject.

Available imports include helper definitions and utils using:

Utils

Read the contract source from given path, just a wrapper for fs.readFileSync using utf-8 encoding.

nodejs >= 18
docker
npm install -g @aeternity/aeproject
Initialization Documentation
Environment Documentation
Testing Documentation
@aeternity/aeproject@4
will continue to work for now.
  • node@16 is no longer supported, please update to v18 or higher

  • updated to @aeternity/aepp-sdk@14 to the latest version, see the migration guide for additional reference.

    • the aeproject provided utils.getSdk({}) has to be adjusted to pass a reference to the sdk used utils.getSdk(AeppSdk, {}) where AeppSdk can be imported using import * as AeppSdk from "@aeternity/aepp-sdk";

    • @aeternity/aepp-sdk@14 requires aeternity node version >= 7.1.0

  • Removed from libs

    Following utils have been removed and cannot be used anymore:

    • utils.getFilesystem() discontinued, as it is now natively available in the sdk via import, e.g. const { getFileSystem } = require("@aeternity/aepp-sdk");

    Initialize the æternity SDK, pre-configured for optimal use in an AEproject project using æternity node devmode.

    Create and wait for n number of key-blocks with the æternity node devmode, checked using the passed aeSdk.

    Create a snapshot of the current chain state using the æternity node devmode, using the passed aeSdk.

    Rollback to the latest snapshot using the æternity node devmode, using the passed aeSdk.

    Rollback to the specified height using the æternity node devmode, using the passed aeSdk.

    Get the pre-funded default accounts as MemoryAccount, so they can be used natively using the aeSdk.

    Wallets

    List of configured keypairs that are pre-funded using the æternity node devmode as provided in AEproject.

    Networks

    Exposed URLs for commonly used nodeUrl and compilerUrl, per default local devmode and optionally hosted URLs for mainnet and testnet.

    const { utils, wallets, networks } = require("@aeternity/aeproject");
    aeproject init [folder]
    aeproject env
    aeproject test
    aeproject help
    aeproject --version
    npm install -g @aeternity/aeproject
    utils.getContractContent(contractPath);
    import * as AeppSdk from "@aeternity/aepp-sdk";
    utils.getSdk(AeppSdk, {});
    utils.awaitKeyBlocks(aeSdk, n);
    utils.createSnapshot(aeSdk);
    utils.rollbackSnapshot(aeSdk);
    utils.rollbackHeight(aeSdk, height);
    utils.getDefaultAccounts();

    Migration from 3.x.x to 4.x.x

    Changes

    AEproject v4.0.0 underwent some bigger changes, is now available as official package of the æternity organization on NPM and is compatible to the recently published node .

    Install the new AEproject version

    Removed commands

    Following commands have been removed and cannot be used anymore. Most of them didn't work properly or aren't used by anyone:

    • aeproject compatibility (discontinued)

    • aeproject compile

      • manual compilation isn't needed for use of aeproject, alternatively use the CLI or the SDK programmatically

    • aeproject deploy

      • deployment isn't supported in aeproject anymore, alternatively use the or the programmatically

    • aeproject export (discontinued)

    • aeproject tx-inspector

      • manual tx inspection is moved to the

    Updated commands

    • aeproject init

      • added the folder argument to create a new folder for the project initialization

    Project structure

    The latest available node and compiler will always be used with starting the testing environment.

    Testing is now handled locally in the project using mocha and chai as direct dev dependencies.

    @aeternity/aeproject is added itself as dependency and includes some library-functions that can be used in testing.

    • networks includes network definitions for local development, testnet and mainnet

    • wallets includes example wallets that are prefunded in local development

    • utils includes helper functions for testing

      • getFilesystem(source) to get the filesystem definition for a given contract for deployment

      • getSdk() get an instance of the SDK for local development

        • initialized with all prefunded wallets for onAccount to be used calling from different accounts

      • awaitKeyBlocks(aeSdk, number) await a certain number of key-blocks

      • createSnapshot(aeSdk) create a snapshot for local testing

      • rollbackSnapshot(aeSdk) rollback to previously created snapshot in local testing

    Instructions

    1. Upgrade your project

      • adds new files needed

        • including new example contract and tests

      • prompts for files to replaced

        • docker setup for the node, compiler dev-mode setup should be accepted

        • example contract and example tests should not be accepted if used in your project for testing

      • automatically installs needed dependencies and removes unnecessary ones

    2. Adapt Testing Setup (compare your tests with test/exampleTest.js) to

      • include const { assert } = require('chai'); for assertions

      • replace NETWORKS import with const { networks } = require('@aeternity/aeproject'); for networks definition

    v6.4.0

    Project Initialization

    Optionally a folder can be specified for the project to be initialized in, otherwise the current directory is used.

    Creates a new project structure with a few folders in which the developer can create contracts and tests, as well as installing needed dependencies.

    Update existing project

    For upgrade from old AEproject versions check out and .

    Updates the project structure and needed artifacts to the latest version, as well as installing needed dependencies.

    aeproject init --update
    npm install -g @aeternity/aeproject
    const { networks, utils, wallets } = require("@aeternity/aeproject");
  • local testing network is now devmode instead of local

  • replace defaultWallets import with const { wallets } = require('@aeternity/aeproject'); for prefunded wallets

  • replace contractUtils import with const { utils } = require('@aeternity/aeproject'); for utils

    • consider using the new helpers for initializing an instance of the SDK and creating snapshots similar to test/exampleTest.js

  • CLI
    SDK
    CLI

    cli

    Upcoming Hard-fork initialization

    The additional parameter --next can be used to either initialize or update a project with changes for an upcoming hard-fork if available.

    aeproject init [folder]
    aeproject init --update
    Migration from 3.x.x to 4.x.x
    Migration from 4.x.x to 5.x.x

    Unit Testing

    Run unit tests

    The test command helps developers run their unit tests for æternity projects. The command executes the tests scripts that are located in the test folder of your æternity project.

    Implement unit tests

    In the test/exampleTest.js file you can find an example for unit testing using AEproject.

    1. Dependencies

    Javascript testing framework used with for assertions, documented at https://www.chaijs.com/api/assert/

    Helper and utilities for AEproject use, e.g. prefunded wallets, network definition and utility functions for SDK initialization and snapshotting.

    Read for a more detailed explanation about the usage of these imports.

    2. SDK and Snapshotting Setup

    Provide your initializations in mocha which need to be done once before all tests:

    Initialize the default SDK instance with provided utils:

    Get the filesystem definition for (custom) includes of the given contract:

    Read the contract source from the filesystem:

    Initialize the contract instance:

    Deploy the contract:

    Create a snapshot of the chain state once before all tests. This allows you to rollback to a clean state after each test if needed:

    Rollback to the previously created snapshot after each test for a clean state in the following tests:

    3. Example Test

    Use mocha for test setup and chai for assert. Then implement contract usage using the aeternity sdk as explained in the guide at https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/guides/contracts.md#5-call-contract-entrypoints

    aeproject test
    mocha
    AEproject Library
    import { assert } from "chai";
    import { before, describe, afterEach, it } from "mocha";
    import { utils } from "@aeternity/aeproject";
    import * as AeppSdk from "@aeternity/aepp-sdk";
    import { Contract, getFileSystem } from "@aeternity/aepp-sdk";
    before(async () => ...)
    aeSdk = utils.getSdk(AeppSdk, {});
    const fileSystem = await getFileSystem(EXAMPLE_CONTRACT_SOURCE);
    const sourceCode = utils.getContractContent(EXAMPLE_CONTRACT_SOURCE);
    contract = await Contract.initialize({ ...aeSdk.getContext(), sourceCode, fileSystem });
    await contract.init();
    await utils.createSnapshot(aeSdk);
    afterEach(async () => {
      await utils.rollbackSnapshot(aeSdk);
    });
    it("ExampleContract: set and get", async () => {
      const set = await contract.set(42, {
        onAccount: utils.getDefaultAccounts()[1],
      });
      assert.equal(set.decodedEvents[0].name, "SetXEvent");
      assert.equal(
        set.decodedEvents[0].args[0],
        utils.getDefaultAccounts()[1].address,
      );
      assert.equal(set.decodedEvents[0].args[1], 42);
    
      const { decodedResult } = await contract.get();
      assert.equal(decodedResult, 42);
    });