Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

aelf-command

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aelf-command

A CLI tools for AElf

  • 0.1.25
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52
decreased by-39.53%
Maintainers
1
Weekly downloads
Β 
Created
Source

aelf-command

Node NPM Commitizen friendly

Descriptions

A CLI tools built for AElf

Features

  • Get or Set common configs, endpoint, account, datadir, password.
  • For new learners who are not familiar with the CLI parameters, any lacked parameters will be asked in a prompting way.
  • Create a new account.
  • Load a account by a given private key or mnemonic.
  • Show wallet details which include private key, address, public key and mnemonic.
  • Encrypt account info into keyStore format and save into files.
  • Get current Best Height of the chain.
  • Get block info by a given height or block hash.
  • Get transaction result by a given transaction id.
  • Send a transaction or call a read-only method on a smart contract.
  • Deploy a smart contract.
  • Open a REPL for using JavaScript to interact with the chain.
  • Friendly interact, beautify with chalk & ora.
  • Get current chain status.
  • Create a proposal on any contract method.
  • Deserialize the result return by executing a transaction.
  • Start a socket.io server for supplying services for dapps.

Installing aelf-command

$ npm i aelf-command -g

Using aelf-command

First Step

You need to create a new account or load a account by a private key or mnemonic you already have.

  • Create a new wallet
$ aelf-command create

Your wallet info is :
Mnemonic            : great mushroom loan crisp ... door juice embrace
Private Key         : e038eea7e151eb451ba2901f7...b08ba5b76d8f288
Public Key          : 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec88288111955b76ea
Address             : 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
βœ” Save account info into a file? … no / yes
βœ” Enter a password … ********
βœ” Confirm password … ********
βœ”
Account info has been saved to "/Users/young/.local/share/aelf/keys/2Ue31YTuB5Szy7cnr...Gi5uMQBYarYUR5oGin1sys6H.json"

  • Load wallet from private key
$ aelf-command load e038eea7e151eb451ba2901f7...b08ba5b76d8f288

Your wallet info is :
Private Key         : e038eea7e151eb451ba2901f7...b08ba5b76d8f288
Public Key          : 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec88288111955b76ea
Address             : 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
βœ” Save account info into a file? … no / yes
βœ” Enter a password … ********
βœ” Confirm password … ********
βœ”
Account info has been saved to "/Users/young/.local/share/aelf/keys/2Ue31YTuB5Szy7cnr...Gi5uMQBYarYUR5oGin1sys6H.json"
  • show wallet info you already have
$ aelf-command wallet -a 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
Your wallet info is :
Private Key         : e038eea7e151eb451ba2901f7...b08ba5b76d8f288
Public Key          : 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec88288111955b76ea
Address             : 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H

Here you can get the account info and decide whether to encrypt account info and save into a file.

Examples:

$ aelf-command console -a 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
βœ” Enter the password you typed when creating a wallet … ********
βœ” Succeed!
Welcome to aelf interactive console. Ctrl + C to terminate the program. Double tap Tab to list objects

   ╔═══════════════════════════════════════════════════════════╗
   β•‘                                                           β•‘
   β•‘   NAME       | DESCRIPTION                                β•‘
   β•‘   AElf       | imported from aelf-sdk                     β•‘
   β•‘   aelf       | the instance of an aelf-sdk, connect to    β•‘
   β•‘              | http://127.0.0.1:8000                  β•‘
   β•‘   _account   | the instance of an AElf wallet, address    β•‘
   β•‘              | is                                         β•‘
   β•‘              | 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR…   β•‘
   β•‘              | 5oGin1sys6H                                β•‘
   β•‘                                                           β•‘
   β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Any missed parameters you did not give in CLI parameters will be asked in a prompting way

