Skip to content

Instantly share code, notes, and snippets.

@databu
Last active April 25, 2019 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save databu/9a7642177a9e0465391cc7a756ca314f to your computer and use it in GitHub Desktop.
Save databu/9a7642177a9e0465391cc7a756ca314f to your computer and use it in GitHub Desktop.
Install AE CLI tools and Forgae on Ubuntu

Setting up AE CLI and forgae:

Install Ubuntu >= 18.04 LTS

  • Native or
  • Windows 10 Ubuntu subsystem or
  • Use vagrant:
    1. Download and install https://virtualbox.org and https://vagrantup.com,
    2. Execute in a directory where the vagrant should be stored:
      1. Initialise the vagrant:
        • Use forgae.box with everything pre-installed:
          • Copy forgae.box to the directory, then vagrant init forgae.box, or
          • vagrant init utu/forgae which downloads the box from vagrantup.com, or
        • Use generic Ubuntu 18 box: vagrant init ubuntu/bionic64
      2. vagrant up
      3. vagrant ssh
      4. If forgae.box or utu/forgae was used, skip the rest of this section and continue with Create a Wallet.

Prerequisites within Ubuntu:

  1. Execute sudo apt update
  2. Install
    1. git: apt install git
    2. node.js and npm: apt install npm

Install the AE JS Command Line Tools:

  1. git clone https://github.com/aeternity/aepp-cli-js.git
  2. cd aepp-cli-js
  3. sudo npm link

Install forgae and init test project:

  1. npm i -g forgae
  2. Create and initialise a project:
    1. mkdir aepp1; cd aepp1
    2. forgae init
  3. See also https://dev.aepps.com/tutorials/smart-contract-deployment-in-forgae.html

Create a Wallet

Execute all of the following inside the vagrant. We will use a wallet, also known as "account", called "a1". Note that this is just a local name, you can name it whatever you want.

Also note that we're using the testnet (-u https://sdk-testnet.aepps.com); there's also a docker compose configuration file in the initialised forgae project (aepp1) which can be used to run a local test net with 3 nodes. Docker and docker-compose are installed in the pre-built box (forgae.box), but the vagrant's configuration might need to be changed to have more memory available for this.

Create the wallet/account file:

aecli account -u https://sdk-testnet.aepps.com create a1  
(Set a password or just press enter)  
=>  
Address___ak…  
Path______/home/vagrant/a1

Check balance:

aecli account -u https://sdk-testnet.aepps.com balance a1  
=>  
API ERROR:  Account not found

Get some tokens:

  1. Open https://testnet.faucet.aepps.com
  2. Copy-paste your wallet address above
  3. Wait for tx…

Check balance again:

aecli account -u https://sdk-testnet.aepps.com balance a1  
=>  
Balance___5000000000000000000  
ID________ ak_…  
Nonce____1

Extract your privste key in hex format:

aecli account address a1 --privateKey  
(Enter password + confirm)  
=>  
Secret Key_____…

Compile and deploy smart contracts with forgae

From the forgae project readme:

ForgAE is an aeternity framework which helps with setting up a project. The framework makes the development of smart contracts in the aeternity network pretty easy. It provides commands for compilation, deployment of smart contracts, running a local node and unit testing the contracts.

We will use it for those purposes, but note that smart contract compilation, deployment and calling can also be done using just the command line tools (aecli). To find out more, use

  • aecli -h,
  • aecli <command> -h,
  • etc.

Execute the following commands inside the forgae project folder (aepp1). Contracts are in the "contracts" subdirectory. The compile and deploy commands process all contracts present in that directory.

Compile contracts

Compilation of a contract connects to an AE node to compile the contract and obtain the byte code, but it will not be deployed yet. The bytecode is what will actually be deployed on the chain.

Compilation is mainly useful for

  • testing whether a contract compiles correctly, or if not, get the compiler errors, and for
  • confirming that a given source code compiles to a given byte code, e.g. to verify that a deployed contract matches a given source code.
forgae compile -n testnet  
===== Compiling contracts =====  
  
Contract '/home/vagrant/aepp1/contracts/HelloWorld.aes has been successfully compiled'  
Contract bytecode: cb_…  

Deploy

If the contract compiles correctly, it can be deployed:

forgae deploy -n testnet -s <secretKey>
===== Contract: ExampleContract.aes has been deployed =====
Your deployment script finished successfully!

Start working on the aepp

To start development on your aepp proper in Javascript, refer to the forgae documentation.

More info

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment