From b5fa77c46451fee6e3c4263ddb15223a596c261a Mon Sep 17 00:00:00 2001 From: yongenaelf <132553186+yongenaelf@users.noreply.github.com> Date: Mon, 24 Jun 2024 12:08:21 +0800 Subject: [PATCH] =?UTF-8?q?Update=20Doc=20=E2=80=9Cprotocol/addresses/inde?= =?UTF-8?q?x=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addresses}/Addresses.md | 54 ++++++++----------- .../addresses}/consensus.md | 0 .../addresses}/network.md | 0 .../addresses}/transactions.md | 0 4 files changed, 23 insertions(+), 31 deletions(-) rename docs/{Protocol => protocol/addresses}/Addresses.md (78%) rename docs/{Protocol => protocol/addresses}/consensus.md (100%) rename docs/{Protocol => protocol/addresses}/network.md (100%) rename docs/{Protocol => protocol/addresses}/transactions.md (100%) diff --git a/docs/Protocol/Addresses.md b/docs/protocol/addresses/Addresses.md similarity index 78% rename from docs/Protocol/Addresses.md rename to docs/protocol/addresses/Addresses.md index 228866f..b453068 100644 --- a/docs/Protocol/Addresses.md +++ b/docs/protocol/addresses/Addresses.md @@ -2,8 +2,8 @@ sidebar_position: 1 title: Addresses description: Addresses +image: /img/Logo.aelf.svg --- - # Address ### Overview @@ -11,6 +11,7 @@ description: Addresses Changes within the aelf blockchain occur through the execution of transactions. An **address** within aelf identifies a participant in a transaction, either as the sender or the recipient. The sender is denoted as **From**, while the recipient is denoted as **To**. **From** can represent: + 1. **User Address**: Identifies an individual participant. 2. **Contract Address**: Identifies a smart contract. 3. **Virtual Address**: Represents a virtual entity within the blockchain. @@ -19,15 +20,14 @@ Changes within the aelf blockchain occur through the execution of transactions. For further details on each type of address in the aelf blockchain, please see below. - ### User Address A **User Address** in aelf is generated from a unique key pair owned by a real user of the blockchain. Here’s how it works: ##### Key Pair Generation: -- A User Address is derived from a key pair using the `IAElfAsymmetricCipherKeyPair` interface. -- This interface includes +* A User Address is derived from a key pair using the `IAElfAsymmetricCipherKeyPair` interface. +* This interface includes ```protobuf public interface IAElfAsymmetricCipherKeyPair @@ -40,13 +40,14 @@ public interface IAElfAsymmetricCipherKeyPair Currently, aelf blockchain utilizes ECKeyPair for this purpose, similar to many other blockchain systems. ##### Generating a Key Pair: -- Users can use the [aelf-command](../reference/cli/introduction.md) tool to create a valid ECKeyPair: + +* Users can use the [aelf-command](../reference/cli/introduction.md) tool to create a valid ECKeyPair: ```shell aelf-command create ``` -- You will need to provide a valid password. The tool generates a `.json` file containing the public and private keys, encrypted with your password. +* You will need to provide a valid password. The tool generates a `.json` file containing the public and private keys, encrypted with your password. ##### Using dApp SDK: @@ -74,10 +75,9 @@ import Aelf from 'aelf-sdk'; const address = Aelf.wallet.getAddressFromPubKey(pubKey); ``` - ##### Address Representation: -- The User Address in aelf is represented using Protobuf message Address +* The User Address in aelf is represented using Protobuf message Address ```protobuf option csharp_namespace = "AElf.Types"; @@ -89,14 +89,14 @@ message Address In summary, a User Address in aleft blockchain is fundamental for identifying users and interacting with the blockchain securely and effectively. - ### Contract Address A **Contract Address** in aelf blockchain uniquely identifies a Smart Contract. Here’s how it’s created: ##### 1. Calculation Method: - - A Contract Address is determined during the deployment of a Smart Contract. - - It’s calculated using a combination of the blockchain's **chain id** and a *serial number associated with the contract. + +* A Contract Address is determined during the deployment of a Smart Contract. +* It’s calculated using a combination of the blockchain's **chain id** and a *serial number associated with the contract. ##### 2. Implementation: @@ -114,15 +114,14 @@ public static Address BuildContractAddress(int chainId, long serialNumber) } ``` -- `HashHelper.ConcatAndCompute`: Combines the chain id and serial number hashes. -- `Address.FromBytes`: Converts the resulting hash into a readable Address format. - +* `HashHelper.ConcatAndCompute`: Combines the chain id and serial number hashes. +* `Address.FromBytes`: Converts the resulting hash into a readable Address format. ##### 3. Usage: - - Developers deploying Smart Contracts on aelf blockchain use these methods to generate unique Contract Addresses dynamically. -In essence, a Contract Address in aelf blockchain ensures each Smart Contract can be uniquely identified and interacted with securely across the network. +* Developers deploying Smart Contracts on aelf blockchain use these methods to generate unique Contract Addresses dynamically. +In essence, a Contract Address in aelf blockchain ensures each Smart Contract can be uniquely identified and interacted with securely across the network. ### Contract Virtual Address @@ -130,29 +129,22 @@ In the aelf blockchain, every contract has the capability to create additional v ##### 1. Creation Process: -- Virtual Addresses are generated by applying a hash function to the main Address of the contract. -- This process allows contracts to create multiple unique identifiers dynamically. - +* Virtual Addresses are generated by applying a hash function to the main Address of the contract. +* This process allows contracts to create multiple unique identifiers dynamically. ##### 2. Use Case: -- For instance, in aelf blockchain, when transferring tokens using the MultiToken contract, both sender and recipient are identified by their respective Addresses. -- Virtual Addresses extend this functionality by enabling the creation of unique identifiers for specific transactions or actions within a contract. +* For instance, in aelf blockchain, when transferring tokens using the MultiToken contract, both sender and recipient are identified by their respective Addresses. +* Virtual Addresses extend this functionality by enabling the creation of unique identifiers for specific transactions or actions within a contract. - ##### 3. Creation Process: -- Virtual Addresses are controlled exclusively by the primary contract. -- This capability allows contracts to manage transactions and funds independently for each user, ensuring secure custody. - +* Virtual Addresses are controlled exclusively by the primary contract. +* This capability allows contracts to manage transactions and funds independently for each user, ensuring secure custody. ##### 4. Utility: -- Virtual Addresses serve as reliable identifiers generated through business actions on the contract. -- They are particularly useful for token transfers and other interactions where unique identification is crucial. - +* Virtual Addresses serve as reliable identifiers generated through business actions on the contract. +* They are particularly useful for token transfers and other interactions where unique identification is crucial. In summary, Virtual Addresses in aelf blockchain enhance the flexibility and security of contract interactions by providing unique identifiers derived from the main contract Address. - - - diff --git a/docs/Protocol/consensus.md b/docs/protocol/addresses/consensus.md similarity index 100% rename from docs/Protocol/consensus.md rename to docs/protocol/addresses/consensus.md diff --git a/docs/Protocol/network.md b/docs/protocol/addresses/network.md similarity index 100% rename from docs/Protocol/network.md rename to docs/protocol/addresses/network.md diff --git a/docs/Protocol/transactions.md b/docs/protocol/addresses/transactions.md similarity index 100% rename from docs/Protocol/transactions.md rename to docs/protocol/addresses/transactions.md