$ aelf-command console
βœ” Enter a valid wallet address, if you don't have, create one by aelf-command create … 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
βœ” Enter the password you typed when creating a wallet … ********
βœ” Succeed!
Welcome to aelf interactive console. Ctrl + C to terminate the program. Double tap Tab to list objects

   ╔═══════════════════════════════════════════════════════════╗
   β•‘                                                           β•‘
   β•‘   NAME       | DESCRIPTION                                β•‘
   β•‘   AElf       | imported from aelf-sdk                     β•‘
   β•‘   aelf       | the instance of an aelf-sdk, connect to    β•‘
   β•‘              | http://13.231.179.27:8000                  β•‘
   β•‘   _account   | the instance of an AElf wallet, address    β•‘
   β•‘              | is                                         β•‘
   β•‘              | 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR…   β•‘
   β•‘              | 5oGin1sys6H                                β•‘
   β•‘                                                           β•‘
   β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Help

Type

$ aelf-command -h

Usage: aelf-command [command] [options]

Options:
  -v, --version                                            output the version number
  -e, --endpoint <URI>                                     The URI of an AElf node. Eg: http://127.0.0.1:8000
  -a, --account <account>                                  The address of AElf wallet
  -p, --password <password>                                The password of encrypted keyStore
  -d, --datadir <directory>                                The directory that contains the AElf related files. Default to be Default to be `{home}/.local/share/aelf`
  -h, --help                                               output usage information

Commands:
  call [contract-address|contract-name] [method] [params]  Call a read-only method on a contract.
  send [contract-address|contract-name] [method] [params]  Execute a method on a contract.
  get-blk-height                                           Get the current block height of specified chain
  get-chain-status                                         Get the current chain status
  get-blk-info [height|block-hash] [include-txs]           Get a block info
  get-tx-result [tx-hash]                                  Get a transaction result
  console                                                  Open a node REPL
  create [options] [save-to-file]                          Create a new account
  wallet                                                   Show wallet details which include private key, address, public key and mnemonic
  load [private-key|mnemonic] [save-to-file]               Load wallet from a private key or mnemonic
  proposal [organization] [expired-time]                   Send a proposal to an origination with a specific contract method
  deploy [category] [code-path]                            Deploy a smart contract
  config <flag> [key] [value]                              Get, set, delete or list aelf-command config

in your terminal and get useful information.

Any sub-commands such as call, you can get help by typing this

$ aelf-command call -h
$ aelf-command send -h
$ aelf-command console -h
...

Common options

  • datadir: The directory that contains aelf-command files, such as encrypted account info keyStore files. Default to be {home}/.local/share/aelf
  • endpoint: The endpoint for the RPC service.
  • account: The account to be used to interact with the blockchain endpoint.
  • password: The password for unlocking the given account.

You can specified options above in several ways, and the priority is in the order of low to high.

  1. export variables in shell.
# This is datadir
export AELF_CLI_DATADIR=/Users/your/.local/share/aelf
# This is endpoint 
export AELF_CLI_ENDPOINT=http://127.0.0.1:8000
# This is account
export AELF_CLI_ACCOUNT=2Ue31YTuB5Szy7c...gtGi5uMQBYarYUR5oGin1sys6H
  1. aelf-command global .aelfrc config file

The global config file is stored in the <datadir>/.aelfrc file, you can read the config file, but better not modify it by yourself.

Modify this config file by aelf-command config.

  • set: set and save config in the file, remember just set datadir, endpoint, account, password four keys.
    $ aelf-command config set endpoint http://127.0.0.1:8000
    $ aelf-command config -h
    
    Usage: aelf-command config [options] <flag> [key] [value]
    
    get, set, delete or list aelf-command config
    
    Options:
      -h, --help  output usage information
    
    Examples:
    
    aelf-command config get <key>
    aelf-command config set <key> <value>
    aelf-command config delete <key>
    aelf-command config list
    
  • get: get the value of given key from global .aelfrc file
    $ aelf-command config get endpoint
    http://127.0.0.1:8000
    
  • delete: delete the <key, value> from global .aelfrc file by a given key
    $ aelf-command config delete endpoint
    
  • list: get the list of all configs stored in global .aelfrc file
    $ aelf-command config list
    endpoint=http://127.0.0.1:8000
    

