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

You can install using cli. For windows user, you can use git bash for cli environment.
> apm install athena-ide-atom
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.
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.
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

Click an add file button on popup

Select keystore file

Enter password to decrypt keystore

Account imported

Wallet Import Format¶
Click an import button

Enter wallet import format & password to decrypt it

Account imported

Export¶
You can export account with an aergo specific keystore format or wallet import format. For details of keystore format, see aergo keystore proposal.
Wallet Import Format¶
Click an export button

Enter a password to encrypt

You can see wallet import format in a console

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.
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
...

With args¶
You can deploy contract with constructor arguments.
-- arguments (key, value)
function constructor(key, value)
system.setItem(key, value)
end
...

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

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)

Import & Remove¶
Import¶
You can import already deployed contract.
Type contract address & click import button

Contract imported

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)

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)

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

Amount¶
You can execute contract with aergo token. Make sure function is registered as payable.
...
function run()
end
...
-- registered as payable
abi.payable(run)

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)

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)


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)


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)
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.
