Skip to content

Commit

Permalink
Merge pull request #36 from AElfProject/feature/chain-sdk-restructure
Browse files Browse the repository at this point in the history
Worked on restrcture of python-chain-sdk page
  • Loading branch information
AelfHongliang authored Jun 27, 2024
2 parents 610d9b8 + ead6285 commit 356cd36
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 97 deletions.
6 changes: 3 additions & 3 deletions docs/learn/transactions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ Smart contracts in aelf blockchain serve as self-executing contracts with predef

In the aelf blockchain, smart contract methods are categorized into two types based on their functionality: **actions** and **views**.

##### 1. Action Methods:
### 1. Action Methods:

- **Definition**: Action methods are designed to modify the state of a contract.
- **Execution**: When a transaction containing an action method is included in a block and successfully executed, it can change the internal state of the contract.

##### Example
#### Example

```protobuf
rpc Vote (VoteInput) returns (google.protobuf.Empty) {
Expand All @@ -57,7 +57,7 @@ rpc Vote (VoteInput) returns (google.protobuf.Empty) {
- Action methods are typically used for operations that alter data within the blockchain, such as updating balances, transferring tokens, or recording votes.


##### 2. View Methods:
### 2. View Methods:

- **Definition**: View methods retrieve data from the contract but do not modify its state under any circumstances.
- **Execution**: They are purely read-only operations.
Expand Down
194 changes: 100 additions & 94 deletions docs/tools/chain-sdk/python-sdk/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,21 @@ aelf = AElf('http://127.0.0.1:8000')

**Parameters**: None

**Returns**: JSON

- `ChainId` - String
- `Branches` - JSON
- `NotLinkedBlocks` - JSON
- `LongestChainHeight` - Number
- `LongestChainHash` - String
- `GenesisBlockHash` - String
- `GenesisContractAddress` - String
- `LastIrreversibleBlockHash` - String
- `LastIrreversibleBlockHeight` - Number
- `BestChainHash` - String
- `BestChainHeight` - Number
**Returns**:

- `JSON`

- `ChainId` - String
- `Branches` - JSON
- `NotLinkedBlocks` - JSON
- `LongestChainHeight` - Number
- `LongestChainHash` - String
- `GenesisBlockHash` - String
- `GenesisContractAddress` - String
- `LastIrreversibleBlockHash` - String
- `LastIrreversibleBlockHeight` - Number
- `BestChainHash` - String
- `BestChainHeight` - Number

**Example**:

Expand All @@ -149,7 +151,7 @@ print('# get_chain_status', chain_status)

**Parameters**: None

**Returns**: Number
**Returns**: `Number`

**Example**:

Expand All @@ -169,22 +171,25 @@ print('# get_block_height', block_height)
- `block_hash` - String
- `include_transactions` - Boolean (true to include transaction IDs list, false otherwise)

**Returns**: JSON
**Returns**:

- `JSON`

- `BlockHash` - String
- `Header` - JSON
- `PreviousBlockHash` - String
- `MerkleTreeRootOfTransactions` - String
- `MerkleTreeRootOfWorldState` - String
- `Extra` - List
- `Height` - Number
- `Time` - JSON
- `ChainId` - String
- `Bloom` - String
- `SignerPubkey` - String
- `PreviousBlockHash` - String
- `MerkleTreeRootOfTransactions` - String
- `MerkleTreeRootOfWorldState` - String
- `Extra` - List
- `Height` - Number
- `Time` - JSON
- `ChainId` - String
- `Bloom` - String
- `SignerPubkey` - String
- `Body` - JSON
- `TransactionsCount` - Number
- `Transactions` - List
- `TransactionsCount` - Number
- `Transactions` - List
- `transactionId` - String

**Example**:

Expand All @@ -204,22 +209,25 @@ print('# get_block', block)
- `block_height` - Number
- `include_transactions` - Boolean (true to include transaction IDs list, false otherwise)

**Returns**: JSON
**Returns**:

- `JSON`

- `BlockHash` - String
- `Header` - JSON
- `PreviousBlockHash` - String
- `MerkleTreeRootOfTransactions` - String
- `MerkleTreeRootOfWorldState` - String
- `Extra` - List
- `Height` - Number
- `Time` - JSON
- `ChainId` - String
- `Bloom` - String
- `SignerPubkey` - String
- `PreviousBlockHash` - String
- `MerkleTreeRootOfTransactions` - String
- `MerkleTreeRootOfWorldState` - String
- `Extra` - List
- `Height` - Number
- `Time` - JSON
- `ChainId` - String
- `Bloom` - String
- `SignerPubkey` - String
- `Body` - JSON
- `TransactionsCount` - Number
- `Transactions` - List
- `TransactionsCount` - Number
- `Transactions` - List
- `transactionId` - String

**Example**:

Expand All @@ -238,27 +246,29 @@ print('# get_block_by_height', block_by_height)

- `transactionId` - String

**Returns**: JSON

- `TransactionId` - String
- `Status` - String
- `Logs` - List
- `Address` - String
- `Name` - String
- `Indexed` - List
- `NonIndexed` - String
- `Bloom` - String
- `BlockNumber` - Number
- `Transaction` - List
- `From` - Number
- `To` - Number
- `RefBlockNumber` - Number
- `RefBlockPrefix` - String
- `MethodName` - String
- `Params` - JSON
- `Signature` - String
- `ReadableReturnValue` - JSON
- `Error` - String
**Returns**:

- `JSON`

- `TransactionId` - String
- `Status` - String
- `Logs` - List
- `Address` - String
- `Name` - String
- `Indexed` - List
- `NonIndexed` - String
- `Bloom` - String
- `BlockNumber` - Number
- `Transaction` - List
- `From` - Number
- `To` - Number
- `RefBlockNumber` - Number
- `RefBlockPrefix` - String
- `MethodName` - String
- `Params` - JSON
- `Signature` - String
- `ReadableReturnValue` - JSON
- `Error` - String

**Example**:

Expand All @@ -280,7 +290,7 @@ print('# get_transaction_result', transaction_result)
- `limit` - Number


**Returns**: List of transaction result objects
**Returns**: `List` of transaction result objects

**Example**:

Expand Down Expand Up @@ -360,12 +370,6 @@ print('# send_transactions', result)

**Web API Path**: `/api/net/peers`

**Parameters**:

- `blockHash` - String
- `offset` - Number
- `limit` - Number

**Example**:

```python
Expand Down Expand Up @@ -423,9 +427,10 @@ print('# remove_peer', remove_peer)