Remember config command only can be used to modify the global .aelfrc file for now, more usages such as modify working directory will be implemented in later.

  1. aelf-command working directory .aelfrc file

The current working directory of aelf-command can have a file named .aelfrc and store configs, the format of this file is like global .aelfrc file:

endpoint http://127.0.0.1:8000
password yourpassword

each line is <key, value> config and a whitespace is needed to separate them.

  1. aelf-command options.

You can give common options by passing them in CLI parameters.

$ aelf-command console -a sadaf -p password -e http://127.0.0.1:8000

Notice the priority, the options given in higher priority will overwrite the lower priority.

create - Create a new account

This command will create a new account.

$ aelf-command create -h
Usage: aelf-command create [options] [save-to-file]

create a new account

Options:
  -c, --cipher [cipher]  Which cipher algorithm to use, default to be aes-128-ctr
  -h, --help             output usage information

Examples:

aelf-command create <save-to-file>
aelf-command create

Example:

  • Specify the cipher way to encrypt account info by passing option -c [cipher], such as:
$ aelf-command create -c aes-128-cbc

load - Load an account by a given private key or mnemonic

This command allow you load an account from backup.

# load from mnemonic
$ aelf-command load 'great mushroom loan crisp ... door juice embrace'
# load from private key
$ aelf-command load 'e038eea7e151eb451ba2901f7...b08ba5b76d8f288'
# load from prompting
$ aelf-command load
? Enter a private key or mnemonic β€Ί e038eea7e151eb451ba2901f7...b08ba5b76d8f288
...

wallet - Show wallet details which include private key, address, public key and mnemonic

This command allow you print wallet info.

$ aelf-command wallet -a C91b1SF5mMbenHZTfdfbJSkJcK7HMjeiuw...8qYjGsESanXR
⬑ AElf [Info]: Private Key         : 97ca9fbece296231f26bee0e493500810f...cbd984f69a8dc22ec9ec89ebb00 
⬑ AElf [Info]: Public Key          : 04c30dd0c3b5abfc85a11b15dabd0de926...74fe04e92eaebf2e4fef6445d9b9b11efe6f4b70c8e86644b72621f9987dc00bb1eab44a9bd7512ea53f93937a5d0 
⬑ AElf [Info]: Address             : C91b1SF5mMbenHZTfdfbJSkJcK7HMjeiuw...8qYjGsESanXR 

proposal - Create a proposal

There are some transactions you can't send directly, such as deploying a smart contract, you need to create a proposal to a specific organization which contains BP nodes, and wait for the approve.

Actually, you can create proposals on any contract method.

  • Get an organization address or create a organization
$ aelf-command call AElf.ContractNames.Parliament GetGenesisOwnerAddress ''
βœ” Fetching contract successfully!
βœ” Calling method successfully!
⬑ AElf [Info]:
Result:
"BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc"
βœ” Succeed!

BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc is the organization address.

You can get the default organization address and it has all BP nodes inside, every proposal can only be released when it has got over 2/3 BP nodes approve

Create an organization

$ aelf-command send AElf.ContractNames.Parliament CreateOrganization '{"reviewers":["ada","asda"], "releaseThreshold": 660000}' 
  • Create a proposal
$ aelf-command proposal

? Enter an organization address: BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc
? Select the expired time for this proposal: 2022/09/23 22:06
? Enter a contract address or name: 2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8
βœ” Fetching contract successfully!
? Pick up a contract method: DeploySmartContract

If you need to pass file contents to the contractMethod, you can enter the relative or absolute path of the file instead

Enter required params one by one:
? Enter the required param <category>: 0
? Enter the required param <code>: /Users/home/Downloads/AElf.Contracts.TokenConverter.dll
? It seems that you have entered a file path, do you want to read the file content and take it as the value of <code> Yes
⬑ AElf [Info]:
 { TransactionId:
   '09c8c824d2e3aea1d6cd15b7bb6cefe4e236c5b818d6a01d4f7ca0b60fe99535' }
