Welcome

Welcome to the athena ide atom wiki. This is an IDE (Integrated Development Environment) for aergo smart contract. It can compile, deploy and execute smart contract with an account. It also can create, import and export account.

Getting Started

Install

Athena ide atom is based on atom. You have to install it first.

By apm

Athena ide atom is available in apm (atom package manager). You can install with it.

Atom -> Preferences -> Install

_images/install-by-ui.png

You can install using cli. For windows user, you can use git bash for cli environment.

> apm install athena-ide-atom

By installer

Installing with apm may be slow on slow network status. So we provide custom installer in releases. Download athena-ide-atom-x.x.x-installer.bin from releases and run in cli. For windows user, you can use git bash for cli environment.

> ./athena-ide-atom-x.x.x-installer.bin

Open

Using shortcut

  • Mac : Option + Shirt + L
  • Windows : Alt + Shirt + L
_images/opened.png

Using menu bar

Packages -> Athena IDE -> Open Athena IDE Panel

_images/open-with-menubar.png

Auto Complete

Athena ide atom provides some basic autocomplete for lua.

_images/autocomplete.png

Lint

Athena ide atom provides basic lint for lua.

_images/lint.png

Node

You can configure an aergo node whose smart contract interacting with. You can see height and gas price of it. Default configuration is localhost:7845.

New

Click an new button

_images/new-node-1.png

Enter node endpoint and click ok

_images/new-node-2.png

You can see height and gas price of it

_images/new-node-3.png

Remove

Click a remove button

_images/remove-node-1.png

Click ok button

_images/remove-node-2.png

Node removed from list

_images/remove-node-3.png

Account

You can configure an account which is deploying, executing and querying smart contract. An account have to have some aergo token to make transaction.

New

Click an new button

_images/new-account-1.png

Click a ok button

_images/new-account-2.png

Account created

_images/new-account-3.png

Import

You can import account with an aergo specific keystore format or wallet import format. For details of keystore format, see aergo keystore proposal.

KeyStore

Click an import button

_images/import-account-keystore-1.png

Click an add file button on popup

_images/import-account-keystore-2.png

Select keystore file

_images/import-account-keystore-3.png

Enter password to decrypt keystore

_images/import-account-keystore-4.png

Account imported

_images/import-account-keystore-5.png

Wallet Import Format

Click an import button

_images/import-account-wif-1.png

Enter wallet import format & password to decrypt it

_images/import-account-wif-2.png

Account imported

_images/import-account-wif-3.png

Export

You can export account with an aergo specific keystore format or wallet import format. For details of keystore format, see aergo keystore proposal.

KeyStore

Click an export button

_images/export-account-keystore-1.png

Enter a password to encrypt

_images/export-account-keystore-2.png

Choose save location

_images/export-account-keystore-3.png

Wallet Import Format

Click an export button

_images/export-account-wif-1.png

Enter a password to encrypt

_images/export-account-wif-2.png

You can see wallet import format in a console

_images/export-account-wif-3.png

Remove

Click an remove button

_images/remove-account-1.png

Click a ok button

_images/remove-account-2.png

Account removed from list

_images/remove-account-3.png

Contract

You can deploy/execute/query smart contract. Deploying and executing is done by making transaction. Make sure that you have enough aergo token to make transaction before deploying and executing contract.

Compile

Before deploying contract, you have to compile by clicking compile button or pressing F7.

_images/compile-contract-before.png _images/compile-contract-after.png

Deploy

After compiling contract, you can deploy contract.

Without args

You can deploy contract without constructor arguments.

-- no arguments
function constructor()
  system.setItem("k1", "v1")
end

...
_images/deploy-without-args.png

With args

You can deploy contract with constructor arguments.

-- arguments (key, value)
function constructor(key, value)
  system.setItem(key, value)
end

...
_images/deploy-with-args.png

Gas limit

You can deploy contract with gas limit configuration. 0 limit means infinite (uses as much as possible).

_images/deploy-with-gas-limit.png

Amount

You can deploy contract with aergo token. Make sure constructor is registered as payable.

function constructor()
  system.setItem("k1", "v1")
end

...

-- registered as payable
abi.payable(constructor)
_images/deploy-with-amount.png

Import & Remove

Import

You can import already deployed contract.

Type contract address & click import button

_images/import-contract-enter.png

Contract imported

_images/import-contract-result.png

Remove

You can remove contract.

Click trash button

_images/remove-contract-before.png

Contract removed

_images/remove-contract-after.png

Execute

Contract execution can change status of contract state db. Any function registered as register can be executed.

Without args

You can execute contract without arguments.

...

-- no arguments
function setDefault()
  system.setItem("k1", "v1")
end

...

-- register as execution
abi.register(setDefault)
_images/execute-without-args.png

With args

You can execute contract with arguments.

...

-- arguments (key, value)
function set(key, value)
  system.setItem(key, value)
end

...

-- register as execution
abi.register(set)
_images/execute-with-args.png

Gas limit

You can execute contract with configuring gas limit. 0 limit means infinite (uses as much as possible).

_images/execute-with-gas-limit.png

Amount

You can execute contract with aergo token. Make sure function is registered as payable.

...

function run()
end

...

-- registered as payable
abi.payable(run)
_images/execute-with-amount.png

Fee delegation

You can execute contract with fee delegation. When contract is executed with fee delegation, the contract pays fee on behalf of contract executor. Make sure function is registered as fee_delegation and a contract has enough aergo token.

...

function run()
end

-- registered as fee delegation
abi.fee_delegation(run)

-- register as execution
abi.register(run)
_images/execute-with-fee-delegation.png

Query

Contract query can check status of contract state db. Any function registered in register_view can be invoked as query.

Without args

You can query contract status without arguments.

...

-- no arguments
function getDefault()
  return system.getItem("k1")
end

-- registered as register_view
abi.register_view(getDefault)
_images/query-without-args.png _images/query-result.png

With args

You can query contract status with arguments.

...

-- arguments (key)
function get(key)
  return system.getItem(key)
end

-- registered as register_view
abi.register_view(get)
_images/query-with-args.png _images/query-result.png

Varargs

Lua supports varargs. The varargs is denoted by … in argument.

...

-- ... : varargs
function set(key, ...)
  local s = ""
  for i,v in ipairs{...} do
    s = s .. v
  end
  system.setItem(key, s)
end

...

abi.register(set)

Add

Click + button

_images/varargs-add-before.png

Argument added

_images/varargs-add-after.png

Remove

Click - button

_images/varargs-remove-before.png

Argument removed

_images/varargs-remove-after.png

Redeploy (private mode only)

You can redeploy already deployed contract. This is supported in a private mode only. Make sure redeployer account is deployer of already deployed one.

To redeploy contract, select deployed contract and click deploy button.

_images/redeploy-contract-selected.png