In development, not ready for production yet.
geth
, no extra software is required to install, except the SQL database
ethbot.getBalanceIfExists(address,block_num)
will show if the account exists in state trie, and ethbot.writeoutState(filename,block_num)
will dump accounts and its balances to file.
If you need some feature that is not currently present in EthBot you may sponsor it by buying our coins (AET) directly from us. We will assign a developer to attend your request. This way you will not just paying for a development job, but instead, staying invested in our currency, and later get your money back, potentially, with a profit, if you bought the currency at a convenient price.
Download the sources from our repository
bash$ go get -v -u github.com/afterether/ethbot
Make sure your GOPATH is pointing to the correct directory.
Build EthBot:
bash$ go build github.com/afterether/ethbot
During compilation, errors may show if you do not have all the dependencies. Install them using this command:
bash$ go get -v -u github.com/package_name_here
After compilation, the EthBot
executable will be located in the current directory
By default, Ethbot is configured for Ethereum Main Net, but if you want to configure it for AfterEther Main Net , execute this command:
bash$ ./misc/setup-afterether.sh
To switch back to Ethereum , execute:
bash$ ./misc/setup-ethereum.sh
To find out what kind of network is currently enabled, check the symbolic link in ./vendor/github.com/ethereum
directory:
bash$ ls -l
total 36
-rw-rw-r-- 1 ethbot ethbot 17689 May 15 14:05 ethbot-patch4geth-172.diff
drwxrwxr-x 37 ethbot ethbot 4096 May 15 14:12 go-afterether-1.7.2
lrwxrwxrwx 1 ethbot ethbot 17 May 15 14:14 go-ethereum -> go-ethereum-1.7.2
drwxrwxr-x 36 ethbot ethbot 4096 May 15 14:13 go-ethereum-1.7.2
The symbolic link is pointing to the network's source code, Ethereum in this example
Install and configure Postgres as usual. Once Postgres is installed , create a new Postgres user and a new database , owned by this user. Here is an example of doing it :
bash$ su - postgres bash$ createuser ethbot bash$ createdb ethbot bash$ psql # now you have entered Postgres SQL console postgres# alter user ethbot with encrypted password '123456'; postgres# grant all privileges on database ethbot to ethbot ;
Edit the script initdb.sh and modify the environment variables :
Run the script to create tables and PLSQL functions:
bash$ ./initdb.sh
If you want to modify the database initialization script, all you have to do is to alter the init_database.sql file or the functions.sql file, which are located within the same directory as the init_database executable file. You can also run init_database.sql directly in Postgres
Set the environment variables of database connection exactly as during the creation process:
Example:
bash$ export ETHBOT_HOSTNAME=localhost bash$ export ETHBOT_USERNAME=ethbot bash$ export ETHBOT_PASSWORD=123456 bash$ export ETHBOT_DATABASE=ethbot
You may want to hide these variables in a bash_profile script and set appropriate permissions so it is not accessible to everybody
To run EthBot and start exporting the blockchain data immediately type bitcoin evolution review in the console:
bash$ ./ethbot --gcmode archive --syncmode full
You will achieve the best performance if the node is already synchronized with the network, otherwise blocks will be inserted into SQL database as they are being downloaded.
Note that EthBot is a modified Ethereum geth
, so, some geth
parameters can be used. For example, to specify another data directory use:
bash$ ./ethbot --datadir [path to data directory]
Type ./ethbot --help
to see the list of all parameters EthBot supports.
Sometimes you don't want to start the export process automatically at startup, to disable it run EthBot with this flag:
bash$ ./ethbot --noexport
The following JavaScript functions are provided to operate EthBot from geth console:
The following JavaScript functions are provided to operate EthBot
from geth
console:
Description:
Parameters:
Return value:
Examples:
1) The following invocation will start the export process from the Genesis block and after exporting all the blocks, will enter into listening mode
geth> ethbot.startBlockchainExportStart(0,-1)
2) The following invocation will start the export process from the last block you have exported in previous session and after exporting all the blocks , will enter into listening mode
geth> ethbot.startBlockchainExportStart(-1,-1)
3) The following invocation will export blocks from 1,000,000 to 2,000,000
geth> ethbot.startBlockchainExportStart(1000000,2000000)
Notes:
last_block
Description:
Return value:
Description:
Return value:
Examples:
geth> ethbot.startBlockchainExportStatus()
{
current_block: 2901328,
direction: 1,
ending_block: 3000000,
listening_mode: true,
starting_block: 2000000
}
Description:
account.last_balance
in SQL database against the last balance in the State of the latest block stored on the blockchain (latest block is the one stored in the table last_block
, not the output of eth.getBlock('latest')
)
Description:
account.last_balance
field in SQL database, retrieving it from the latest balance of the State of the latest block in the blockchain (latest block is the one stored in the table last_block, not the output of eth.getBlock('latest'))
. This function is made for recovery purposes, not for the daily operation.
Description:
Parameters:
Return value:
Example:
To export blocks from 3,100,000 to 3,200,000 invoke the function like this:
geth> ethbot.exportBlockRange(3100000,3200000)
Description:
Parameters:
Return value:
Example:
Verify account balances for the block number 3,451,967
geth> ethbot.verifySQLdata1(3451967)
Description:
Parameters:
Return value:
Example:
Verify account balances for the block number 3,451,967
geth> ethbot.verifySQLdata1(3451967)
Description:
Return value:
value_transfers
table causing verification failure
Example:
geth> ethbot.verificationStatus()
{
block_num: 2001,
cancelled_by_user: false,
error_str: "",
failed: false,
finished_threads: 0,
in_progress: false,
num_accounts: 10212,
num_processed: 562,
total_threads: 89,
valtr_id: 0
}
>
Description:
Return value:
Description:
Parameters:
Return value:
Description:
Parameters:
Return value:
Description:
Return value:
To open a geth
in another terminal use this command:
bash$ ./ethbot attach ipc:/your_data_dir/geth.ipc
Now you can control the main EthBot process through another terminal.
Note: The error log and info log will be printed on the console of the main EthBot process, not the console connected through IPC.
Database schema can be found in the file init_database.sql
Lookup table for value_transfer.kind
is the following:
EthBot provides auxiliary functions to query SQL database so you can avoid writing complex queries. The list of all functions can be found in functions.sql
file
psql> SELECT get_balance(account_id,block_num) AS balance;
This function will query the latest balance for the account_id. Not that it queries per block, so only using the latest block will give you the latest balance. Use -1 to specify the latest block.
For example:
psql> SELECT get_balance4block(36313,-1)
psql> SELECT get_TXs(account_id,starting_block,ending_block)
This function will return all the transactions for an account for a range of blocks Use -1 in ending_block to specify the latest block available
Value transfers are transfers of Ether. Value transfers compose a transaction , so if you need low level exploring (transfers between contracts), this function will help you. Note that value transfer can occur without a transaction, like for example during mining a block.
psql> SELECT get_VTs(account_id,starting_block,ending_block)
Use -1 in ending_block to specify the latest block available
SELECT t.tx_id,t.from_id,t.to_id,t.tx_value,t.block_num FROM transaction AS t,account AS a WHERE (a.account_id=t.to_id AND a.address='b794f5ea0ba39494ce839613fffba74279579268') OR (a.account_id=t.from_id AND a.address='b794f5ea0ba39494ce839613fffba74279579268');
SELECT vt.block_num,vt.from_id,vt.to_id,vt.value FROM value_transfer AS vt,account AS a WHERE (a.account_id=vt.to_id AND a.address='b794f5ea0ba39494ce839613fffba74279579268') OR (a.account_id=vt.from_id AND a.address='b794f5ea0ba39494ce839613fffba74279579268');
Note, this is not an optimized query, optimized queries can be seen in AEX's source code
SELECT vt.block_num,vt.from_id,vt.to_id,vt.kind,vt.value FROM value_transfer AS vt,account AS a WHERE (vt.kind='4' AND a.account_id=vt.to_id AND a.address='e8b61c4a9a4143a64cec3a4d4edc76192007d79e') OR (vt.kind='4' AND a.account_id=vt.from_id AND a.address='e8b61c4a9a4143a64cec3a4d4edc76192007d79e ');
SELECT * FROM account ORDER BY last_balance DESC LIMIT 20;
Copyright 2018 AfterEther Foundation, Belize. All Rights Reserved.