βœ” loading proposal id...
⬑ AElf [Info]: Proposal id: "bafe83ca4ec5b2a2f1e8016d09b21362c9345954a014379375f1a90b7afb43fb".
βœ” Succeed!

You can get the proposal id, then get proposal status by it.

  • Get proposal status
$ aelf-command call AElf.ContractNames.Parliament GetProposal bafe83ca4ec5b2a2f1e8016d09b21362c9345954a014379375f1a90b7afb43fb

{
  ...
  "expiredTime": {
    "seconds": "1663942010",
    "nanos": 496000
  },
  "organizationAddress": "BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc",
  "proposer": "2tj7Ea67fuQfVAtQZ3WBmTv7AAJ8S9D2L4g6PpRRJei6JXk7RG",
  "toBeReleased": false
}
βœ” Succeed!

toBeReleased indicates whether you can release this proposal, in default situation, a proposal need to get over 2/3 BP nodes approve.

  • Release a proposal

You can release a proposal when it got approved.

$ aelf-command send AElf.ContractNames.Parliament Release bafe83ca4ec5b2a2f1e8016d09b21362c9345954a014379375f1a90b7afb43fb
⬑ AElf [Info]:
 { TransactionId:
   '09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535' }

Get the transaction result

$ aelf-command get-tx-result 09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535

⬑ AElf [Info]: {
  "TransactionId": "09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535",
  "Status": "MINED",
  "Logs": [
    {
      "Address": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8",
      "Name": "ContractDeployed",
      "Indexed": [
        "CiIKIPklcv1FnKLzUEtsxyZC59it/lXsLhgWS5VpxEhR4FxE",
        "EiIKIDKVFb+Kx1GM+Vus5MGJnCmbKmRg6d7MOuNP6FiQ9laq"
      ],
      "NonIndexed": "GiIKIKOmGZC08DAoVVq4bnxr6WsfKAUpflGo1WLHAKS9g+SD"
    }
  ],
  "Bloom": "AAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAACAAAAAAAAAAACAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAQAAA==",
  "BlockNumber": 28411,
  "BlockHash": "fa22e4eddff12a728895a608db99d40a4b21894f7c07df1a4fa8f0625eb914a2",
  "Transaction": {
    "From": "2tj7Ea67fuQfVAtQZ3WBmTv7AAJ8S9D2L4g6PpRRJei6JXk7RG",
    "To": "29RDBXTqwnpWPSPHGatYsQXW2E17YrQUCj7QhcEZDnhPb6ThHW",
    "RefBlockNumber": 28410,
    "RefBlockPrefix": "0P+eTw==",
    "MethodName": "Release",
    "Params": "\"ad868c1e0d74127dd746ccdf3443a09459c55cf07d247df053ddf718df258c86\"",
    "Signature": "DQcv55EBWunEFPXAbqZG20OLO5T0Sq/s0A+/iuwv1TdQqIV4318HrqFLsGpx9m3+sp5mzhAnMlrG7CSxM6EuIgA="
  },
  "ReturnValue": "",
  "ReadableReturnValue": "{ }",
  "Error": null
}

If you want to call a contract method by creating a proposal and released it, the transaction result could be confusing, you can use another aelf-command sub-command to get the readable result;

Take the example above which has deployed a smart contract by proposal, the contract address is necessary for sending transactions. The contract address has been given but need to be decoded. We supply aelf-command event to decode the results.

Pass the transaction id as a parameter:

aelf-command event 09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535

[Info]: 
The results returned by 
Transaction: 09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535 is: 
[
  {
    "Address": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8",
    "Name": "ContractDeployed",
    "NonIndexed": "GiIKIKOmGZC08DAoVVq4bnxr6WsfKAUpflGo1WLHAKS9g+SD",
    "Result": {
      "creator": null,
      "codeHash": null,
      "address": "2F5C128Srw5rHCXoSY2C7uT5sAku48mkgiaTTp1Hiprhbb7ED9"
    }
  }
]

The Result field is the decoded result, in this example, the Result.address is the new deployed contract address.

