From 43193218108f0e11c787411cd35c6f058b00bb36 Mon Sep 17 00:00:00 2001 From: Rutvik Date: Tue, 9 Jul 2024 08:24:34 +0530 Subject: [PATCH 1/7] Replaced translate files with javascript-sdk (tools/chain-sdk) and commands (aelf-cli) --- docs/tools/aelf-cli/commands/index.md | 770 +++++++------------ docs/tools/chain-sdk/javascript-sdk/index.md | 511 ++++++------ 2 files changed, 544 insertions(+), 737 deletions(-) diff --git a/docs/tools/aelf-cli/commands/index.md b/docs/tools/aelf-cli/commands/index.md index db910a35..e85ad89d 100644 --- a/docs/tools/aelf-cli/commands/index.md +++ b/docs/tools/aelf-cli/commands/index.md @@ -6,9 +6,12 @@ description: aelf CLI Commands # Commands Overview +## 具体配置 + ### Common Options -**datadir**: Directory containing `aelf-command` files, including encrypted account info keyStore files. Default: `{home}/.local/share/aelf` +**datadir**: Directory containing `aelf-command` files, including encrypted account info keyStore files. Default: +`{home}/.local/share/aelf` **endpoint**: The RPC service endpoint. @@ -19,57 +22,63 @@ description: aelf CLI Commands You can set these options in several ways, in order of priority from low to high: 1. **Environment Variables** - ```sh - # Set datadir - $ export AELF_CLI_DATADIR=/Users/{you}/.local/share/aelf - - # Set endpoint - $ export AELF_CLI_ENDPOINT=http://127.0.0.1:8000 - - # Set account - $ export AELF_CLI_ACCOUNT=2Ue31YTuB5Szy7c...gtGi5uMQBYarYUR5oGin1sys6H - ``` + + ```sh + # Set datadir + $ export AELF_CLI_DATADIR=/Users/{you}/.local/share/aelf + + # Set endpoint + $ export AELF_CLI_ENDPOINT=https://tdvw-test-node.aelf.io + + # Set account + $ export AELF_CLI_ACCOUNT=2Ue31YTuB5Szy7c...gtGi5uMQBYarYUR5oGin1sys6H + ``` 2. **Global Config File** - - The global config file is located in `/.aelfrc`. Avoid modifying this file manually. - - Use the `aelf-command config` to modify the global config file. + - The global config file is located in `/.aelfrc`. Avoid modifying this file manually. + - Use the `aelf-command config` to modify the global config file. ### Config Command **set**: Save configuration in the global `.aelfrc` file. ```bash -$ aelf-command config set endpoint http://127.0.0.1:8000 +$ aelf-command config set endpoint https://tdvw-test-node.aelf.io ✔ Succeed! ``` **get**: Retrieve a value from the global `.aelfrc` file. + ```bash -$ aelf-command config get endpoint -http://127.0.0.1:8000 +$ aelf-command config get endpoint https://tdvw-test-node.aelf.io ``` **delete**: Remove a key-value pair from the global `.aelfrc` file. + ```bash $ aelf-command config delete endpoint ✔ Succeed! ``` **list**: List all configurations stored in the global `.aelfrc` file. + ```bash $ aelf-command config list -endpoint=http://127.0.0.1:8000 -password=password +endpoint=https://tdvw-test-node.aelf.io +password=yourpassword ``` **Usage:** + ```bash $ aelf-command config -h Usage: aelf-command config [options] [key] [value] +Get, set, delete or list aelf-command config + Options: -h, --help output usage information - + Examples: aelf-command config get @@ -81,20 +90,26 @@ aelf-command config list ### Working Directory Config File The current working directory can also have a `.aelfrc` file. The format is the same as the global `.aelfrc` file: + ``` -endpoint http://127.0.0.1:8000 +endpoint https://tdvw-test-node.aelf.io password yourpassword ``` + Each line contains a `` pair separated by a whitespace. ### CLI Parameters You can pass common options directly as CLI parameters: + ```sh -$ aelf-command console -a sadaf -p password -e http://127.0.0.1:8000 +$ aelf-command console -a sadaf -p yourpassword -e https://tdvw-test-node.aelf.io ``` + Options given in higher priority (e.g., CLI parameters) will overwrite those with lower priority (e.g., environment variables). +## 具体命令(#command-details) + ### Create a New Account Use the `create` command to create a new account. @@ -109,51 +124,54 @@ Options: ``` **Examples:** + ```sh $ aelf-command create $ aelf-command create $ aelf-command create -c aes-128-cbc ``` -By following this guide, you should be able to easily set up and use aelf for your Web3 applications. For more detailed information, please refer to the full aelf documentation. +By following this guide, you should be able to easily set up and use aelf for your Web3 applications. For more detailed +information, please refer to the full aelf documentation. - -## Load - Load an Account by a Given `Private Key` or `Mnemonic` +### Load - Load an Account by a Given `Private Key` or `Mnemonic` This command allows you to load an account from a backup. -### Load from Mnemonic +**Load from Mnemonic:** ```sh -$ aelf-command load 'great mushroom loan crisp ... door juice embrace' +$ aelf-command load 'impact fork bulk museum swap design draw arctic load option ticket across' ``` -### Load from Private Key +**Load from Private Key:** ```sh -$ aelf-command load 'e038eea7e151eb451ba2901f7...b08ba5b76d8f288' +$ aelf-command load '9a2c6023e8b2221f4b02f4ccc5128392c1bd968ae45a42fa62848d793fff148f' ``` -### Load from Prompting +**Load from Prompting:** ```sh $ aelf-command load -? Enter a private key or mnemonic › e038eea7e151eb451ba2901f7...b08ba5b76d8f288 +? Enter a private key or mnemonic › 9a2c6023e8b2221f4b02f4ccc5128392c1bd968ae45a42fa62848d793fff148f ``` -## Wallet - Show Wallet Details +### Wallet - Show Wallet Details This command allows you to print wallet information, including the `private key`, `address`, `public key`, and `mnemonic`. +**Examples:** + ```sh -$ aelf-command wallet -a C91b1SF5mMbenHZTfdfbJSkJcK7HMjeiuw...8qYjGsESanXR -AElf [Info]: -Private Key : 97ca9fbece296231f26bee0e493500810f...cbd984f69a8dc22ec9ec89ebb00 -Public Key : 04c30dd0c3b5abfc85a11b15dabd0de926...74fe04e92eaebf2e4fef6445d9b9b11efe6f4b70c8e86644b72621f9987dc00bb1eab44a9bd7512ea53f93937a5d0 -Address : C91b1SF5mMbenHZTfdfbJSkJcK7HMjeiuw...8qYjGsESanXR +$ aelf-command wallet -a GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk +AElf [Info]: Mnemonic : impact fork bulk museum swap design draw arctic load option ticket across +AElf [Info]: Private Key : 9a2c6023e8b2221f4b02f4ccc5128392c1bd968ae45a42fa62848d793fff148f +AElf [Info]: Public Key : 04703bbe95e986c9d901f28edd60975a7a6c3b2dce41dfec2e7983d293c600e8249642a3da379c4194a6d62bd89afe6753e81acfc2b6bbf3b40736ee0949102071 +AElf [Info]: Address : GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk ``` -## Proposal - Create a Proposal +### Proposal - Create a Proposal There are three types of proposal contracts in aelf: @@ -163,7 +181,7 @@ There are three types of proposal contracts in aelf: Depending on your needs, you can choose one and create a proposal. -### Get an Organization Address or Create One +#### Get an Organization Address or Create One **Get the Default Organization's Address with the Parliament Contract** @@ -173,42 +191,42 @@ $ aelf-command call AElf.ContractNames.Parliament GetDefaultOrganizationAddress ✔ Calling method successfully! AElf [Info]: Result: -"BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc" +"aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG" ✔ Succeed! ``` -`BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc` is the default organization address. - -The default organization includes all miners; every proposal under AElf.ContractNames.Parliament requires over 2/3 miner approval to be released. +`aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG` is the default organization address. -**Create an Organization with the Referendum Contract** +The default organization includes all miners; every proposal under AElf.ContractNames.Parliament requires over 2/3 miner approval +to be released. **Create an Organization with the Referendum Contract** ```sh $ aelf-command send AElf.ContractNames.Referendum ✔ Fetching contract successfully! ? Pick up a contract method: CreateOrganization -If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file. +If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file -Enter the params one by one, type `Enter` to skip optional parameters: +Enter the params one by one, type `Enter` to skip optional param: ? Enter the required param : ELF -? Enter the required param : 666 -? Enter the required param : 666 -? Enter the required param : 666 -? Enter the required param : 666 -? Enter the required param : ["2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX"] +? Enter the required param : 1 +? Enter the required param : 0 +? Enter the required param : 0 +? Enter the required param : 1 +? Enter the required param : ["GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk"] +? Enter the required param : The params you entered is: { "tokenSymbol": "ELF", "proposalReleaseThreshold": { - "minimalApprovalThreshold": 666, - "maximalRejectionThreshold": 666, - "maximalAbstentionThreshold": 666, - "minimalVoteThreshold": 666 + "minimalApprovalThreshold": 1, + "maximalRejectionThreshold": 0, + "maximalAbstentionThreshold": 0, + "minimalVoteThreshold": 1 }, "proposerWhiteList": { "proposers": [ - "2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX" + "GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk" ] } } @@ -216,514 +234,263 @@ The params you entered is: AElf [Info]: Result: { - "TransactionId": "273285c7e8825a0af5291dd5d9295f746f2bb079b30f915422564de7a64fc874" + "TransactionId": "0106c04d7918d7634ad0ef9499b5366458d14ce87f735e4d39d3587052840bc1" } ✔ Succeed! ``` -### Create a Proposal +#### Create a Proposal ```sh $ aelf-command proposal ? Pick up a contract name to create a proposal: AElf.ContractNames.Parliament -? Enter an organization address: BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc -? Select the expired time for this proposal: 2022/09/23 22:06 -? Optional, input a URL for proposal description: +? Enter an organization address: aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG +? Select the expired time for this proposal: 2222/07/03 13:09 +? Optional, input an URL for proposal description: ? Enter a contract address or name: AElf.ContractNames.Token ✔ Fetching contract successfully! ? Pick up a contract method: Transfer -If you need to pass file contents to the contract method, you can enter the relative or absolute path of the file instead. +If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file -Enter required params one by one: -? Enter the required param : 2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX +Enter the params one by one, type `Enter` to skip optional param: +? Enter the required param : GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk ? Enter the required param : ELF ? Enter the required param : 100000000 ? Enter the required param : test AElf [Info]: - { TransactionId: - '09c8c824d2e3aea1d6cd15b7bb6cefe4e236c5b818d6a01d4f7ca0b60fe99535' } + { + TransactionId: 'b99c63fc8aa2572d1d8c7c65dd52ad01926ed985ce045e3c8ad3dabeb4c6f2ba' +} ✔ loading proposal id... -AElf [Info]: Proposal id: "bafe83ca4ec5b2a2f1e8016d09b21362c9345954a014379375f1a90b7afb43fb". +AElf [Info]: Proposal id: 1df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f. ✔ Succeed! ``` You can get the proposal id, then get the proposal’s status. - -### Get Proposal Status +#### Get Proposal Status ```sh -$ aelf-command call AElf.ContractNames.Parliament GetProposal bafe83ca4ec5b2a2f1e8016d09b21362c9345954a014379375f1a90b7afb43fb +$ aelf-command call AElf.ContractNames.Parliament GetProposal 1df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f +AElf [Info]: +Result: { - ... + "proposalId": "1df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f", + "contractMethodName": "Transfer", + "toAddress": "ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx", + "params": "CiIKICREfSjQ2i95I6kXpBdiFAMlQb2j0NGkyBlfPszMA0/HEgNFTEYYgMLXLyIEdGVzdA==", "expiredTime": { - "seconds": "1663942010", - "nanos": 496000 + "seconds": "7968172181", + "nanos": 141000000 }, - "organizationAddress": "BkcXRkykRC2etHp9hgFfbw2ec1edx7ERBxYtbC97z3Q2bNCwc", - "proposer": "2tj7Ea67fuQfVAtQZ3WBmTv7AAJ8S9D2L4g6PpRRJei6JXk7RG", - "toBeReleased": false + "organizationAddress": "aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG", + "proposer": "GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk", + "toBeReleased": false, + "approvalCount": "0", + "rejectionCount": "0", + "abstentionCount": "0" } ✔ Succeed! ``` `toBeReleased` indicates whether you can release this proposal. By default, a proposal needs over 2/3 BP nodes' approval. -### Release a Proposal +#### Release a Proposal You can release a proposal when it gets approved. ```sh -$ aelf-command send AElf.ContractNames.Parliament Release bafe83ca4ec5b2a2f1e8016d09b21362c9345954a014379375f1a90b7afb43fb +$ aelf-command send AElf.ContractNames.Parliament Release 1df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f AElf [Info]: { TransactionId: '09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535' } ``` -### Get the Transaction Result +#### Get the Transaction Result Use the `get-tx-result` command to retrieve the details of the transaction: ```sh -$ aelf-command get-tx-result 09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535 +$ aelf-command get-tx-result b99c63fc8aa2572d1d8c7c65dd52ad01926ed985ce045e3c8ad3dabeb4c6f2ba +✔ Succeed! AElf [Info]: { - "TransactionId": "09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535", - "Status": "MINED", - "Logs": [ - { - "Address": "25CecrU94dmMdbhC3LWMKxtoaL4Wv8PChGvVJM6PxkHAyvXEhB", - "Name": "Transferred", - "Indexed": [ - "CiIKIJTPGZ24g4eHwSVNLit8jgjFJeeYCEEYLDpFiCeCT0Bf", - "EiIKIO0jJRxjHdRQmUTby8klRVSqYpwhOyUsnXYV3IrQg8N1", - "GgNFTEY=" - ], - "NonIndexed": "IICgt4fpBSomVC00MzFkMjc0Yi0zNWJjLTRjYzgtOGExZC1iODhhZTgxYzU2Zjc=" - } - ], - "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": "", - "Error": null -} -``` -The command outputs detailed information about the transaction, including its status, logs, and related block information. - - -### Decode the Logs for Readable Result - -```sh -$ aelf-command event 09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535 -``` - -This command provides a readable format of the events logged by the transaction. The output includes details such as the address, event name, indexed data, non-indexed data, and a decoded result. - -#### Example Breakdown - -Here is a sample output from the `get-tx-result` command: - -```sh -{ - "TransactionId": "09c8c824d2e3aea1d...cefe4e236c5b818d6a01d4f7ca0b60fe99535", + "TransactionId": "b99c63fc8aa2572d1d8c7c65dd52ad01926ed985ce045e3c8ad3dabeb4c6f2ba", "Status": "MINED", "Logs": [ { - "Address": "25CecrU94dmMdbhC3LWMKxtoaL4Wv8PChGvVJM6PxkHAyvXEhB", - "Name": "Transferred", + "Address": "vcv1qewcsFN2tVWqLuu7DJ5wVFA8YEx5FFgCQBb1jMCbAQHxV", + "Name": "ProposalCreated", "Indexed": [ - "CiIKIJTPGZ24g4eHwSVNLit8jgjFJeeYCEEYLDpFiCeCT0Bf", - "EiIKIO0jJRxjHdRQmUTby8klRVSqYpwhOyUsnXYV3IrQg8N1", - "GgNFTEY=" + "EiIKIExmVoQ5QtJW9cSejVogutsxgut28BnGDCX3Y+Chrlf3" ], - "NonIndexed": "IICgt4fpBSomVC00MzFkMjc0Yi0zNWJjLTRjYzgtOGExZC1iODhhZTgxYzU2Zjc=" + "NonIndexed": "CiIKIB3yd7yjZhzXREP7u3EfxDHK2Mz9a7RhKNP56LDYhdw/" } ], - "BlockNumber": 28411, - "BlockHash": "fa22e4eddff12a728895a608db99d40a4b21894f7c07df1a4fa8f0625eb914a2", + "Bloom": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAACAAAAAAAAAAAAAAAAAAEAAAAIAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAA==", + "BlockNumber": 126568091, + "BlockHash": "facc33cd87f39ee1d9ad38ca96c5cea82040f58737ab0a9faa19bf48b8623dc4", "Transaction": { - "From": "2tj7Ea67fuQfVAtQZ3WBmTv7AAJ8S9D2L4g6PpRRJei6JXk7RG", - "To": "29RDBXTqwnpWPSPHGatYsQXW2E17YrQUCj7QhcEZDnhPb6ThHW", - "RefBlockNumber": 28410, - "RefBlockPrefix": "0P+eTw==", - "MethodName": "Release", - "Params": "\"ad868c1e0d74127dd746ccdf3443a09459c55cf07d247df053ddf718df258c86\"", - "Signature": "DQcv55EBWunEFPXAbqZG20OLO5T0Sq/s0A+/iuwv1TdQqIV4318HrqFLsGpx9m3+sp5mzhAnMlrG7CSxM6EuIgA=" + "From": "GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk", + "To": "vcv1qewcsFN2tVWqLuu7DJ5wVFA8YEx5FFgCQBb1jMCbAQHxV", + "RefBlockNumber": 126568085, + "RefBlockPrefix": "lpdm9g==", + "MethodName": "CreateProposal", + "Params": "{ \"contractMethodName\": \"Transfer\", \"toAddress\": \"ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx\", \"params\": \"CiIKICREfSjQ2i95I6kXpBdiFAMlQb2j0NGkyBlfPszMA0/HEgNFTEYYgMLXLyIEdGVzdA==\", \"expiredTime\": \"2222-07-03T05:09:41.141Z\", \"organizationAddress\": \"aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG\" }", + "Signature": "B7RfSxydZK59oU6tqSK+Ojfo/VIvG92SVTUnGzN2bWER3uxuuhQ/axsSLbP28vjWYvPTfu+6i10W7y2Yl0ZrjQE=" }, - "ReturnValue": "", - "Error": null + "ReturnValue": "0a201df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f", + "Error": null, + "TransactionSize": 320 } ``` -### Understand the Decoded Event +The command outputs detailed information about the transaction, including its status, logs, and related block information. -After running the `event` command, the decoded event output is as follows: +#### Decode the Logs for Readable Result ```sh -{ - "Address": "25CecrU94dmMdbhC3LWMKxtoaL4Wv8PChGvVJM6PxkHAyvXEhB", - "Name": "Transferred", - "Indexed": [ - "CiIKIJTPGZ24g4eHwSVNLit8jgjFJeeYCEEYLDpFiCeCT0Bf", - "EiIKIO0jJRxjHdRQmUTby8klRVSqYpwhOyUsnXYV3IrQg8N1", - "GgNFTEY=" - ], - "NonIndexed": "IICgt4fpBSomVC00MzFkMjc0Yi0zNWJjLTRjYzgtOGExZC1iODhhZTgxYzU2Zjc=", - "Result": { - "from": "28Y8JA1i2cN6oHvdv7EraXJr9a1gY6D1PpJXw9QtRMRwKcBQMK", - "to": "2oSMWm1tjRqVdfmrdL8dgrRvhWu1FP8wcZidjS6wPbuoVtxhEz", - "symbol": "ELF", - "amount": "200000000000", - "memo": "T-431d274b-35bc-4cc8-8a1d-b88ae81c56f7" - } -} -``` - -#### Summary of Decoded Event +$ aelf-command event b99c63fc8aa2572d1d8c7c65dd52ad01926ed985ce045e3c8ad3dabeb4c6f2ba -**From Address**: 28Y8JA1i2cN6oHvdv7EraXJr9a1gY6D1PpJXw9QtRMRwKcBQMK -**To Address**: 2oSMWm1tjRqVdfmrdL8dgrRvhWu1FP8wcZidjS6wPbuoVtxhEz -**Symbol**: ELF -**Amount**: 200000000000 -**Memo**: T-431d274b-35bc-4cc8-8a1d-b88ae81c56f7 - -These steps and commands will help you retrieve and decode the transaction results on the ealf blockchain. - -For more details, check the descriptions of [`aelf-command event`](#event---deserialize-transaction-result). - - -# Deploy a smart contract - -**Note**: The `deploy` command has been deprecated. Please use `aelf-command` send or `aelf-command proposal` instead. - -#### Example Workflow - -#### 1.Check Chain Status - -```javascript -$ aelf-command get-chain-status -✔ Succeed -{ - "ChainId": "AELF", - "Branches": { - "41a8a1ebf037197b7e2f10a67d81f741d46a6af41775bcc4e52ab855c58c4375": 8681551, - "ed4012c21a2fbf810db52e9869ef6a3fb0629b36d23c9be2e3692a24703b3112": 8681597, - "13476b902ef137ed63a4b52b2902bb2b2fa5dbe7c256fa326c024a73dc63bcb3": 8681610 - }, - "NotLinkedBlocks": {}, - "LongestChainHeight": 8681610, - "LongestChainHash": "13476b902ef137ed63a4b52b2902bb2b2fa5dbe7c256fa326c024a73dc63bcb3", - "GenesisBlockHash": "cd5ce1bfa0cd97a1dc34f735c57bea2fcb9d88fc8f76bece2592fe7d82d5660c", - "GenesisContractAddress": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8", - "LastIrreversibleBlockHash": "4ab84cdfe0723b191eedcf4d2ca86b0f64e57105e61486c21d98d562b14f2ab0", - "LastIrreversibleBlockHeight": 8681483, - "BestChainHash": "0dbc2176aded950020577552c92c82e66504ea109d4d6588887502251b7e932b", - "BestChainHeight": 8681609 -} -``` - -#### 2. Deploy Smart Contract - -Use the Genesis Contract Address (`GenesisContractAddress`) as a parameter with `aelf-command send`. - - -```javascript -$ aelf-command send 2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8 DeploySmartContract -✔ Fetching contract successfully! - -If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file - -Enter the params one by one, type `Enter` to skip optional param: -? Enter the required param : 0 -? Enter the required param : /Users/test/contract.dll -... - -``` - -#### 3. Propose New Contract - -Use `aelf-command send` with `ProposeNewContract` method if required by the chain. - -```javascript -$ aelf-command send 2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8 ProposeNewContract -✔ Fetching contract successfully! - -If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file - -Enter the params one by one, type `Enter` to skip optional param: -? Enter the required param : 0 -? Enter the required param : /Users/test/contract.dll -... - -You must input contract method parameters in the prompting way. Note that you can input a relative or absolute path of a contract file to pass a file to `aelf-command`. It will read the file content and encode it as a base64 string. - -After calling `ProposeNewContract`, you can get the proposal id and `proposedContractInputHash` later by running: - -$ aelf-command event 34184cbc27c95bbc0a1bd676192c3afc380740ab61626e5d428ae17faf9ea984 [Info]: -The results returned by Transaction: 34184cbc27c95bbc0a1bd676192c3afc380740ab61626e5d428ae17faf9ea984 is: +The results returned by +Transaction: b99c63fc8aa2572d1d8c7c65dd52ad01926ed985ce045e3c8ad3dabeb4c6f2ba is: [ { - "Address": "pykr77ft9UUKJZLVq15wCH8PinBSjVRQ12sD1Ayq92mKFsJ1i", - "Name": "ContractProposed", - "Indexed": [], - "NonIndexed": "CiIKIK0dKXkwu/HDpZUf/tzjJSfcZ5XznUrE/C0XMtp4liqo", - "Result": { - "proposedContractInputHash": "ad1d297930bbf1c3a5951ffedce32527dc6795f39d4ac4fc2d1732da78962aa8" - } - }, - { - "Address": "2JT8xzjR5zJ8xnBvdgBZdSjfbokFSbF5hDdpUCbXeWaJfPDmsK", + "Address": "vcv1qewcsFN2tVWqLuu7DJ5wVFA8YEx5FFgCQBb1jMCbAQHxV", "Name": "ProposalCreated", "Indexed": [ - "EiIKIEknWCUo4/KJS/vDAf7u1R6JmLEfAcapRY1BZ9yogawl" + "EiIKIExmVoQ5QtJW9cSejVogutsxgut28BnGDCX3Y+Chrlf3" ], - "NonIndexed": "CiIKIFb/RK9tR/SjJn0z7d4AjUvw288KCwTRyXSYMMryQuC2", + "NonIndexed": "CiIKIB3yd7yjZhzXREP7u3EfxDHK2Mz9a7RhKNP56LDYhdw/", "Result": { - "organizationAddress": "ZDcYStbBRACaEQh6K1nqPb2SHKPCTggB9E66onthFoGrVnkfi", - "proposalId": "56ff44af6d47f4a3267d33edde008d4bf0dbcf0a0b04d1c9749830caf242e0b6" + "organizationAddress": "aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG", + "proposalId": "1df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f" } } ] - -Wait for the organization members to approve your proposal, and you can release your proposal by calling `ReleaseApprovedContract`. - -``` - - -#### 4. Release Approved Contract - -```javascript -$ aelf-command send 2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8 -✔ Fetching contract successfully! -? Pick up a contract method: ReleaseApprovedContract - -If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file - -Enter the params one by one, type `Enter` to skip optional param: -? Enter the required param : proposalId -? Enter the required param : proposedContractInputHash - -The params you entered are: -{ - "proposalId": proposalNewContract proposalId, - "proposedContractInputHash": proposedContractInputHash -} ✔ Succeed! +``` -And then you can get the code check proposal id from the event of `ReleaseApprovedContract` transaction. - -... - -{ - "Address": "2JT8xzjR5zJ8xnBvdgBZdSjfbokFSbF5hDdpUCbXeWaJfPDmsK", - "Name": "ProposalCreated", - "Indexed": [ - "EiIKIEknWCUo4/KJS/vDAf7u1R6JmLEfAcapRY1BZ9yogawl" - ], - "NonIndexed": "CiIKIAfOf/a3zIillggQjSl2N0Y3aEh8bRGK5ppBrc14CKSn", - "Result": { - "organizationAddress": "ZDcYStbBRACaEQh6K1nqPb2SHKPCTggB9E66onthFoGrVnkfi", - "proposalId": "07ce7ff6b7cc88a59608108d297637463768487c6d118ae69a41adcd7808a4a7" - } -} - -Wait for the code check to pass, then you can release the code check proposal by calling `ReleaseCodeCheck`. +This command provides a readable format of the events logged by the transaction. The output includes details such as the address, +event name, indexed data, non-indexed data, and a decoded result. -``` +##### Summary of Decoded Event -#### 5. Release Code-Checked Contract +**organizationAddress**: aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG **proposalId**: +1df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f -```javascript -$ aelf-command send 2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8 -a 28Y8JA1i2cN6oHvdv7EraXJr9a1gY6D1PpJXw9QtRMRwKcBQMK -p 123 -✔ Fetching contract successfully! -? Pick up a contract method: ReleaseCodeCheckedContract +These steps and commands will help you retrieve and decode the transaction results on the ealf blockchain. -If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file +For more details, check the descriptions of [`aelf-command event`](#event---deserialize-transaction-result). -Enter the params one by one, type `Enter` -``` +### Deploy a smart contract +**Note**: The `deploy` command has been deprecated. Please use `aelf-command` send or `aelf-command proposal` instead. -## event - Deserialize Transaction Result +### event - Deserialize Transaction Result -To view details from a transaction, including events triggered by contract methods, you can use the `aelf-command event` tool. Here’s how: +To view details from a transaction, including events triggered by contract methods, you can use the `aelf-command event` tool. +Here’s how: -```javascript -$ aelf-command event fe1974fde291e44e16c55db666f2c747323cdc584d616de05c88c8bae18ecceb +```sh +$ aelf-command event ef17ac2078c2b31a702b9edc754bfa56f1c37931f52f9dd8e2b9dc65769966b1 [Info]: The results returned by -Transaction: fe1974fde291e44e16c55db666f2c747323cdc584d616de05c88c8bae18ecceb is: +Transaction: ef17ac2078c2b31a702b9edc754bfa56f1c37931f52f9dd8e2b9dc65769966b1 is: [ { - "Address": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8", - "Name": "ContractDeployed", + "Address": "ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx", + "Name": "Transferred", "Indexed": [ - "CiIKIN2O6lDDGWbgbkomYr6+9+2B0JpHsuses3KfLwzHgSmu", - "EiIKIDXZGwZLKqm78WpYDXuBlyd6Dv+RMjrgOUEnwamfIA/z" + "CiIKIKl+hAq40lOArRO+3srxpNVRFOaGZtH4WUSLGW7qDyoI", + "EiIKINhKsag9MOuJ2sbYwzlGfKCeOcGHu4qPWYp6DeqjrOZw", + "GgNFTEY=" ], - "NonIndexed": "GiIKIN2O6lDDGWbgbkomYr6+9+2B0JpHsuses3KfLwzHgSmu", + "NonIndexed": "IICglKWNHQ==", "Result": { - "author": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8", - "codeHash": "35d91b064b2aa9bbf16a580d7b8197277a0eff91323ae0394127c1a99f200ff3", - "address": "2gaQh4uxg6tzyH1ADLoDxvHA14FMpzEiMqsQ6sDG5iHT8cmjp8" + "from": "2HeW7S9HZrbRJZeivMppUuUY3djhWdfVnP5zrDsz8wqq6hKMfT", + "to": "2eFtDbjWBDPJ6oNtRLjYuS5XrtjSzw4CnrCM79U1HjdvKkGYrF", + "symbol": "ELF", + "amount": "1000000000000" } } ] ✔ Succeed! -```` +``` #### Explanation: -When you execute this command, you'll get details about the transaction with ID fe1974fde291e44e16c55db666f2c747323cdc584d616de05c88c8bae18ecceb. Here's what the output means: +When you execute this command, you'll get details about the transaction with ID +fe1974fde291e44e16c55db666f2c747323cdc584d616de05c88c8bae18ecceb. Here's what the output means: -- **Address**: The contract address where the event occurred. -- **Name**: The name of the event triggered by a contract method. -- **Indexed**: Additional data related to the event, encoded in base64 format. -- **NonIndexed**: Further details about the event, also in base64. +- **from**: 表示发送方的地址,即交易中的发起者 +- **to**: 表示接收方的地址,即交易中的接收者 +- **symbol**: 表示交易的代币符号 +- **amount**: 表示交易的数量或金额. - **Result**: Decoded information from the event, providing readable details such as author, code hash, and address. +This command helps you understand what happened during a transaction, especially useful when dealing with events triggered by +smart contracts. -This command helps you understand what happened during a transaction, especially useful when dealing with events triggered by smart contracts. - -## send - Send a transaction - -#### 1. Enter aelf Node URI: - -```javascript -$ aelf-command send -✔ Enter the URI of an AElf node … http://13.231.179.27:8000 -``` - -You need to specify the URI of an aelf blockchain node to which you will connect. - -#### 2. Enter Wallet Address and Password: - +### send - Send a transaction ```sh -✔ Enter a valid wallet address, if you do not have, create one by aelf-command create … D3vSjRYL8MpeRpvUDy85ktXijnBe2tHn8NTACsggUVteQCNGP -✔ Enter the password you typed when creating a wallet … ******** -``` - -Provide your wallet address and the password associated with it. This is necessary to sign transactions. - - -#### 3. Enter Contract Information: - -```sh -✔ Enter contract name (System contracts only) or the address of contract … AElf.ContractNames.Token +$ aelf-command send AElf.ContractNames.Referendum ✔ Fetching contract successfully! -``` - -Specify the contract name or address. In this example, AElf.ContractNames.Token refers to the Token contract. - - -#### 4. Select Contract Method: - -```bash -? Pick up a contract method: Transfer -``` - -Choose the specific method of the contract you want to invoke. Here, `Transfer` is selected. +? Pick up a contract method: CreateOrganization -#### 5. Enter Method Parameters: +If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file -```sh Enter the params one by one, type `Enter` to skip optional param: -? Enter the required param : C91b1SF5mMbenHZTfdfbJSkJcK7HMjeiuwfQu8qYjGsESanXR -? Enter the required param : ELF -? Enter the required param : 100000000 -? Enter the required param : 'test command' -``` - -Input the required parameters for the `Transfer` method: recipient address (`to`), token symbol (`symbol`), amount (`amount`), and an optional memo (`memo`). - -#### 6. Confirmation and Execution: - -```sh +? Enter the required param : ELF +? Enter the required param : 1 +? Enter the required param : 0 +? Enter the required param : 0 +? Enter the required param : 1 +? Enter the required param : ["GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk"] +? Enter the required param : The params you entered is: { - "to": "C91b1SF5mMbenHZTfdfbJSkJcK7HMjeiuwfQu8qYjGsESanXR", - "symbol": "ELF", - "amount": 100000000, - "memo": "'test command'" + "tokenSymbol": "ELF", + "proposalReleaseThreshold": { + "minimalApprovalThreshold": 1, + "maximalRejectionThreshold": 0, + "maximalAbstentionThreshold": 0, + "minimalVoteThreshold": 1 + }, + "proposerWhiteList": { + "proposers": [ + "GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk" + ] + } } ✔ Succeed! -``` - -Confirm the parameters you entered and proceed with the transaction. - - -#### 7. Transaction Result: - -```css AElf [Info]: Result: { - "TransactionId": "85d4684cb6e4721a63893240f73f675ac53768679c291abeb54974ff4e063bb5" + "TransactionId": "0106c04d7918d7634ad0ef9499b5366458d14ce87f735e4d39d3587052840bc1" } ✔ Succeed! ``` -The transaction is executed successfully, and you receive the `TransactionId` as confirmation. - - -By following these steps, you can effectively send transactions on the aelf blockchain using the `aelf-command send` interface. Adjust parameters and contract names as necessary for different contract methods or system contracts within AElf. - - -## call - Call a read-only method on a contract +You can effectively send transactions on the aelf blockchain using the `aelf-command send` interface. Adjust parameters and +contract names as necessary for different contract methods or system contracts within AElf. +### call - Call a read-only method on a contract ```sh -$ aelf-command call -✔ Enter the the URI of an AElf node … http://13.231.179.27:8000 -✔ Enter a valid wallet address, if you do not 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 +$ aelf-command call AElf.ContractNames.Parliament GetDefaultOrganizationAddress ✔ Fetching contract successfully! -? Pick up a contract method: GetTokenInfo - -If you need to pass file contents as a parameter, you can enter the relative or absolute path of the file - -Enter the params one by one, type `Enter` to skip optional param: -? Enter the required param : ELF -The params you entered is: -{ - "symbol": "ELF" -} ✔ Calling method successfully! AElf [Info]: Result: -{ - "symbol": "ELF", - "tokenName": "Native Token", - "supply": "99732440917954549", - "totalSupply": "100000000000000000", - "decimals": 8, - "issuer": "FAJcKnSpbViZfAufBFzX4nC8HtuT93rxUS4VCMACUwXWYurC2", - "isBurnable": true, - "issueChainId": 9992731, - "burned": "267559132045477" -} +"aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG" ✔ Succeed! ``` -```sh -aelf-command call AElf.ContractNames.Token GetTokenInfo '{"symbol":"ELF"}' -``` - -## get-chain-status - Get the current status of the block chain +### get-chain-status - Get the current status of the block chain ```sh $ aelf-command get-chain-status @@ -745,44 +512,40 @@ $ aelf-command get-chain-status } ``` - ## get-tx-result - Get a transaction result ```sh -$ aelf-command get-tx-result -✔ Enter the the URI of an AElf node … http://13.231.179.27:8000 -✔ Enter a valid transaction id 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-tx-result b99c63fc8aa2572d1d8c7c65dd52ad01926ed985ce045e3c8ad3dabeb4c6f2ba -```sh -$ aelf-command get-blk-height -✔ Enter the the URI of an AElf node … http://13.231.179.27:8000 -> 7902091 +AElf [Info]: { + "TransactionId": "b99c63fc8aa2572d1d8c7c65dd52ad01926ed985ce045e3c8ad3dabeb4c6f2ba", + "Status": "MINED", + "Logs": [ + { + "Address": "vcv1qewcsFN2tVWqLuu7DJ5wVFA8YEx5FFgCQBb1jMCbAQHxV", + "Name": "ProposalCreated", + "Indexed": [ + "EiIKIExmVoQ5QtJW9cSejVogutsxgut28BnGDCX3Y+Chrlf3" + ], + "NonIndexed": "CiIKIB3yd7yjZhzXREP7u3EfxDHK2Mz9a7RhKNP56LDYhdw/" + } + ], + "Bloom": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAACAAAAAAAAAAAAAAAAAAEAAAAIAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAA==", + "BlockNumber": 126568091, + "BlockHash": "facc33cd87f39ee1d9ad38ca96c5cea82040f58737ab0a9faa19bf48b8623dc4", + "Transaction": { + "From": "GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk", + "To": "vcv1qewcsFN2tVWqLuu7DJ5wVFA8YEx5FFgCQBb1jMCbAQHxV", + "RefBlockNumber": 126568085, + "RefBlockPrefix": "lpdm9g==", + "MethodName": "CreateProposal", + "Params": "{ \"contractMethodName\": \"Transfer\", \"toAddress\": \"ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx\", \"params\": \"CiIKICREfSjQ2i95I6kXpBdiFAMlQb2j0NGkyBlfPszMA0/HEgNFTEYYgMLXLyIEdGVzdA==\", \"expiredTime\": \"2222-07-03T05:09:41.141Z\", \"organizationAddress\": \"aeXhTqNwLWxCG6AzxwnYKrPMWRrzZBskW3HWVD9YREMx1rJxG\" }", + "Signature": "B7RfSxydZK59oU6tqSK+Ojfo/VIvG92SVTUnGzN2bWER3uxuuhQ/axsSLbP28vjWYvPTfu+6i10W7y2Yl0ZrjQE=" + }, + "ReturnValue": "0a201df277bca3661cd74443fbbb711fc431cad8ccfd6bb46128d3f9e8b0d885dc3f", + "Error": null, + "TransactionSize": 320 +} ``` ## get-blk-info - Get the block info by a block height or a block hash @@ -790,47 +553,38 @@ $ aelf-command get-blk-height Either a block height or a block hash can be provided as an argument to this sub-command. ```sh -$ aelf-command get-blk-info -✔ Enter the the URI of an AElf node: http://13.231.179.27:8000 -✔ Enter a valid height or block hash: 123 -✔ Include transactions whether or not: no / yes -{ BlockHash: - '6034db3e02e283d3b81a4528442988d28997d3828f87cca1a89457b294517372', - Header: - { PreviousBlockHash: - '9d6bcc588c0bc10942899e7ec4536665c86f23286029ed45287babf22c582f5a', - MerkleTreeRootOfTransactions: - '7ceb349715787ececa647ad48576467d294de6dcc44d14e19f60c4a91a7a9536', - MerkleTreeRootOfWorldState: - 'b529e2775283edc39cd4e3f685616085b18bd5521a87ea7904ad99cd2dc50910', - Extra: - '[ "CkEEJT3FEw+k9cuqv7uruq1fEwQwEjKtYxbXK86wUGrAOH7BgCVkMendLkQZmpEpMgzcz+JXnaVpWtFt3AJcGmGycxL+DggIEvIDCoIBMDQyNTNkYzUxMzBmYTRmNWNiYWFiZmJiYWJiYWFkNWYxMzA0MzAxMjMyYWQ2MzE2ZDcyYmNlYjA1MDZhYzAzODdlYzE4MDI1NjQzMWU5ZGQyZTQ0MTk5YTkxMjkzMjBjZGNjZmUyNTc5ZGE1Njk1YWQxNmRkYzAyNWMxYTYxYjI3MxLqAggCIiIKIOAP2QU8UpM4u9Y3OxdKdI5Ujm3DSyQ4JaRNf7q5ka5mKiIKIH5yNJs87wb/AkWcIrCxvCX/Te3fGHVXFxE8xsnfT1HtMgwIoJro6AUQjOa1pQE4TkqCATA0MjUzZGM1MTMwZmE0ZjVjYmFhYmZiYmFiYmFhZDVmMTMwNDMwMTIzMmFkNjMxNmQ3MmJjZWIwNTA2YWMwMzg3ZWMxODAyNTY0MzFlOWRkMmU0NDE5OWE5MTI5MzIwY2RjY2ZlMjU3OWRhNTY5NWFkMTZkZGMwMjVjMWE2MWIyNzNiIgogHY83adsNje+EtL0lLEte8KfT6X/836zXZTbntbqyjgtoBHAEegwIoJro6AUQzOybpgF6DAigmujoBRCk8MG1AnoLCKGa6OgFEOCvuBF6CwihmujoBRCg/JhzegwIoZro6AUQ9Lml1wF6DAihmujoBRDYyOO7AnoMCKGa6OgFEKy+ip8DkAEOEp8CCoIBMDQ4MWMyOWZmYzVlZjI5NjdlMjViYTJiMDk0NGVmODQzMDk0YmZlOTU0NWFhZGFjMGQ3Nzk3MWM2OTFjZTgyMGQxYjNlYzQxZjNjMDllNDZjNmQxMjM2NzA5ZTE1ZTEyY2U5N2FhZGNjYTBmZGU4NDY2M2M3OTg0OWZiOGYwM2RkMhKXAQgEMgwIpJro6AUQjOa1pQE4IkqCATA0ODFjMjlmZmM1ZWYyOTY3ZTI1YmEyYjA5NDRlZjg0MzA5NGJmZTk1NDVhYWRhYzBkNzc5NzFjNjkxY2U4MjBkMWIzZWM0MWYzYzA5ZTQ2YzZkMTIzNjcwOWUxNWUxMmNlOTdhYWRjY2EwZmRlODQ2NjNjNzk4NDlmYjhmMDNkZDISnwIKggEwNDFiZTQwMzc0NjNjNTdjNWY1MjgzNTBhNjc3ZmRkZmEzMzcxOWVlZjU5NDMwNDY5ZTlmODdkY2IyN2Y0YTQ1NjY0OTI4NmZhNzIxYzljOWVjZDMxMmY0YjdlZDBmZGE4OTJmZTNlZDExZWFjYTBmMzcxOTBkMjAzYTczYTA2YjFmEpcBCAYyDAiomujoBRCM5rWlATgySoIBMDQxYmU0MDM3NDYzYzU3YzVmNTI4MzUwYTY3N2ZkZGZhMzM3MTllZWY1OTQzMDQ2OWU5Zjg3ZGNiMjdmNGE0NTY2NDkyODZmYTcyMWM5YzllY2QzMTJmNGI3ZWQwZmRhODkyZmUzZWQxMWVhY2EwZjM3MTkwZDIwM2E3M2EwNmIxZhKfAgqCATA0OTMzZmYzNDRhNjAxMTdmYzRmYmRmMDU2ODk5YTk0NDllNjE1MzA0M2QxYzE5MWU4NzlkNjlkYzEzZmIyMzM2NWJmNTQxZWM1NTU5MWE2MTQ3YmM1Y2M3ZjUzMjQ0OTY2ZGE5NzA2ZWZmNzZiY2Y2ZjViY2EyOTYzNmVmODNkYzYSlwEICjIMCLCa6OgFEIzmtaUBOCJKggEwNDkzM2ZmMzQ0YTYwMTE3ZmM0ZmJkZjA1Njg5OWE5NDQ5ZTYxNTMwNDNkMWMxOTFlODc5ZDY5ZGMxM2ZiMjMzNjViZjU0MWVjNTU1OTFhNjE0N2JjNWNjN2Y1MzI0NDk2NmRhOTcwNmVmZjc2YmNmNmY1YmNhMjk2MzZlZjgzZGM2EpUDCoIBMDRiNmMwNzcxMWJjMzBjZGY5OGM5ZjA4MWU3MDU5MWY5OGYyYmE3ZmY5NzFlNWExNDZkNDcwMDlhNzU0ZGFjY2ViNDY4MTNmOTJiYzgyYzcwMDk3MWFhOTM5NDVmNzI2YTk2ODY0YTJhYTM2ZGE0MDMwZjA5N2Y4MDZiNWFiZWNhNBKNAggIEAEyDAismujoBRCM5rWlATgwQAJKggEwNGI2YzA3NzExYmMzMGNkZjk4YzlmMDgxZTcwNTkxZjk4ZjJiYTdmZjk3MWU1YTE0NmQ0NzAwOWE3NTRkYWNjZWI0NjgxM2Y5MmJjODJjNzAwOTcxYWE5Mzk0NWY3MjZhOTY4NjRhMmFhMzZkYTQwMzBmMDk3ZjgwNmI1YWJlY2E0egwInJro6AUQjOa1pQF6DAicmujoBRCkz+mjAnoMCJya6OgFEIj8yfECegwInJro6AUQ7KiH0wN6CwidmujoBRCko6hXegwInZro6AUQ6LTNugF6DAidmujoBRCY4NObAnoMCJ2a6OgFEMzWv+oCkAEQIFg6ggEwNGI2YzA3NzExYmMzMGNkZjk4YzlmMDgxZTcwNTkxZjk4ZjJiYTdmZjk3MWU1YTE0NmQ0NzAwOWE3NTRkYWNjZWI0NjgxM2Y5MmJjODJjNzAwOTcxYWE5Mzk0NWY3MjZhOTY4NjRhMmFhMzZkYTQwMzBmMDk3ZjgwNmI1YWJlY2E0QAIYBQ==", "" ]', - Height: 123, - Time: '2019-07-01T13:39:45.8704899Z', - ChainId: 'AELF', - Bloom: - '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - SignerPubkey: - '04253dc5130fa4f5cbaabfbbabbaad5f1304301232ad6316d72bceb0506ac0387ec180256431e9dd2e44199a9129320cdccfe2579da5695ad16ddc025c1a61b273' }, - Body: - { TransactionsCount: 1, - Transactions: - [ 'a365a682caf3b586cbd167b81b167979057246a726c7282530554984ec042625' ] } } -``` - - -```sh -aelf-command get-blk-info ca61c7c8f5fc1bc8af0536bc9b51c61a94f39641a93a748e72802b3678fea4a9 true +$ aelf-command get-blk-info 7900508 +✔ Succeed! +AElf [Info]: + { + BlockHash: 'e16e08c916765968de862b1358c618817f4ccc5c5c8f10d64e75e8208902f410', + Header: { + PreviousBlockHash: '6489ca5330884565b80de5de97cdcef5113bd1f1697b0bb561faabcef6505679', + MerkleTreeRootOfTransactions: 'e5e8482f2bbf7d9add7408552e34a746a4d6873866b0ac86ffd25d533236c3cd', + MerkleTreeRootOfWorldState: '7345ea86e722e18aa9eadb5a86ee91cf96fa66c756f72417d93520d3ab3dd5af', + MerkleTreeRootOfTransactionState: '3de130b601adb26673918126687308d6b37bcae3cba8fbc7bc66d63bbea28ccd', + Extra: '{ "CrossChain": "", "Consensus": "CkEELSIQWlfBBh3Tz26IuzGb91RXYmnerlhu0QDIR8qx0/G1V3PDH15zlnD1P9Tw2Fn7umvPjSgPFd6Nu8RRGBUXqxKuBwjmpwoS+QIKggEwNDJkMjIxMDVhNTdjMTA2MWRkM2NmNmU4OGJiMzE5YmY3NTQ1NzYyNjlkZWFlNTg2ZWQxMDBjODQ3Y2FiMWQzZjFiNTU3NzNjMzFmNWU3Mzk2NzBmNTNmZDRmMGQ4NTlmYmJhNmJjZjhkMjgwZjE1ZGU4ZGJiYzQ1MTE4MTUxN2FiEvEBOIK7YEqCATA0MmQyMjEwNWE1N2MxMDYxZGQzY2Y2ZTg4YmIzMTliZjc1NDU3NjI2OWRlYWU1ODZlZDEwMGM4NDdjYWIxZDNmMWI1NTc3M2MzMWY1ZTczOTY3MGY1M2ZkNGYwZDg1OWZiYmE2YmNmOGQyODBmMTVkZThkYmJjNDUxMTgxNTE3YWJqCwiA+9mWBhDIgIlvagwIgPvZlgYQlJ2m1QFqDAiA+9mWBhDwhoOcAmoMCID72ZYGELjnzOsCagwIgPvZlgYQoMqgrQNqCwiB+9mWBhCw/KwRagsIgfvZlgYQ3LLFUYABB4gB1priAxKHAQqCATA0ZTgyYjcyMTk4ODZiYTU0YWIwYjU4ZWNlOWMyMzQyMmRlOWVlMDkyZTg5NDExODFjZGJkM2Q4ZDJkMjRlMzY5OGY0YjI2NWFlYmRkM2IwMWQyOWFlODU0ZDYyZWU5NDI3MTk4YTQxZTdmZTNkYjMyMmJlN2M5YzJmNjYyZjc3Y2QSABKHAQqCATA0MzU3YjFhZDhjMDU3NmQyNmFhM2Q2YjJkMDliMmFkMDNiZjVkYmNlMjIzNzMwNjM2MTQ1Y2Y0NDNmZWIzN2ZiMTkxNTZiOTkxOTRmYTQ4YWQ5MjU2NmI5NWM0NTQ5MzlkZjJjYTcxZTliZjUxN2MyNTkwYzJlZWRkZDc2Y2Y5MWUSABKHAQqCATA0Nzc5NGU1YjQyNDE3N2JmMDNmOWQ1ZTU0MWU3YmRhMjgwNTYyMDlkODE0YzY4YWVkMjY3MGU0NmQ5NjNjODVkMDRkYTVmNjllZjgyNDU4ZTg2MTc0ODkwNzQzOTg1ZTI5Nzg0MzQ4NWIxMGQwMjk1ZmMyOGI4ODUzMzU1Y2ZiOGISABKHAQqCATA0NTI3NjJlYzIxZmVkMjlmNGNiODZkZjNmYzA4ZjAyYTIzODVjODRkNDVkZmQ0ZWY1NDAwNTk3M2I0MWY1YWIyNjRlMmU1ZGUwZDQ2ZWM0NWU2NDkxYjk4MTA1MDM4MGIwYWExOTcxNGFmNGYwODc4NTYwMzIxODkzZTYyNjMxZTQSAFDY5sHxHhgE", "SystemTransactionCount": "CAI=" }', + Height: 7900508, + Time: '2022-07-19T09:46:41.1710063Z', + ChainId: 'tDVW', + Bloom: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==', + SignerPubkey: '042d22105a57c1061dd3cf6e88bb319bf754576269deae586ed100c847cab1d3f1b55773c31f5e739670f53fd4f0d859fbba6bcf8d280f15de8dbbc451181517ab' + }, + Body: { + TransactionsCount: 2, + Transactions: [ + '26b346d1042423850627059991fb426a520d43393f8a1b28a58353e18bd9384c', + '45314ca224418c43a4dc2c0b1a9fe491c0ad1f4e099bade676b219d29f4dcf75' + ] + }, + BlockSize: 1456 +} ``` - ## console - Open an interactive console ```sh $ aelf-command console -✔ Enter the the URI of an AElf node … http://13.231.179.27:8000 -✔ Enter a valid wallet address, if you do not 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 @@ -848,16 +602,16 @@ Welcome to aelf interactive console. Ctrl + C to terminate the program. Double t ╚═══════════════════════════════════════════════════════════╝ ``` -## dapp-server - Start a socket.io server for supplying services for dApps +### dapp-server - Start a socket.io server for supplying services for dApps -Are you developing a dApp and need an environment to manage wallet information and connect to the AElf chain? You can easily start a local development server using this sub-command. +Are you developing a dApp and need an environment to manage wallet information and connect to the AElf chain? You can easily start +a local development server using this sub-command. ```shell $ aelf-command dapp-server AElf [Info]: DApp server is listening on port 35443 ``` - Alternatively, you can specify a different port: ```shell @@ -865,8 +619,8 @@ $ aelf-command dapp-server --port 40334 AElf [Info]: DApp server is listening on port 40334 ``` - -This server uses Socket.io to listen on the specified local port. You can use aelf-bridge to connect to this server with the following code: +This server uses Socket.io to listen on the specified local port. You can use aelf-bridge to connect to this server with the +following code: ```javascript import AElfBridge from 'aelf-bridge'; @@ -881,5 +635,5 @@ const bridgeInstance = new AElfBridge({ bridgeInstance.connect().then(console.log).catch(console.error); ``` - -For more details, check out the [aelf-bridge](https://github.com/AElfProject/aelf-js-bridge) and [aelf-bridge-demo](https://github.com/AElfProject/aelf-bridge-demo). \ No newline at end of file +For more details, check out the [aelf-bridge](https://github.com/AElfProject/aelf-js-bridge) and +[aelf-bridge-demo](https://github.com/AElfProject/aelf-bridge-demo). \ No newline at end of file diff --git a/docs/tools/chain-sdk/javascript-sdk/index.md b/docs/tools/chain-sdk/javascript-sdk/index.md index b127e01a..c213423e 100644 --- a/docs/tools/chain-sdk/javascript-sdk/index.md +++ b/docs/tools/chain-sdk/javascript-sdk/index.md @@ -5,62 +5,161 @@ description: Javascript SDK image: /img/Logo.aelf.svg --- -# aelf-sdk.js - aelf JavaScript API +# aelf-web3.js - aelf JavaScript API ## Introduction -The `aelf-sdk.js` library for aelf is similar to web3.js for Ethereum. It allows you to interact with a local or remote aelf node using an HTTP connection. +The `aelf-web3.js` library for aelf is similar to web3.js for Ethereum. It allows you to interact with a local or remote aelf node using an HTTP connection. -This guide will help you install and use `aelf-sdk.js`, with an API reference and examples. +This guide will help you install and use `aelf-web3.js`, with an API reference and examples. -For more details, check out the repository: [aelf-sdk.js](https://github.com/AElfProject/aelf-web3.js). +For more details, check out the repository: [aelf-web3.js](https://github.com/AElfProject/aelf-web3.js). +## Quickstart -## Adding aelf-sdk.js +### Adding aelf-web3.js -First, you need to add `aelf-sdk.js` to your project. You can do this using the following methods +First you need to get aelf-sdk.js into your project. This can be done using the following methods: +npm: `npm install aelf-sdk` -### Using npm +pure js: `link dist/aelf.umd.js` -```sh -npm install aelf-sdk +After that you need to create a aelf instance and set a provider. + +```js +// 1.In node.js use: const AElf = require('aelf-sdk'); +// 2.FrontEnd freshman, add following tag in html +// +const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); +``` + +### Detail information for library files + +你可以跳过这一步,如果 Adding aelf-web3.js 这一步已经足够的话 + +In our dist directory, we supply two kinds of packages for different platforms, such as Node and Browser. + +| packages | usage | +| ---------------- | ------------------------------------------------------------ | +| dist/aelf.cjs.js | built for node, remove node built-in modules such as crypto. | +| dist/aelf.umd.js | built for browser, add some node built-in modules by webpack | + +You can choose any packages based on your need, for examples: + +if you are new to FrontEnd, you can use `AElf-sdk` by add a script tag in your html files. + +```html + + ``` -### Pure JS +if you want to use a bundle system such as webpack or rollup, and build your applications for Node.js and Browsers, just import the specified version of package files. -Add the script link in your HTML: +#### For browser usage and use UMD + +Webpack: ```javascript - +module.exports = { + // ... + resolve: { + alias: { + 'aelf-sdk$': 'aelf-sdk/dist/aelf.umd.js' + } + } +}; ``` -Then, create an aelf instance and set a provider. +Rollup: ```javascript -// In Node.js -const AElf = require('aelf-sdk'); -const aelf = new AElf(new AElf.providers.HttpProvider('http://127.0.0.1:8000')); +const alias = require('rollup-plugin-alias'); + +rollup({ + // ... + plugins: [ + alias({ + 'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.umd.js') + }) + ] +}); +``` + +#### For Node.js usage and use commonjs module system + +Webpack: + +```javascript +module.exports = { + // ... + resolve: { + alias: { + 'aelf-sdk$': 'aelf-sdk/dist/aelf.cjs.js' + } + } +}; +``` + +Rollup: + +```javascript +const alias = require('rollup-plugin-alias'); + +rollup({ + // ... + plugins: [ + alias({ + 'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.cjs.js') + }) + ] +}); +``` + +## 🔨Development + +1. Install dev dependencies + +```bash +yarn install +``` + +2. 在 src 下创建你的文件,编写你的逻辑 +3. 在 src/index 下看一下是否需要将你新增的模块挂在 AElf 作为实例的一个属性 +4. 在根目录执行`yarn link`,这会创建一个全局的符号链接到本包,并将其存储在全局 node_modules 目录中 +5. 在其他目录使用`yarn link "aelf-sdk"`,请确保你 link 的包的版本是正确的,因为有时候 node 版本不一致也可能会导致 link 到的 aelf-web3.js 版本不对 + +接着你就可以试一下自己的刚写的逻辑是否 ok -// In browser -// +### Lint + +```sh +yarn lint +``` + +### Tests + +```sh +# Unit tests +yarn test ``` +## Basic usage -## Examples +### Examples -You can find more examples in the `./examples` directory. +You can also see full examples in `./examples`; -### Create Instance +#### Create Instance ```javascript import AElf from 'aelf-sdk'; // Create a new instance of AElf -const aelf = new AElf(new AElf.providers.HttpProvider('http://127.0.0.1:1235')); +const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); ``` -### Create or Load a Wallet +#### Create or Load a Wallet ```javascript // Create a new wallet @@ -73,8 +172,7 @@ const privateKeyWallet = AElf.wallet.getWalletByPrivateKey('your-private-key'); const mnemonicWallet = AElf.wallet.getWalletByMnemonic('your-mnemonic'); ``` - -### Get a System Contract Address +#### Get a System Contract Address ```javascript const tokenContractName = 'AElf.ContractNames.Token'; @@ -92,8 +190,7 @@ let tokenContractAddress; })(); ``` - -### Get a Contract Instance +#### Get a Contract Instance ```javascript const wallet = AElf.wallet.createNewWallet(); @@ -105,10 +202,9 @@ let tokenContract; })(); // Promise method -aelf.chain.contractAt(tokenContractAddress, wallet) - .then(result => { - tokenContract = result; - }); +aelf.chain.contractAt(tokenContractAddress, wallet).then(result => { + tokenContract = result; +}); // Callback method aelf.chain.contractAt(tokenContractAddress, wallet, (error, result) => { @@ -117,8 +213,7 @@ aelf.chain.contractAt(tokenContractAddress, wallet, (error, result) => { }); ``` - -### Use Contract Instance +#### Use Contract Instance How to use a contract instance. You can call methods in two ways: read-only and send transaction. @@ -126,8 +221,8 @@ How to use a contract instance. You can call methods in two ways: read-only and (async () => { // Read-only method: Get the balance of an address const balanceResult = await tokenContract.GetBalance.call({ - symbol: "ELF", - owner: "7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz" + symbol: 'ELF', + owner: '7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz' }); console.log(balanceResult); /** @@ -140,10 +235,10 @@ How to use a contract instance. You can call methods in two ways: read-only and // Send transaction method: Transfer tokens const transactionId = await tokenContract.Transfer({ - symbol: "ELF", - to: "7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz", - amount: "1000000000", - memo: "transfer in demo" + symbol: 'ELF', + to: '7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz', + amount: '1000000000', + memo: 'transfer in demo' }); console.log(transactionId); /** @@ -154,24 +249,22 @@ How to use a contract instance. You can call methods in two ways: read-only and })(); ``` - ### Change the Node Endpoint ```javascript import AElf from 'aelf-sdk'; -const aelf = new AElf(new AElf.providers.HttpProvider('http://127.0.0.1:1235')); -aelf.setProvider(new AElf.providers.HttpProvider('http://127.0.0.1:8000')); +const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); +aelf.setProvider(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); ``` - ## Web API -You can access the Web API of your aelf node at `{chainAddress}/swagger/index.html`. +You can access the Web API of your aelf node at `{chainAddress}/swagger/index.html`. For example, if your local node address is `http://127.0.0.1:1235`, you can view the Web API at `http://127.0.0.1:1235/swagger/index.html`. -parameters and returns based on the URL: [https://aelf-public-node.aelf.io/swagger/index.html](https://aelf-public-node.aelf.io/swagger/index.html) +我们的测试网节点地址是:[https://aelf-test-node.aelf.io/swagger/index.html](https://aelf-test-node.aelf.io/swagger/index.html)(主链)、[https://tdvw-test-node.aelf.io/swagger/index.html](https://tdvw-test-node.aelf.io/swagger/index.html)(侧链),可以访问这两个地址找到对应的参数和返回值。 The methods below use an instance of aelf. If you don't have one, create it as shown: @@ -191,29 +284,26 @@ Get the current status of the blockchain. - **Parameters**: None - **Returns**: `Object` - - `ChainId` - String - - `Branches` - Object - - `NotLinkedBlocks` - Object - - `LongestChainHeight` - Number - - `LongestChainHash` - String - - `GenesisBlockHash` - String - - `GenesisContractAddress` - String - - `LastIrreversibleBlockHash` - String - - `LastIrreversibleBlockHeight` - Number - - `BestChainHash` - String - - `BestChainHeight` - Number - + - `ChainId` - String + - `Branches` - Object + - `NotLinkedBlocks` - Object + - `LongestChainHeight` - Number + - `LongestChainHash` - String + - `GenesisBlockHash` - String + - `GenesisContractAddress` - String + - `LastIrreversibleBlockHash` - String + - `LastIrreversibleBlockHeight` - Number + - `BestChainHash` - String + - `BestChainHeight` - Number #### Example: ```javascript -aelf.chain.getChainStatus() - .then(res => { - console.log(res); - }); +aelf.chain.getChainStatus().then(res => { + console.log(res); +}); ``` - ### 2. Get Contract File Descriptor Set Get the protobuf definitions related to a contract. @@ -223,38 +313,31 @@ Get the protobuf definitions related to a contract. - **Parameters**: `contractAddress` (String) - **Returns**: `String`. - #### Example: ```javascript -aelf.chain.getContractFileDescriptorSet(contractAddress) - .then(res => { - console.log(res); - }); +aelf.chain.getContractFileDescriptorSet(contractAddress).then(res => { + console.log(res); +}); ``` - ### 3. Get Block Height Get the current best height of the chain. - - **Web API Path**: `/api/blockChain/blockHeight` - **Method**: GET - **Parameters**: None - **Returns**: `Number`. - #### Example: ```javascript -aelf.chain.getBlockHeight() - .then(res => { - console.log(res); - }); +aelf.chain.getBlockHeight().then(res => { + console.log(res); +}); ``` - ### 4. Get Block Get block information by block hash. @@ -262,42 +345,40 @@ Get block information by block hash. - **Web API Path**: `/api/blockChain/block` - **Method**: GET - **Parameters**: - - **`blockHash`** (String) - - **`includeTransactions`** (Boolean) - - `true` require transaction ids list in the block - - `false` Doesn’t require transaction ids list in the block + + - **`blockHash`** (String) + - **`includeTransactions`** (Boolean) + - `true` require transaction ids list in the block + - `false` Doesn’t require transaction ids list in the block - **Returns**: `Object` - - - `BlockHash` - String - - - `Header` - Object - - `PreviousBlockHash` - String - - `MerkleTreeRootOfTransactions` - String - - `MerkleTreeRootOfWorldState` - String - - `Extra` - Array - - `Height` - Number - - `Time` - google.protobuf.Timestamp - - `ChainId` - String - - `Bloom` - String - - `SignerPubkey` - String - - - `Body` - Object - - `TransactionsCount` - Number - - `Transactions` - Array - - `transactionId` - String + - `BlockHash` - String + + - `Header` - Object + - `PreviousBlockHash` - String + - `MerkleTreeRootOfTransactions` - String + - `MerkleTreeRootOfWorldState` - String + - `Extra` - Array + - `Height` - Number + - `Time` - google.protobuf.Timestamp + - `ChainId` - String + - `Bloom` - String + - `SignerPubkey` - String + + - `Body` - Object + - `TransactionsCount` - Number + - `Transactions` - Array + - `transactionId` - String #### Example: ```javascript -aelf.chain.getBlock(blockHash, false) - .then(res => { - console.log(res); - }); +aelf.chain.getBlock(blockHash, false).then(res => { + console.log(res); +}); ``` - ### 5. Get Block By Height Get block information by block height. @@ -305,211 +386,203 @@ Get block information by block height. - **Web API Path**: `/api/blockChain/blockByHeight` - **Method**: GET - **Parameters**: - - **`blockHash`** (String) - - **`includeTransactions`** (Boolean) - - `true` require transaction ids list in the block - - `false` Doesn’t require transaction ids list in the block -- **Returns**: `Object` - - - `BlockHash` - String + - **`blockHash`** (String) + - **`includeTransactions`** (Boolean) + - `true` require transaction ids list in the block + - `false` Doesn’t require transaction ids list in the block - - `Header` - Object - - `PreviousBlockHash` - String - - `MerkleTreeRootOfTransactions` - String - - `MerkleTreeRootOfWorldState` - String - - `Extra` - Array - - `Height` - Number - - `Time` - google.protobuf.Timestamp - - `ChainId` - String - - `Bloom` - String - - `SignerPubkey` - String +- **Returns**: `Object` - - `Body` - Object - - `TransactionsCount` - Number - - `Transactions` - Array - - `transactionId` - String + - `BlockHash` - String + - `Header` - Object + - `PreviousBlockHash` - String + - `MerkleTreeRootOfTransactions` - String + - `MerkleTreeRootOfWorldState` - String + - `Extra` - Array + - `Height` - Number + - `Time` - google.protobuf.Timestamp + - `ChainId` - String + - `Bloom` - String + - `SignerPubkey` - String + - `Body` - Object + - `TransactionsCount` - Number + - `Transactions` - Array + - `transactionId` - String #### Example: ```javascript -aelf.chain.getBlockByHeight(12, false) - .then(res => { - console.log(res); - }); +aelf.chain.getBlockByHeight(12, false).then(res => { + console.log(res); +}); ``` -### 6. Get Transaction Result +### 6. Get Contract View Method List + +- **Web API Path**: `/api/blockChain/ContractViewMethodList` +- **Method**: GET +- **Parameters**: `address` (String) +- **Returns**: `Array` - The array of view method name + +#### Example: + +```javascript +aelf.chain.getContractViewMethodList('https://tdvw-test-node.aelf.io/').then(res => { + console.log(res); +}); +``` +### 7. Get Transaction Result - **Web API Path**: `/api/blockChain/transactionResult` - **Method**: GET - **Parameters**: `transactionId` (String) -- **Returns**: `Object` - - - `TransactionId` - String - - `Status` - String - - `Logs` - Array - - `Address` - String - - `Name` - String - - `Indexed` - Array - - `NonIndexed` - Number - - `Bloom` - String - - `BlockNumber` - Number - - `Transaction` - Object - - `From` - String - - `To` - String - - `RefBlockNumber` - Number - - `RefBlockPrefix` - String - - `MethodName` - String - - `Params` - Object - - `Signature` - String - - `ReadableReturnValue` - Object - - `Error` - String - +- **Returns**: `Object` - `TransactionId` - String - `Status` - String - `Logs` - Array - `Address` - String - `Name` - String - `Indexed` - Array - `NonIndexed` - Number - `Bloom` - String - `BlockNumber` - Number - `Transaction` - Object - `From` - String - `To` - String - `RefBlockNumber` - Number - `RefBlockPrefix` - String - `MethodName` - String - `Params` - Object - `Signature` - String - `ReadableReturnValue` - Object - `Error` - String #### Example: ```javascript -aelf.chain.getTxResult(transactionId) - .then(res => { - console.log(res); - }); +aelf.chain.getTxResult(transactionId).then(res => { + console.log(res); +}); ``` -### 7. Get Multiple Transaction Results +### 8. Get Merkle Path By TxId + +- **Web API Path**: `/api/blockChain/merklePathByTransactionId` +- **Method**: GET +- **Parameters**: + - **`transactionId`** (String) +- **Returns**: + - `MerklePathNodes` - The array of merklePathNodes: + - `Hash` - String + - `IsLeftChildNode` - String + +#### Example: + +```javascript +aelf.chain.merklePathByTransactionId(txId).then(res => { + console.log(res); +}); +``` +### 9. Get Multiple Transaction Results - **Web API Path**: `/api/blockChain/transactionResults` - **Method**: GET - **Parameters**: - - **`blockHash`** (String) - - **`offset`** (Number) - - **`limit`** (Number) -- **Returns**: - - `Array` - The array of method descriptions: - - the transaction result object - + - **`blockHash`** (String) + - **`offset`** (Number) + - **`limit`** (Number) +- **Returns**: + - `Array` - The array of method descriptions: + - the transaction result object #### Example: ```javascript -aelf.chain.getTxResults(blockHash, 0, 2) - .then(res => { - console.log(res); - }); +aelf.chain.getTxResults(blockHash, 0, 2).then(res => { + console.log(res); +}); ``` -### 8. Get Transaction Pool Status - +### 10. Get Transaction Pool Status - **Web API Path**: `/api/blockChain/transactionPoolStatus` - **Method**: GET - **Parameters**: None - -### 9. Send Transaction - +### 11. Send Transaction - **Web API Path**: `/api/blockChain/sendTransaction` - **Method**: POST - **Parameters**: `Object` (Serialized protobuf data with RawTransaction string) - - `RawTransaction` - String - + - `RawTransaction` - String -### 10. Send Multiple Transactions +### 12. Send Multiple Transactions - **Web API Path**: `/api/blockChain/sendTransactions` - **Method**: POST - **Parameters**: `Object` (Serialized protobuf data with RawTransaction string) - - `RawTransaction` - String + - `RawTransaction` - String - -### 11. Call Read-Only Method +### 13. Call Read-Only Method Call a read-only method on a contract. - **Method**: POST - **Parameters**: `Object` (Serialized protobuf data with RawTransaction string) - - `RawTransaction` - String + - `RawTransaction` - String - **Returns**: Method call result - -### 12. Get Peers +### 14. Get Peers Get peer info about the connected network nodes. - **Method**: GET - **Parameters**: `withMetrics` (Boolean) - - `true` with metrics - - `false` without metrics - + - `true` with metrics + - `false` without metrics -### 13. Add Peer +### 15. Add Peer Attempts to add a node to the connected network nodes - **Method**: POST - **Parameters**: `Object` The object with the following structure : - - `Address` - String + - `Address` - String -### 14. Remove Peer +### 16. Remove Peer Attempts to remove a node from the connected network nodes - **Method**: DELETE - **Parameters**: `address` (String) - -### 15. Calculate Transaction Fee - +### 17. Calculate Transaction Fee - **Web API Path**: `/api/blockChain/calculateTransactionFee` - **Method**: POST -- **Parameters**: `CalculateTransactionFeeInput` (Object with RawTransaction string): - - `RawTransaction` - String +- **Parameters**: `CalculateTransactionFeeInput` (Object with RawTransaction string): + - `RawTransaction` - String - **Returns**: `CalculateTransactionFeeOutput` (Object with fee details): - - `Success` - Bool - - `TransactionFee` - Array - - `ResourceFee` - Array - + - `Success` - Bool + - `TransactionFee` - Array + - `ResourceFee` - Array #### Example ```javascript -aelf.chain.calculateTransactionFee(rawTransaction) - .then(res => { - console.log(res); - }); +aelf.chain.calculateTransactionFee(rawTransaction).then(res => { + console.log(res); +}); ``` ### 16. Network Info - - **Method**: GET - **Parameters**: None - **Returns**: Network connection info - ## AElf.wallet `AElf.wallet` is a static property of `AElf`. - ### 1. createNewWallet **Returns:** - **Object** - - **`mnemonic - String`**: The mnemonic phrase for the wallet. - - **`BIP44Path - String`**: The BIP44 path, formatted as m/purpose’/coin_type’/account’/change/address_index. - - **`childWallet - Object`**: The Hierarchical Deterministic (HD) wallet object. - - **`keyPair - String`**: The elliptic curve (EC) key pair. - - **`privateKey - String`**: The private key for the wallet. - - **`address - String`**: The wallet address. + - **`mnemonic - String`**: The mnemonic phrase for the wallet. + - **`BIP44Path - String`**: The BIP44 path, formatted as m/purpose’/coin_type’/account’/change/address_index. + - **`childWallet - Object`**: The Hierarchical Deterministic (HD) wallet object. + - **`keyPair - String`**: The elliptic curve (EC) key pair. + - **`privateKey - String`**: The private key for the wallet. + - **`address - String`**: The wallet address. #### Example: @@ -519,12 +592,10 @@ const wallet = AElf.wallet.createNewWallet(); console.log(wallet); ``` - ### 2. getWalletByMnemonic Retrieves a wallet using a mnemonic phrase. - **Parameters:** - **`mnemonic - String`**: The mnemonic phrase of the wallet. @@ -533,7 +604,6 @@ Retrieves a wallet using a mnemonic phrase. - **`Object`**: The complete wallet object. - #### Example: ```javascript @@ -541,7 +611,6 @@ const wallet = AElf.wallet.getWalletByMnemonic(mnemonic); console.log(wallet); ``` - ### 3. getWalletByPrivateKey Retrieves a wallet using a private key. @@ -554,7 +623,6 @@ Retrieves a wallet using a private key. - **`Object`**: The complete wallet object, with an empty mnemonic. - #### Example: ```javascript @@ -562,7 +630,6 @@ const wallet = AElf.wallet.getWalletByPrivateKey(privateKey); console.log(wallet); ``` - ### 4. signTransaction Signs a transaction using the wallet's key pair. @@ -576,7 +643,6 @@ Signs a transaction using the wallet's key pair. - **`Object`**: The signed transaction object. - #### Example: ```javascript @@ -584,7 +650,6 @@ const result = AElf.wallet.signTransaction(rawTxn, keyPair); console.log(result); ``` - ### 5. AESEncrypt Encrypts a string using the AES algorithm. @@ -598,8 +663,6 @@ Encrypts a string using the AES algorithm. - **`String`**: The encrypted string. - - ### 6. AESDecrypt Decrypts a string using the AES algorithm. @@ -615,23 +678,18 @@ Decrypts a string using the AES algorithm. These are the detailed functions and their usages for the AElf.wallet API. If you have any specific questions or need further clarification, feel free to ask! - - ## AElf.pbjs Reference to protobuf.js. For detailed usage, refer to the [protobuf.js documentation](https://github.com/protobufjs/protobuf.js). - ## AElf.pbUtils Provides basic format methods for aelf. For detailed code, see `src/utils/proto.js`. - ### AElf.utils Contains utility methods for aelf. For detailed code, see `src/utils/utils.js`. - ### Check address Example to check if an address is valid using `base58` utility from aelf. @@ -657,7 +715,6 @@ import AElf from 'aelf-sdk'; console.log(AElf.version); // outputs the version, e.g., 3.2.23 ``` - ## Requirements To use aelf SDK, you need: @@ -665,19 +722,15 @@ To use aelf SDK, you need: - [Node.js](https://nodejs.org/en) - [NPM](https://www.npmjs.com/) - ## Support ![browsers](https://img.shields.io/badge/browsers-latest%202%20versions-brightgreen.svg) ![node](https://img.shields.io/badge/node-%3E=10-green.svg) - - ## About contributing Read out [contributing guide] - ## About Version -AElf SDK follows Semantic Versioning. For more details, refer to [semver.org](https://semver.org/). +AElf SDK follows Semantic Versioning. For more details, refer to [semver.org](https://semver.org/). \ No newline at end of file From b3b100ced6895f435176b4ee5073e0de46586d7c Mon Sep 17 00:00:00 2001 From: Rutvik Date: Wed, 10 Jul 2024 08:41:13 +0530 Subject: [PATCH 2/7] Translate the strings into English --- docs/tools/aelf-cli/commands/index.md | 14 +++++++------- docs/tools/chain-sdk/javascript-sdk/index.md | 15 ++++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/tools/aelf-cli/commands/index.md b/docs/tools/aelf-cli/commands/index.md index e85ad89d..b5ea65aa 100644 --- a/docs/tools/aelf-cli/commands/index.md +++ b/docs/tools/aelf-cli/commands/index.md @@ -6,7 +6,7 @@ description: aelf CLI Commands # Commands Overview -## 具体配置 +## Specific configuration ### Common Options @@ -108,7 +108,7 @@ $ aelf-command console -a sadaf -p yourpassword -e https://tdvw-test-node.aelf.i Options given in higher priority (e.g., CLI parameters) will overwrite those with lower priority (e.g., environment variables). -## 具体命令(#command-details) +## Specific orders(#command-details) ### Create a New Account @@ -425,10 +425,10 @@ Transaction: ef17ac2078c2b31a702b9edc754bfa56f1c37931f52f9dd8e2b9dc65769966b1 is When you execute this command, you'll get details about the transaction with ID fe1974fde291e44e16c55db666f2c747323cdc584d616de05c88c8bae18ecceb. Here's what the output means: -- **from**: 表示发送方的地址,即交易中的发起者 -- **to**: 表示接收方的地址,即交易中的接收者 -- **symbol**: 表示交易的代币符号 -- **amount**: 表示交易的数量或金额. +- **from**: Indicates the address of the sender, the initiator in the transaction +- **to**: Indicates the address of the recipient, that is, the recipient in the transaction +- **symbol**: Token symbol representing the transaction +- **amount**: Represents the quantity or amount of a transaction. - **Result**: Decoded information from the event, providing readable details such as author, code hash, and address. This command helps you understand what happened during a transaction, especially useful when dealing with events triggered by @@ -602,7 +602,7 @@ Welcome to aelf interactive console. Ctrl + C to terminate the program. Double t ╚═══════════════════════════════════════════════════════════╝ ``` -### dapp-server - Start a socket.io server for supplying services for dApps +### dapp-server - Start a socket.io server for supplying services for dApps Are you developing a dApp and need an environment to manage wallet information and connect to the AElf chain? You can easily start a local development server using this sub-command. diff --git a/docs/tools/chain-sdk/javascript-sdk/index.md b/docs/tools/chain-sdk/javascript-sdk/index.md index c213423e..0a305bfa 100644 --- a/docs/tools/chain-sdk/javascript-sdk/index.md +++ b/docs/tools/chain-sdk/javascript-sdk/index.md @@ -36,7 +36,7 @@ const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.ae ### Detail information for library files -你可以跳过这一步,如果 Adding aelf-web3.js 这一步已经足够的话 +You can skip this step, if Adding aelf-web3.js is enough In our dist directory, we supply two kinds of packages for different platforms, such as Node and Browser. @@ -124,12 +124,12 @@ rollup({ yarn install ``` -2. 在 src 下创建你的文件,编写你的逻辑 -3. 在 src/index 下看一下是否需要将你新增的模块挂在 AElf 作为实例的一个属性 -4. 在根目录执行`yarn link`,这会创建一个全局的符号链接到本包,并将其存储在全局 node_modules 目录中 -5. 在其他目录使用`yarn link "aelf-sdk"`,请确保你 link 的包的版本是正确的,因为有时候 node 版本不一致也可能会导致 link 到的 aelf-web3.js 版本不对 +2. Create your file under `src` and write your logic +3. Check under `src/index` whether you need to hang your new module on AElf as an attribute of the instance. +4. Execute `yarn link` in the root directory. This will create a global symbolic link to this package and store it in the global `node_module` directory. +5. When using yarn link `aelf-sdk` in other directories, please ensure that the version of the package you link is correct, because sometimes inconsistent node versions may also cause the incorrect version of aelf-web3.js to be linked. -接着你就可以试一下自己的刚写的逻辑是否 ok +Then you can try to see if the logic you just wrote is OK. ### Lint @@ -264,7 +264,8 @@ You can access the Web API of your aelf node at `{chainAddress}/swagger/index.ht For example, if your local node address is `http://127.0.0.1:1235`, you can view the Web API at `http://127.0.0.1:1235/swagger/index.html`. -我们的测试网节点地址是:[https://aelf-test-node.aelf.io/swagger/index.html](https://aelf-test-node.aelf.io/swagger/index.html)(主链)、[https://tdvw-test-node.aelf.io/swagger/index.html](https://tdvw-test-node.aelf.io/swagger/index.html)(侧链),可以访问这两个地址找到对应的参数和返回值。 +Our testnet node address is: [https://aelf-test-node.aelf.io/swagger/index.html](https://aelf-test-node.aelf.io/swagger/index.html)( +main chain)、[https://tdvw-test-node.aelf.io/swagger/index.html](https://tdvw-test-node.aelf.io/swagger/index.html)(side chain),You can access these two addresses to find the corresponding parameters and return values. The methods below use an instance of aelf. If you don't have one, create it as shown: From dca00fdac0b40293a021d05ce445fea35777394e Mon Sep 17 00:00:00 2001 From: Rutvik Date: Wed, 10 Jul 2024 09:46:45 +0530 Subject: [PATCH 3/7] Refectore resource example --- docs/tools/chain-sdk/javascript-sdk/index.md | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/tools/chain-sdk/javascript-sdk/index.md b/docs/tools/chain-sdk/javascript-sdk/index.md index 0a305bfa..1e411398 100644 --- a/docs/tools/chain-sdk/javascript-sdk/index.md +++ b/docs/tools/chain-sdk/javascript-sdk/index.md @@ -441,7 +441,26 @@ aelf.chain.getContractViewMethodList('https://tdvw-test-node.aelf.io/').then(res - **Web API Path**: `/api/blockChain/transactionResult` - **Method**: GET - **Parameters**: `transactionId` (String) -- **Returns**: `Object` - `TransactionId` - String - `Status` - String - `Logs` - Array - `Address` - String - `Name` - String - `Indexed` - Array - `NonIndexed` - Number - `Bloom` - String - `BlockNumber` - Number - `Transaction` - Object - `From` - String - `To` - String - `RefBlockNumber` - Number - `RefBlockPrefix` - String - `MethodName` - String - `Params` - Object - `Signature` - String - `ReadableReturnValue` - Object - `Error` - String +- **Returns**: `Object` + - `TransactionId` - String + - `Status` - String + - `Logs` - Array + - `Address` - String + - `Name` - String + - `Indexed` - Array + - `NonIndexed` - Number + - `Bloom` - String + - `BlockNumber` - Number + - `Transaction` - Object + - `From` - String + - `To` - String + - `RefBlockNumber` - Number + - `RefBlockPrefix` - String + - `MethodName` - String + - `Params` - Object + - `Signature` - String + - `ReadableReturnValue` - Object + - `Error` - String #### Example: From d8dba61c150d251e904d407654f14d9edc65d2f6 Mon Sep 17 00:00:00 2001 From: Rutvik Date: Wed, 10 Jul 2024 10:56:24 +0530 Subject: [PATCH 4/7] Updated javascript-docs-file --- docs/tools/chain-sdk/javascript-sdk/index.md | 142 +++++++++++++------ 1 file changed, 102 insertions(+), 40 deletions(-) diff --git a/docs/tools/chain-sdk/javascript-sdk/index.md b/docs/tools/chain-sdk/javascript-sdk/index.md index 1e411398..1ee428b2 100644 --- a/docs/tools/chain-sdk/javascript-sdk/index.md +++ b/docs/tools/chain-sdk/javascript-sdk/index.md @@ -11,58 +11,83 @@ image: /img/Logo.aelf.svg The `aelf-web3.js` library for aelf is similar to web3.js for Ethereum. It allows you to interact with a local or remote aelf node using an HTTP connection. -This guide will help you install and use `aelf-web3.js`, with an API reference and examples. +#### This guide will help you: + +- Install `aelf-web3.js`. + +- Use the library. + +- Understand the available API. For more details, check out the repository: [aelf-web3.js](https://github.com/AElfProject/aelf-web3.js). ## Quickstart -### Adding aelf-web3.js +### 1. Adding aelf-web3.js -First you need to get aelf-sdk.js into your project. This can be done using the following methods: +Now, You can add `aelf-web3.js` using **npm** or directly in your **HTML**. -npm: `npm install aelf-sdk` +- #### Using npm +```bash +npm install aelf-sdk +``` +- #### Using Pure js +```bash +link dist/aelf.umd.js +``` -pure js: `link dist/aelf.umd.js` +### 2. Create an AElf Instance -After that you need to create a aelf instance and set a provider. +Set up your AElf instance and connect to a provider. +#### Node.js ```js -// 1.In node.js use: const AElf = require('aelf-sdk'); -// 2.FrontEnd freshman, add following tag in html -// +const AElf = require('aelf-sdk'); const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); ``` -### Detail information for library files +#### Frontend (Using PureJs) + +- Include the script in your HTML file: + +```js + + +``` + + +### 3. Choose the Right Package You can skip this step, if Adding aelf-web3.js is enough -In our dist directory, we supply two kinds of packages for different platforms, such as Node and Browser. +The `dist` directory provides packages for different environments. | packages | usage | | ---------------- | ------------------------------------------------------------ | -| dist/aelf.cjs.js | built for node, remove node built-in modules such as crypto. | -| dist/aelf.umd.js | built for browser, add some node built-in modules by webpack | +| dist/aelf.cjs.js | For Node.js, excludes Node built-in modules like crypto. | +| dist/aelf.umd.js | For Browsers, includes necessary Node built-in modules. | -You can choose any packages based on your need, for examples: +#### For Beginner in Frontend -if you are new to FrontEnd, you can use `AElf-sdk` by add a script tag in your html files. +- Add the UMD package to your HTML: ```html ``` -if you want to use a bundle system such as webpack or rollup, and build your applications for Node.js and Browsers, just import the specified version of package files. +### 4. Use with Bundlers -#### For browser usage and use UMD +If you want to use a bundler like Webpack or Rollup, import the specified version of the package files. -Webpack: +#### For Browser (Using UMD) + +- Set up Webpack: ```javascript module.exports = { - // ... resolve: { alias: { 'aelf-sdk$': 'aelf-sdk/dist/aelf.umd.js' @@ -71,7 +96,7 @@ module.exports = { }; ``` -Rollup: +- Set up Rollup: ```javascript const alias = require('rollup-plugin-alias'); @@ -86,9 +111,9 @@ rollup({ }); ``` -#### For Node.js usage and use commonjs module system +#### For Node.js (Using CommonJS) -Webpack: +- Set up Webpack: ```javascript module.exports = { @@ -101,7 +126,7 @@ module.exports = { }; ``` -Rollup: +- Set up Rollup: ```javascript const alias = require('rollup-plugin-alias'); @@ -116,28 +141,61 @@ rollup({ }); ``` -## 🔨Development +#### Note + +- `aelf-web3.js` is the same as `aelf-sdk`. +- `aelf-sdk` is the package name on npm. + +For more detailed usage and examples, refer to the [aelf-web3.js repository](https://github.com/AElfProject/aelf-web3.js). -1. Install dev dependencies +## Development 🔨 +### 1. Install Development Dependencies +- install the required development dependencies: ```bash yarn install ``` -2. Create your file under `src` and write your logic -3. Check under `src/index` whether you need to hang your new module on AElf as an attribute of the instance. -4. Execute `yarn link` in the root directory. This will create a global symbolic link to this package and store it in the global `node_module` directory. -5. When using yarn link `aelf-sdk` in other directories, please ensure that the version of the package you link is correct, because sometimes inconsistent node versions may also cause the incorrect version of aelf-web3.js to be linked. +### 2. Write Your Code -Then you can try to see if the logic you just wrote is OK. +- Create your file under the `src` directory. +- Write your logic in the newly created file. -### Lint +### 3. Integrate Your Module + +- Check `src/index` to see if you need to add your new module as an attribute to the `AElf` instance. + +### 4. Link the Package Globally + +- Execute `yarn link` in the root directory. This creates a global symbolic link to this package and stores it in the global `node_modules` directory. + +```sh +yarn link +``` + +### 5. Link the Package in Other Directories + +- When using `yarn link aelf-sdk` in other directories, ensure the version of the package is correct. Inconsistent node versions can sometimes cause issues with linking the incorrect version of `aelf-web3.js`. + +```sh +yarn link aelf-sdk +``` + +### 6. Test Your Code + +- Try out the logic you just wrote to make sure everything works as expected. + +### Linting + +- To lint your code, run: ```sh yarn lint ``` -### Tests +### Running Tests + +- To run unit tests, execute: ```sh # Unit tests @@ -260,20 +318,24 @@ aelf.setProvider(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io ## Web API -You can access the Web API of your aelf node at `{chainAddress}/swagger/index.html`. +Access the Web API of your aelf node at `{chainAddress}/swagger/index.html` -For example, if your local node address is `http://127.0.0.1:1235`, you can view the Web API at `http://127.0.0.1:1235/swagger/index.html`. +**Examples:** -Our testnet node address is: [https://aelf-test-node.aelf.io/swagger/index.html](https://aelf-test-node.aelf.io/swagger/index.html)( -main chain)、[https://tdvw-test-node.aelf.io/swagger/index.html](https://tdvw-test-node.aelf.io/swagger/index.html)(side chain),You can access these two addresses to find the corresponding parameters and return values. +- Local node: `http://127.0.0.1:1235/swagger/index.html` +- Testnet nodes: + - **Main Chain**: [https://aelf-test-node.aelf.io/swagger/index.html](https://aelf-test-node.aelf.io/swagger/index.html) + - **Side Chain**: [https://tdvw-test-node.aelf.io/swagger/index.html](https://tdvw-test-node.aelf.io/swagger/index.html) -The methods below use an instance of aelf. If you don't have one, create it as shown: +**Setup:** + +Create an instance of `AElf`: ```javascript -import AElf from 'aelf-sdk'; +import AElf from "aelf-sdk"; -// Create a new instance of AElf, change the URL if needed -const aelf = new AElf(new AElf.providers.HttpProvider('http://127.0.0.1:1235')); +// Change the URL if needed +const aelf = new AElf(new AElf.providers.HttpProvider("http://127.0.0.1:1235")); ``` ### 1. Get Chain Status From 0a481da2b591ba4b602c56d3c329c2795710d800 Mon Sep 17 00:00:00 2001 From: vasmohi Date: Wed, 10 Jul 2024 11:22:16 +0530 Subject: [PATCH 5/7] fix: refactored content --- docs/tools/chain-sdk/javascript-sdk/index.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/tools/chain-sdk/javascript-sdk/index.md b/docs/tools/chain-sdk/javascript-sdk/index.md index 1ee428b2..d5d5b347 100644 --- a/docs/tools/chain-sdk/javascript-sdk/index.md +++ b/docs/tools/chain-sdk/javascript-sdk/index.md @@ -13,9 +13,7 @@ The `aelf-web3.js` library for aelf is similar to web3.js for Ethereum. It allow #### This guide will help you: -- Install `aelf-web3.js`. - -- Use the library. +- Install and use `aelf-web3.js`. - Understand the available API. @@ -66,8 +64,8 @@ The `dist` directory provides packages for different environments. | packages | usage | | ---------------- | ------------------------------------------------------------ | -| dist/aelf.cjs.js | For Node.js, excludes Node built-in modules like crypto. | -| dist/aelf.umd.js | For Browsers, includes necessary Node built-in modules. | +| dist/aelf.cjs.js | For node.js, excludes node built-in modules like crypto. | +| dist/aelf.umd.js | For browsers, includes necessary node built-in modules. | #### For Beginner in Frontend From b662584df85ccf3526e1205d1b6ca9fc25b14ea0 Mon Sep 17 00:00:00 2001 From: AelfHarsh Date: Wed, 10 Jul 2024 11:54:15 +0530 Subject: [PATCH 6/7] aelf-cli introduction --- docs/tools/aelf-cli/introduction/index.md | 56 +++++++++++------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/docs/tools/aelf-cli/introduction/index.md b/docs/tools/aelf-cli/introduction/index.md index 2abd16fc..8dee0430 100644 --- a/docs/tools/aelf-cli/introduction/index.md +++ b/docs/tools/aelf-cli/introduction/index.md @@ -6,27 +6,27 @@ description: aelf's Command Line Interface # Introduction to the CLI -The **aelf-command** tool is a Command Line Interface (CLI) designed for interacting with an aelf node. This guide will introduce you to its key features and show you how to install and use the tool. +The **aelf-command** tool is a Command Line Interface (CLI) for interacting with an aelf node. This guide shows you its key features and how to use them. ## Features -- **Configuration Management**: Easily get or set common configurations like `endpoint`, `account`, `data directory`, and `password`. -- **User-Friendly Prompts**: For new users, missing parameters will be prompted interactively. -- **Account Management**: Create new `accounts` or load existing ones using a private key or mnemonic. -- **Wallet Information**: Display `wallet` details including private key, address, public key, and mnemonic. -- **Encryption**: Encrypt account information into `keyStore` format and save it to a file. -- **Blockchain Interaction**: - - Retrieve the current `best height` of the chain. - - Get `block information` by `height` or `block hash`. - - Get `transaction results` by `transaction ID`. - - Send `transactions` or call `read-only methods` on smart `contracts`. - - Deploy smart `contracts`. - - Open a `REPL` (Read-Eval-Print Loop) for using `JavaScript` to interact with the chain. -- **Friendly UI**: Enhanced user interactions with chalk and ora for a better visual experience. -- **Chain Status**: Retrieve the current chain status. +- **Configuration Management**: Set and get settings like `endpoint`, `account`, `data directory`, and `password`. +- **Interactive Prompts**: Helps new users by asking for missing parameters. +- **Account Management**: Create or load `accounts` with a private key or mnemonic. +- **Wallet Information**: Show details like private key, address, public key, and mnemonic. +- **Encryption**: Save account info in `keyStore` format. +- **Blockchain Interaction**: + - Get the chain's `best height`. + - Get `block information` by height or block hash. + - Get `transaction results` by transaction ID. + - Send transactions or call read-only methods on smart contracts. + - Deploy smart contracts. + - Use `REPL` (Read-Eval-Print Loop) for JavaScript interactions with the chain. +- **User Interface**: Uses chalk and ora for better visuals. +- **Chain Status**: Get the current status of the chain. - **Proposal Management**: Create proposals on any contract method. -- **Transaction Deserialization**: Deserialize results returned by executing a transaction. -- **Socket.io Server**: Start a socket.io server to provide services for dApps. +- **Transaction Deserialization**: Read results from transactions. +- **Socket.io Server**: Start a server for dApps. ## Installation @@ -40,7 +40,7 @@ npm install aelf-command -g ### First Step -You need to create a new account or load an existing account using a `private key` or `mnemonic`. +Create a new account or load an existing account using a `private key` or `mnemonic`. **Create a New Wallet** @@ -48,7 +48,7 @@ You need to create a new account or load an existing account using a `private ke aelf-command create ``` -Output example: +Example output: ```bash Your wallet info is: @@ -69,14 +69,14 @@ Account info has been saved to "/Users/young/.local/share/aelf/keys/2Ue31YTuB5Sz aelf-command load e038eea7e151eb451ba2901f7...b08ba5b76d8f288 ``` -Output example: +Example output: ```bash Your wallet info is: Private Key: e038eea7e151eb451ba2901f7...b08ba5b76d8f288 Public Key: 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec88288111955b76ea Address: 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H -✔ Save account info into a file? +✔ Save account info into a file? … no / yes ✔ Enter a password … ******** ✔ Confirm password … ******** ✔ @@ -89,7 +89,7 @@ Account info has been saved to "/Users/young/.local/share/aelf/keys/2Ue31YTuB5Sz aelf-command wallet -a 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H ``` -Output example: +Example output: ```bash Your wallet info is: @@ -98,11 +98,9 @@ Public Key: 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec882 Address: 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H ``` -Here you can decide whether to encrypt the account info and save it to a file. - ## Examples -**Interactive Console** +##### Interactive Console ```sh aelf-command console -a 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H @@ -123,10 +121,10 @@ Welcome to aelf interactive console. Ctrl + C to terminate the program. Double t ║ | 5oGin1sys6H ║ ║ ║ ╚═══════════════════════════════════════════════════════════╝ - -``` -**Default Parameters** +``` + +##### Default Parameters ```sh aelf-command console @@ -232,4 +230,4 @@ Options: Examples: aelf-command console -``` \ No newline at end of file +``` From e6fde3d97ec1bb9690a78c55013c3a7d3bb35442 Mon Sep 17 00:00:00 2001 From: AelfHarsh Date: Wed, 10 Jul 2024 11:59:33 +0530 Subject: [PATCH 7/7] adding the link --- docs/tools/chain-sdk/javascript-sdk/index.md | 176 +++++++++++-------- 1 file changed, 98 insertions(+), 78 deletions(-) diff --git a/docs/tools/chain-sdk/javascript-sdk/index.md b/docs/tools/chain-sdk/javascript-sdk/index.md index d5d5b347..15916244 100644 --- a/docs/tools/chain-sdk/javascript-sdk/index.md +++ b/docs/tools/chain-sdk/javascript-sdk/index.md @@ -26,10 +26,13 @@ For more details, check out the repository: [aelf-web3.js](https://github.com/AE Now, You can add `aelf-web3.js` using **npm** or directly in your **HTML**. - #### Using npm + ```bash npm install aelf-sdk ``` + - #### Using Pure js + ```bash link dist/aelf.umd.js ``` @@ -39,9 +42,12 @@ link dist/aelf.umd.js Set up your AElf instance and connect to a provider. #### Node.js + ```js -const AElf = require('aelf-sdk'); -const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); +const AElf = require("aelf-sdk"); +const aelf = new AElf( + new AElf.providers.HttpProvider("https://tdvw-test-node.aelf.io") +); ``` #### Frontend (Using PureJs) @@ -55,17 +61,16 @@ const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.ae ``` - ### 3. Choose the Right Package You can skip this step, if Adding aelf-web3.js is enough The `dist` directory provides packages for different environments. -| packages | usage | -| ---------------- | ------------------------------------------------------------ | -| dist/aelf.cjs.js | For node.js, excludes node built-in modules like crypto. | -| dist/aelf.umd.js | For browsers, includes necessary node built-in modules. | +| packages | usage | +| ---------------- | -------------------------------------------------------- | +| dist/aelf.cjs.js | For node.js, excludes node built-in modules like crypto. | +| dist/aelf.umd.js | For browsers, includes necessary node built-in modules. | #### For Beginner in Frontend @@ -88,24 +93,24 @@ If you want to use a bundler like Webpack or Rollup, import the specified versio module.exports = { resolve: { alias: { - 'aelf-sdk$': 'aelf-sdk/dist/aelf.umd.js' - } - } + "aelf-sdk$": "aelf-sdk/dist/aelf.umd.js", + }, + }, }; ``` - Set up Rollup: ```javascript -const alias = require('rollup-plugin-alias'); +const alias = require("rollup-plugin-alias"); rollup({ // ... plugins: [ alias({ - 'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.umd.js') - }) - ] + "aelf-sdk": require.resolve("aelf-sdk/dist/aelf.umd.js"), + }), + ], }); ``` @@ -118,24 +123,24 @@ module.exports = { // ... resolve: { alias: { - 'aelf-sdk$': 'aelf-sdk/dist/aelf.cjs.js' - } - } + "aelf-sdk$": "aelf-sdk/dist/aelf.cjs.js", + }, + }, }; ``` - Set up Rollup: ```javascript -const alias = require('rollup-plugin-alias'); +const alias = require("rollup-plugin-alias"); rollup({ // ... plugins: [ alias({ - 'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.cjs.js') - }) - ] + "aelf-sdk": require.resolve("aelf-sdk/dist/aelf.cjs.js"), + }), + ], }); ``` @@ -149,7 +154,9 @@ For more detailed usage and examples, refer to the [aelf-web3.js repository](htt ## Development 🔨 ### 1. Install Development Dependencies + - install the required development dependencies: + ```bash yarn install ``` @@ -204,15 +211,17 @@ yarn test ### Examples -You can also see full examples in `./examples`; +You can also see full example here - [Examples](https://github.com/AElfProject/aelf-web3.js/tree/master/examples) #### Create Instance ```javascript -import AElf from 'aelf-sdk'; +import AElf from "aelf-sdk"; // Create a new instance of AElf -const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); +const aelf = new AElf( + new AElf.providers.HttpProvider("https://tdvw-test-node.aelf.io") +); ``` #### Create or Load a Wallet @@ -222,16 +231,16 @@ const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.ae const newWallet = AElf.wallet.createNewWallet(); // Load a wallet by private key -const privateKeyWallet = AElf.wallet.getWalletByPrivateKey('your-private-key'); +const privateKeyWallet = AElf.wallet.getWalletByPrivateKey("your-private-key"); // Load a wallet by mnemonic -const mnemonicWallet = AElf.wallet.getWalletByMnemonic('your-mnemonic'); +const mnemonicWallet = AElf.wallet.getWalletByMnemonic("your-mnemonic"); ``` #### Get a System Contract Address ```javascript -const tokenContractName = 'AElf.ContractNames.Token'; +const tokenContractName = "AElf.ContractNames.Token"; let tokenContractAddress; (async () => { @@ -240,9 +249,14 @@ let tokenContractAddress; // Get genesis contract address const GenesisContractAddress = chainStatus.GenesisContractAddress; // Get genesis contract instance - const zeroContract = await aelf.chain.contractAt(GenesisContractAddress, newWallet); + const zeroContract = await aelf.chain.contractAt( + GenesisContractAddress, + newWallet + ); // Get contract address by the read-only method 'GetContractAddressByName' of genesis contract - tokenContractAddress = await zeroContract.GetContractAddressByName.call(AElf.utils.sha256(tokenContractName)); + tokenContractAddress = await zeroContract.GetContractAddressByName.call( + AElf.utils.sha256(tokenContractName) + ); })(); ``` @@ -258,7 +272,7 @@ let tokenContract; })(); // Promise method -aelf.chain.contractAt(tokenContractAddress, wallet).then(result => { +aelf.chain.contractAt(tokenContractAddress, wallet).then((result) => { tokenContract = result; }); @@ -277,8 +291,8 @@ How to use a contract instance. You can call methods in two ways: read-only and (async () => { // Read-only method: Get the balance of an address const balanceResult = await tokenContract.GetBalance.call({ - symbol: 'ELF', - owner: '7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz' + symbol: "ELF", + owner: "7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz", }); console.log(balanceResult); /** @@ -291,10 +305,10 @@ How to use a contract instance. You can call methods in two ways: read-only and // Send transaction method: Transfer tokens const transactionId = await tokenContract.Transfer({ - symbol: 'ELF', - to: '7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz', - amount: '1000000000', - memo: 'transfer in demo' + symbol: "ELF", + to: "7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz", + amount: "1000000000", + memo: "transfer in demo", }); console.log(transactionId); /** @@ -308,10 +322,14 @@ How to use a contract instance. You can call methods in two ways: read-only and ### Change the Node Endpoint ```javascript -import AElf from 'aelf-sdk'; +import AElf from "aelf-sdk"; -const aelf = new AElf(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); -aelf.setProvider(new AElf.providers.HttpProvider('https://tdvw-test-node.aelf.io')); +const aelf = new AElf( + new AElf.providers.HttpProvider("https://tdvw-test-node.aelf.io") +); +aelf.setProvider( + new AElf.providers.HttpProvider("https://tdvw-test-node.aelf.io") +); ``` ## Web API @@ -360,7 +378,7 @@ Get the current status of the blockchain. #### Example: ```javascript -aelf.chain.getChainStatus().then(res => { +aelf.chain.getChainStatus().then((res) => { console.log(res); }); ``` @@ -377,7 +395,7 @@ Get the protobuf definitions related to a contract. #### Example: ```javascript -aelf.chain.getContractFileDescriptorSet(contractAddress).then(res => { +aelf.chain.getContractFileDescriptorSet(contractAddress).then((res) => { console.log(res); }); ``` @@ -394,7 +412,7 @@ Get the current best height of the chain. #### Example: ```javascript -aelf.chain.getBlockHeight().then(res => { +aelf.chain.getBlockHeight().then((res) => { console.log(res); }); ``` @@ -435,7 +453,7 @@ Get block information by block hash. #### Example: ```javascript -aelf.chain.getBlock(blockHash, false).then(res => { +aelf.chain.getBlock(blockHash, false).then((res) => { console.log(res); }); ``` @@ -476,7 +494,7 @@ Get block information by block height. #### Example: ```javascript -aelf.chain.getBlockByHeight(12, false).then(res => { +aelf.chain.getBlockByHeight(12, false).then((res) => { console.log(res); }); ``` @@ -491,9 +509,11 @@ aelf.chain.getBlockByHeight(12, false).then(res => { #### Example: ```javascript -aelf.chain.getContractViewMethodList('https://tdvw-test-node.aelf.io/').then(res => { - console.log(res); -}); +aelf.chain + .getContractViewMethodList("https://tdvw-test-node.aelf.io/") + .then((res) => { + console.log(res); + }); ``` ### 7. Get Transaction Result @@ -501,31 +521,31 @@ aelf.chain.getContractViewMethodList('https://tdvw-test-node.aelf.io/').then(res - **Web API Path**: `/api/blockChain/transactionResult` - **Method**: GET - **Parameters**: `transactionId` (String) -- **Returns**: `Object` - - `TransactionId` - String - - `Status` - String - - `Logs` - Array - - `Address` - String - - `Name` - String - - `Indexed` - Array - - `NonIndexed` - Number - - `Bloom` - String - - `BlockNumber` - Number - - `Transaction` - Object - - `From` - String - - `To` - String - - `RefBlockNumber` - Number - - `RefBlockPrefix` - String - - `MethodName` - String - - `Params` - Object - - `Signature` - String - - `ReadableReturnValue` - Object - - `Error` - String +- **Returns**: `Object` + - `TransactionId` - String + - `Status` - String + - `Logs` - Array + - `Address` - String + - `Name` - String + - `Indexed` - Array + - `NonIndexed` - Number + - `Bloom` - String + - `BlockNumber` - Number + - `Transaction` - Object + - `From` - String + - `To` - String + - `RefBlockNumber` - Number + - `RefBlockPrefix` - String + - `MethodName` - String + - `Params` - Object + - `Signature` - String + - `ReadableReturnValue` - Object + - `Error` - String #### Example: ```javascript -aelf.chain.getTxResult(transactionId).then(res => { +aelf.chain.getTxResult(transactionId).then((res) => { console.log(res); }); ``` @@ -544,7 +564,7 @@ aelf.chain.getTxResult(transactionId).then(res => { #### Example: ```javascript -aelf.chain.merklePathByTransactionId(txId).then(res => { +aelf.chain.merklePathByTransactionId(txId).then((res) => { console.log(res); }); ``` @@ -564,7 +584,7 @@ aelf.chain.merklePathByTransactionId(txId).then(res => { #### Example: ```javascript -aelf.chain.getTxResults(blockHash, 0, 2).then(res => { +aelf.chain.getTxResults(blockHash, 0, 2).then((res) => { console.log(res); }); ``` @@ -636,7 +656,7 @@ Attempts to remove a node from the connected network nodes #### Example ```javascript -aelf.chain.calculateTransactionFee(rawTransaction).then(res => { +aelf.chain.calculateTransactionFee(rawTransaction).then((res) => { console.log(res); }); ``` @@ -667,7 +687,7 @@ aelf.chain.calculateTransactionFee(rawTransaction).then(res => { #### Example: ```javascript -import AElf from 'aelf-sdk'; +import AElf from "aelf-sdk"; const wallet = AElf.wallet.createNewWallet(); console.log(wallet); ``` @@ -777,21 +797,21 @@ Example to check if an address is valid using `base58` utility from aelf. #### Example: ```javascript -const AElf = require('aelf-sdk'); +const AElf = require("aelf-sdk"); const { base58 } = AElf.utils; try { - base58.decode('$address'); // replace '$address' with actual address - console.log('Valid address'); + base58.decode("$address"); // replace '$address' with actual address + console.log("Valid address"); } catch (error) { - console.error('Invalid address', error); + console.error("Invalid address", error); } ``` ## AElf.version ```javascript -import AElf from 'aelf-sdk'; +import AElf from "aelf-sdk"; console.log(AElf.version); // outputs the version, e.g., 3.2.23 ``` @@ -813,4 +833,4 @@ Read out [contributing guide] ## About Version -AElf SDK follows Semantic Versioning. For more details, refer to [semver.org](https://semver.org/). \ No newline at end of file +AElf SDK follows Semantic Versioning. For more details, refer to [semver.org](https://semver.org/).