- `transaction` - JSON format transaction

**Returns**: JSON
**Returns**:

- `RawTransaction` - hex string bytes generated by transaction information
- `JSON`
- `RawTransaction` - hex string bytes generated by transaction information

**Example**:

Expand Down Expand Up @@ -548,7 +553,7 @@ print('# get_merkle_path', merkle_path)
```


### 16. Calculate Transaction Fee
### 17. Calculate Transaction Fee

**Web API Path**: `/api/blockchain/calculateTransactionFee`

Expand All @@ -559,11 +564,12 @@ print('# get_merkle_path', merkle_path)
- `CalculateTransactionFeeInput` - JSON with the following structure:
- `RawTransaction` - String

**Returns**: JSON with the following structure:
**Returns**:

- `Success` - Boolean
- `TransactionFee` - Array
- `ResourceFee` - Array
- `CalculateTransactionFeeOutput` - `json` - The json with the following structure :
- `Success` - Boolean
- `TransactionFee` - Array
- `ResourceFee` - Array

**Example**:

Expand All @@ -580,7 +586,7 @@ print('# calculate_transaction_fee', calculate_transaction_fee_output)



### 16. Calculate Transaction Fee
### 18. Get Network Info

**Web API Path**: `/api/net/networkInfo`

Expand Down Expand Up @@ -618,11 +624,11 @@ genesis_contract_address = aelf.get_genesis_contract_address_string()

**Parameters:**

- `contract_name` - String: system contract’s name
- `contract_name` - String: system contract’s name

**Returns:**

Address: system contract’s address
- `Address`: system contract’s address

**Example:**

Expand All @@ -637,11 +643,11 @@ multi_token_contract_address = aelf.get_system_contract_address('AElf.ContractNa

**Parameters:**

- `contract_name` - String: system contract’s name
- `contract_name` - String: system contract’s name

**Returns:**

String: system contract’s address
- `String`: system contract’s address

**Example:**

Expand All @@ -656,9 +662,9 @@ multi_token_contract_address_string = aelf.get_system_contract_address_string('A

**Parameters:**

- `to_address` - Address or String: target contract’s address
- `method_name` - String: method name
- `params` - String: serialize parameters into String
- `to_address` - Address or String: target contract’s address
- `method_name` - String: method name
- `params` - String: serialize parameters into String

**Example:**

Expand All @@ -677,8 +683,8 @@ Sign a transaction with the user’s private key.

**Parameters:**

- `private_key` - String: user’s private key
- `transaction` - Transaction: transaction
- `private_key` - String: user’s private key
- `transaction` - Transaction: transaction

**Example:**

Expand All @@ -699,11 +705,11 @@ Generate an address from a public key.

**Parameters:**

- `public_key` - bytes: user’s public key
- `public_key` - bytes: user’s public key

**Returns:**

- Address
- `Address`

**Example:**

Expand All @@ -720,11 +726,11 @@ Generate an address string from a public key.

**Parameters:**

- `public_key` - bytes: user’s public key
- `public_key` - bytes: user’s public key

**Returns:**

- String
- `String`

**Example:**

Expand All @@ -741,7 +747,7 @@ address = aelf.get_address_string_from_public_key(public_key)

**Returns:**

- Number
- `Number`

**Example:**

Expand All @@ -758,12 +764,12 @@ print('# get_chain_id', chain_id)

**Parameters:**

- `address` - Address: address
- `address` - Address: address

**Returns:**

- String

- `String`
**Example:**

```python
Expand Down Expand Up @@ -834,13 +840,13 @@ toolkit.cross_chain_transfer(to_address_string, symbol, amount, memo, to_chain_i

## Requirements

- Python
- Docker
- [Python](https://www.python.org/)
- [Docker](https://www.docker.com/)


## Support

- Node
- [Node](https://hub.docker.com/r/aelf/node)

## About Contributing

Expand Down

0 comments on commit 356cd36

Please sign in to comment.