For more details, check the descriptions of aelf-command event.

deploy - Deploy a smart contract

Deploy a smart contract to the chain

$ aelf-command deploy
βœ” Enter a valid wallet address, if you don't have, create one by aelf-command create … 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
βœ” Enter the password you typed when creating a wallet … ********
βœ” Enter the category of the contract to be deployed … 0
? Enter the relative or absolute path of contract code β€Ί /Users/home/home

event - Deserialize the result return by executing a transaction

Only one parameter is required

$ aelf-command event 40872ea2d8a4d2cf7747263c5b9fdd5a4ad05b3e9fadc7a7dd134728a858d5de

[Info]: 
The results returned by 
Transaction: 40872ea2d8a4d2cf7747263c5b9fdd5a4ad05b3e9fadc7a7dd134728a858d5de is: 
[
  {
    "Address": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8",
    "Name": "ContractDeployed",
    "NonIndexed": "GiIKIKOmGZC08DAoVVq4bnxr6WsfKAUpflGo1WLHAKS9g+SD",
    "Result": {
      "creator": null,
      "codeHash": null,
      "address": "2F5C128Srw5rHCXoSY2C7uT5sAku48mkgiaTTp1Hiprhbb7ED9"
    }
  }
]

A transaction may be related with several Contract Methods' executions, so the transaction result can include several items.

In each item,

  • Address: the contract address.
  • Name: the executed method name of contract address.
  • NoIndexed: the encoded result returned by this contract method.
  • Result: the decoded result, this is readable and you can use it and get what the fields means inside the Result by reading the contract documents or contract related protobuf files. In this example, you can read the protobuf file;

send - Send a transaction

$ aelf-command send
βœ” Enter the the URI of an AElf node … http://13.231.179.27:8000
βœ” Enter a valid wallet address, if you don't have, create one by aelf-command create … D3vSjRYL8MpeRpvUDy85ktXijnBe2tHn8NTACsggUVteQCNGP
βœ” Enter the password you typed when creating a wallet … ********
βœ” Enter contract name (System contracts only) or the address of contract … AElf.ContractNames.Token
βœ” Succeed
βœ” Pick up a contract method β€Ί GetTokenInfo
βœ” Enter the method params in JSON string format … {"symbol":"ELF"}
βœ” Succeed!

Result:
{
  "TransactionId": "7b620a49ee9666c0c381fdb33f94bd31e1b5eb0fdffa081463c3954e9f734a02"
}
βœ” Succeed!
$ aelf-command send AElf.ContractNames.Token GetTokenInfo '{"symbol":"ELF"}'
$ aelf-command send WnV9Gv3gioSh3Vgaw8SSB96nV8fWUNxuVozCf6Y14e7RXyGaM GetTokenInfo '{"symbol":"ELF"}'

call - Call a read-only method on a contract

$ aelf-command call
βœ” Enter the the URI of an AElf node … http://13.231.179.27:8000
βœ” Enter a valid wallet address, if you don't have, create one by aelf-command create … D3vSjRYL8MpeRpvUDy85ktXijnBe2tHn8NTACsggUVteQCNGP
βœ” Enter the password you typed when creating a wallet … ********
βœ” Enter contract name (System contracts only) or the address of contract … AElf.ContractNames.Token
βœ” Succeed
βœ” Pick up a contract method β€Ί GetTokenInfo
βœ” Enter the method params in JSON string format … {"symbol":"ELF"}
βœ” Succeed!

Result:
{
  "symbol": "ELF",
  "tokenName": "elf token",
  "supply": "1000000000",
  "totalSupply": "1000000000",
  "decimals": 2,
  "issuer": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8",
  "isBurnable": true
}
βœ” Succeed!
$ aelf-command call AElf.ContractNames.Token GetTokenInfo '{"symbol":"ELF"}'
$ aelf-command call WnV9Gv3gioSh3Vgaw8SSB96nV8fWUNxuVozCf6Y14e7RXyGaM GetTokenInfo '{"symbol":"ELF"}'

