As we know, AOS was developed based on EOSIO, so all the EOSIO documents and usage, are worked for AOS. Developers can refer to https://developers.eos.io/ for more information and details.
1. Basic
1.1 Install AOSIO
Clone source code of the aosio/aos repository.
git clone — recursive https://github.com/aosio/aos
cd aos
Build:
./script/aosio_build.sh
Install:
sudo ./script/aosio_install.sh
1.2 Install CDT
Clone source code of the aosio.cdt repository.
git clone — recursive https://github.com/aosio/aosio.cdt
cd aosio.cdt
Build:
./script/aosio_build.sh
Install:
sudo ./script/aosio_install.sh
1.3 Create development wallet
1.3.1 Create a wallet:
claos wallet create — to-console
It will return a password, save this password somewhere as you will likely need it later in the tutorial.
1.3.2 Open the wallet
Wallets are closed by default when starting a kaosd instance, to begin, run the following:
claos wallet open
Run the following to return a list of wallets.
claos wallet list
1.3.3 Unlock it
The kaosd wallet(s) have been opened, but is still locked. Moments ago you were provided a password, you’re going to need that now.
claos wallet unlock
You will be prompted for your password, paste it and press enter.
1.3.4 Import keys into your wallet
Generate a private key, claos has a helper function for this, just run the following.
claos wallet create_key
It will generate a new private key with a public key.
claos wallet import
You’ll be prompted for a private key, enter the aosio development key provided earlier.
1.4 Start kaosd and nodaos
1.4.1 Start kaosd
kaosd &
1.4.2 Start nodaos
nodaos -e -p aosio \
— plugin eosio::producer_plugin \
— plugin eosio::producer_api_plugin \
— plugin eosio::chain_api_plugin \
— plugin eosio::http_plugin \
— plugin eosio::history_plugin \
— plugin eosio::history_api_plugin \
— filter-on=”*” \
— access-control-allow-origin=’*’ \
— contracts-console \
— http-validate-host=false \
— verbose-http-errors >> nodaos.log 2>&1 &
1.4.3 Check the installation
Check that nodaos is producing blocks
curl http://localhost:8888/v1/chain/get_info
You can check to see if the height is same.
1.5 Create test accounts
Using aosio to create two test accounts, alice and bob.
claos create account aosio alice
claos create account aosio bob
1.6 Compile contracts
For example, if your contract code file is hello.cpp, then compile your code to wasm as fellows:
eosio-cpp hello.cpp -o hello.wasm
1.7 Deploy contracts
For example, you try deploy your hello contract into alice account, as fellows:
claos set contract alice CONTRACTS_DIR/hello -p alice@active
1.8 Execute the contract
claos push action alice hi ‘[“bob”]’ -p alice@active
1.9 Add inline actions
In order for the inline actions to be available, add the aosio.code permission to the contract’s account’s active permission.
claos set account permission alice active — add-code
2. Advanced
Besides EOSIO related features, AOSIO provide multiple intrinsics that developers can use to make powerful cryptographic DAPPs.
2.1 assert_cipher_equal_prove
This intrinsic provide cipher equality prove. It checkes if cipher_balance equal provided eq_para and public key.
Include:
#include <eosio/crypto.hpp>
Prototype:
void assert_cipher_equal_prove(const char* cipher_balance, size_t cb_len, const char* eq_para, size_t eq_len, const char* pub_para, size_t pp_len);
Parameters:
cipher_balance: cipher balance of original value
cb_len: length of cipher_balance
eq_para: equality parameter, cipher balance of value
eq_len: length of eq_para
pub_para: public key of sender
pp_len: length of pub_para
2.2 assert_cipher_valid_prove
This intrinsic provide cipher valid prove, it verify account’s public key and bulletproofs.
Include:
#include <eosio/crypto.hpp>
Prototype:
void assert_cipher_valid_prove(const char* prove_para, size_t pv_len, const char* pub_para, size_t pp_len);
Paramters:
prove_para: prove parameter
pv_len: length of prove_para
pub_para: public key parameter
pp_len: length of pub_para
2.3 assert_cipher_ecdsa_signature
This intrinsic provide verifying ECDSA signature.
Include:
#include <eosio/crypto.hpp>
Prototype:
void assert_cipher_ecdsa_signature(const char* eq_para, size_t eq_len, const char* from_pub_para, size_t fp_len, const char* to_pub_para, size_t tp_len, const char* sig, size_t sig_len);
Parameters:
eq_para: equality of prove paramter
eq_len: length of eq_para
from_pub_para: from account public key parameter
fp_len: length of from_pub_para
to_pub_para: to account public key parameter
tp_len: length of to_pub_para
sig: signature of the data
sig_len: length of sig
2.4 assert_cipher_encrypt
This intrinsic provide verify cipher encrypt function. It checkes if ciphertext matches encrypt(pubkey, value, random).
Include:
#include <eosio/crypto.hpp>
Prototype:
void assert_cipher_encrypt(const char* random, size_t rand_len, unsigned int value, const char* pub_para, size_t pp_len, const char* ciphertext, size_t ct_len);
Parameters:
random: random number
rand_len: length of random
value: a number that need to be encrypted
pub_para: public key
pp_len: length of pub_para
ciphertext:cipher text
ct_len: length of ciphertext
2.5 cipher_add
This intrinsic provide cipher add function.
Include:
#include <eosio/crypto.hpp>
Prototype:
eosio::cipher128 cipher_add(const char* cipher1, size_t len1, const char* cipher2, size_t len2);
Parameters:
eosio::cipher128: a 128 char array
cipher1: first cipher string
len1: length of cipher1
cipher2: second cipher string
len2: length of cipher2
2.6 get_permission_key
This intrinsic get account’s related public key.
Include:
#include <eosio/permission.hpp>
Prototype:
int get_permission_key(name account, name permission, char* pub, size_t publen)
Parameters:
account: account
permission: permission type of account, i.e, “active”or “owner”
pub: output char array
publen: length of pub
2.7 prove_bulletproof
This intrinsic generate a bulletproof for a value.
Include:
#include <eosio/crypto.hpp>
Prototype:
void prove_bulletproof( uint64_t value, const unsigned char* blind, size_t blindlen, unsigned char* proof, size_t plen)
get_permission_key
get_permission_key
get_permission_key
get_permission_key
Parameters:
value: a unsigned int64
blind: a 32-byte unsigned char array, random number
blindlen: length of blind, should be 32
proof: output of bulletproof, 675-byte unsigned char array
plen: length of proof, should be 675
2.8 assert_verify_bulletproof
This intrinsic verify proof, if proof verified succeed, it pass, otherwise, it panic.
Include:
#include <eosio/crypto.hpp>
Prototype:
void assert_verify_bulletproof(const unsigned char* commit, size_t commitlen, const unsigned char* proof, size_t prooflen)
Parameters:
commit: pedersen commit of a value, a 33-byte unsigned char array
commitlen: length of commit, should be 33
proof: a 675-byte unsigned char array
prooflen: length of proof
2.9 pedersen_commit
This intrinsic generate pedersen commit.
Include:
#include <eosio/crypto.hpp>
Prototype:
void pedersen_commit(uint64_t value, const unsigned char* blind, size_t blindlen, unsigned char* commit, size_t commitlen)
Parameters:
value: a unsigned int64
blind: a 32-byte unsigned char array, random number, should be same as prove_bulletproof’s
blindlen: length of blind, should be 32
commit: output of pedersen commit, 33-byte unsigned char array
commitlen: length of commit, should be 33