Skip to content

Commit

Permalink
Update Doc “protocol/addresses/index”
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Jun 24, 2024
1 parent 5e8cd67 commit b5fa77c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
54 changes: 23 additions & 31 deletions docs/Protocol/Addresses.md → docs/protocol/addresses/Addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
sidebar_position: 1
title: Addresses
description: Addresses
image: /img/Logo.aelf.svg
---

# Address

### Overview

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.
Expand All @@ -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
Expand All @@ -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:

Expand Down Expand Up @@ -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";
Expand All @@ -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:

Expand All @@ -114,45 +114,37 @@ 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

In the aelf blockchain, every contract has the capability to create additional virtual addresses based on its main Address. These virtual addresses are known as **Virtual Addresses**.

##### 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.



File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b5fa77c

Please sign in to comment.