get-chain-status - Get the current status of the block chain

$ aelf-command get-chain-status
βœ” Succeed
{
  "ChainId": "AELF",
  "Branches": {
    "59937e3c16860dedf0c80955f4995a5604ca43ccf39cd52f936fb4e5a5954445": 4229086
  },
  "NotLinkedBlocks": {},
  "LongestChainHeight": 4229086,
  "LongestChainHash": "59937e3c16860dedf0c80955f4995a5604ca43ccf39cd52f936fb4e5a5954445",
  "GenesisBlockHash": "da5e200259320781a1851081c99984fb853385153991e0f00984a0f5526d121c",
  "GenesisContractAddress": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8",
  "LastIrreversibleBlockHash": "497c24ff443f5cbd33da24a430f5c6c5e0be2f31651bd89f4ddf2790bcbb1906",
  "LastIrreversibleBlockHeight": 4229063,
  "BestChainHash": "59937e3c16860dedf0c80955f4995a5604ca43ccf39cd52f936fb4e5a5954445",
  "BestChainHeight": 4229086
}

get-tx-result - Get a transaction result

$ aelf-command get-tx-result

βœ” Enter the the URI of an AElf node … http://13.231.179.27:8000
βœ” Enter a valid transaction hash in hex format … 7b620a49ee9666c0c381fdb33f94bd31e1b5eb0fdffa081463c3954e9f734a02
βœ” Succeed!
{ TransactionId:
   '7b620a49ee9666c0c381fdb33f94bd31e1b5eb0fdffa081463c3954e9f734a02',
  Status: 'MINED',
  Logs: null,
  Bloom:
   'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==',
  BlockNumber: 7900508,
  BlockHash:
   'a317c5ecf4a22a481f88ab08b8214a8e8c24da76115d9ddcef4afc9531d01b4b',
  Transaction:
   { From: 'D3vSjRYL8MpeRpvUDy85ktXijnBe2tHn8NTACsggUVteQCNGP',
     To: 'WnV9Gv3gioSh3Vgaw8SSB96nV8fWUNxuVozCf6Y14e7RXyGaM',
     RefBlockNumber: 7900503,
     RefBlockPrefix: 'Q6WLSQ==',
     MethodName: 'GetTokenInfo',
     Params: '{ "symbol": "ELF" }',
     Signature:
      'JtSpWbMX13tiJD0klMSJQyPBa0aRNFY4hTh3hltdWqhBpv4IRTbjjZfQj39lbBSCOy68vnLg6rUerEcyCsqwfgE=' },
  ReadableReturnValue:
   '{ "symbol": "ELF", "tokenName": "elf token", "supply": "1000000000", "totalSupply": "1000000000", "decimals": 2, "issuer": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8", "isBurnable": true }',
  Error: null }

get-blk-height - Get the block height

$ aelf-command get-blk-height
βœ” Enter the the URI of an AElf node … http://13.231.179.27:8000
> 7902091

get-blk-info - Get the block info by a block height or a block hash

You can pass a block height or a block hash to this sub-command.

$ aelf-command get-blk-info
βœ” Enter the the URI of an AElf node … http://13.231.179.27:8000
βœ” Enter a valid height … 123
βœ” Include transactions whether or not … no / yes
{ BlockHash:
   '6034db3e02e283d3b81a4528442988d28997d3828f87cca1a89457b294517372',
  Header:
   { PreviousBlockHash:
      '9d6bcc588c0bc10942899e7ec4536665c86f23286029ed45287babf22c582f5a',
     MerkleTreeRootOfTransactions:
      '7ceb349715787ececa647ad48576467d294de6dcc44d14e19f60c4a91a7a9536',
     MerkleTreeRootOfWorldState:
      'b529e2775283edc39cd4e3f685616085b18bd5521a87ea7904ad99cd2dc50910',
     Extra:
      '[ "CkEEJT3FEw+k9cuqv7uruq1fEwQwEjKtYxbXK86wUGrAOH7BgCVkMendLkQZmpEpMgzcz+JXnaVpWtFt3AJcGmGycxL+DggIEvIDCoIBMDQyNTNkYzUxMzBmYTRmNWNiYWFiZmJiYWJiYWFkNWYxMzA0MzAxMjMyYWQ2MzE2ZDcyYmNlYjA1MDZhYzAzODdlYzE4MDI1NjQzMWU5ZGQyZTQ0MTk5YTkxMjkzMjBjZGNjZmUyNTc5ZGE1Njk1YWQxNmRkYzAyNWMxYTYxYjI3MxLqAggCIiIKIOAP2QU8UpM4u9Y3OxdKdI5Ujm3DSyQ4JaRNf7q5ka5mKiIKIH5yNJs87wb/AkWcIrCxvCX/Te3fGHVXFxE8xsnfT1HtMgwIoJro6AUQjOa1pQE4TkqCATA0MjUzZGM1MTMwZmE0ZjVjYmFhYmZiYmFiYmFhZDVmMTMwNDMwMTIzMmFkNjMxNmQ3MmJjZWIwNTA2YWMwMzg3ZWMxODAyNTY0MzFlOWRkMmU0NDE5OWE5MTI5MzIwY2RjY2ZlMjU3OWRh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kYTQwMzBmMDk3ZjgwNmI1YWJlY2E0QAIYBQ==", "" ]',
     Height: 123,
     Time: '2019-07-01T13:39:45.8704899Z',
     ChainId: 'AELF',
     Bloom:
      '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
     SignerPubkey:
      '04253dc5130fa4f5cbaabfbbabbaad5f1304301232ad6316d72bceb0506ac0387ec180256431e9dd2e44199a9129320cdccfe2579da5695ad16ddc025c1a61b273' },
  Body:
   { TransactionsCount: 1,
     Transactions:
      [ 'a365a682caf3b586cbd167b81b167979057246a726c7282530554984ec042625' ] } }
$ aelf-command get-blk-info ca61c7c8f5fc1bc8af0536bc9b51c61a94f39641a93a748e72802b3678fea4a9 true
$ aelf-command get-blk-info 12 true

console - Open an interactive console

$ aelf-command console
βœ” Enter the the URI of an AElf node … http://13.231.179.27:8000
βœ” Enter a valid wallet address, if you don't have, create one by aelf-command create … 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
βœ” Enter the password you typed when creating a wallet … ********
βœ” Succeed!
Welcome to aelf interactive console. Ctrl + C to terminate the program. Double tap Tab to list objects

   ╔═══════════════════════════════════════════════════════════╗
   β•‘                                                           β•‘
   β•‘   NAME       | DESCRIPTION                                β•‘
   β•‘   AElf       | imported from aelf-sdk                     β•‘
   β•‘   aelf       | the instance of an aelf-sdk, connect to    β•‘
   β•‘              | http://13.231.179.27:8000                  β•‘
   β•‘   _account   | the instance of an AElf wallet, address    β•‘
   β•‘              | is                                         β•‘
   β•‘              | 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR…   β•‘
   β•‘              | 5oGin1sys6H                                β•‘
   β•‘                                                           β•‘
   β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

dapp-server - Start a socket.io server for supplying services for dapps

If you're developing a dapp and you need an environment to hold wallet info and connect to the AElf chain, you can use this sub-command to start a server for dapp local development.

$ aelf-command dapp-server
⬑ AElf [Info]: DApp server is listening on port 35443

# or listen on a specified port
$ aelf-command dapp-server --port 40334
⬑ AElf [Info]: DApp server is listening on port 40334 

This server use Socket.io to listen on local port 35443 and you can use aelf-bridge to connect to this server like this.

import AElfBridge from 'aelf-bridge';
const bridgeInstance = new AElfBridge({
  proxyType: 'SOCKET.IO',
  socketUrl: 'http://localhost:35443',
  channelType: 'ENCRYPT'
});
// connect to dapp-server
bridgeInstance.connect().then(console.log).catch(console.error);

Keywords

FAQs

Package last updated on 28 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc