This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from darwinia-network/aki-refactor
Refactor
- Loading branch information
Showing
43 changed files
with
601 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"label": "Builder", | ||
"collapsible": false, | ||
"position": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
--- | ||
sidebar_position: 105 | ||
--- | ||
|
||
# Ethereum API | ||
|
||
## Introduction | ||
|
||
DVM(Darwinia Virtual Machine) is fully compatible with EVM (Ethereum Virtual Machine) in Darwinia Network. | ||
|
||
You can use `web3.js` or other [ethereum tools](#dev-tools) to interact with Darwinia using Ethereum compactible RPC api. | ||
|
||
## RPC List | ||
|
||
> Note: The currently implemented RPC apis is compatible with Ethereum, but some apis are not yet implemented. | ||
## Supported Interfaces | ||
|
||
- [x] debug_traceBlockByNumber | ||
- [x] debug_traceByHash | ||
- [x] debug_traceTransaction | ||
- [x] eth_accounts | ||
- [x] eth_blockNumber | ||
- [x] eth_chainId | ||
- [x] eth_coinbase | ||
- [x] eth_call | ||
- [x] eth_estimateGas | ||
- [x] eth_feeHistory | ||
- [x] eth_gasPrice | ||
- [x] eth_getBlockByHash | ||
- [x] eth_getBlockByNumber | ||
- [x] eth_getTransactionCount | ||
- [x] eth_getBlockTransactionCountByHash | ||
- [x] eth_getBlockTransactionCountByNumber | ||
- [x] eth_getCode | ||
- [x] eth_getTransactionByBlockHashAndIndex | ||
- [x] eth_getTransactionByHash | ||
- [x] eth_getTransactionByBlockNumberAndIndex | ||
- [x] eth_getTransactionReceipt | ||
- [x] eth_getUncleByBlockHashAndIndex | ||
- [x] eth_getUncleByBlockNumberAndIndex | ||
- [x] eth_getUncleCountByBlockHash | ||
- [x] eth_getUncleCountByBlockNumber | ||
- [x] eth_getLogs | ||
- [x] eth_getWork | ||
- [x] eth_getBalance | ||
- [x] eth_getFilterChanges | ||
- [x] eth_getFilterLogs | ||
- [x] eth_hashrate | ||
- [x] eth_mining | ||
- [x] eth_newFilter | ||
- [x] eth_newBlockFilter | ||
- [x] eth_newPendingTransactionFilter | ||
- [x] eth_protocolVersion | ||
- [x] eth_sendTransaction | ||
- [x] eth_sendRawTransaction | ||
- [x] eth_submitWork | ||
- [x] eth_submitHashrate | ||
- [x] eth_subscription | ||
- [x] eth_syncing | ||
- [x] eth_unsubscribe | ||
- [x] eth_uninstallFilter | ||
- [x] net_version | ||
- [x] net_peerCount | ||
- [x] net_listening | ||
- [x] trace_filter | ||
- [x] web3_clientVersion | ||
- [x] web3_sha3 | ||
|
||
## Things Dapp developers must know | ||
|
||
### Use `block.timestamp` instead of `block.number` | ||
|
||
On Ethereum or other EVM-Compatible platform, you may use `block.number` in contract, but this is not recommended in CSC. We may introduce CSC 2.0 (The Next Generation of CSC) in the future and export the data from CSC 1.0 to CSC 2.0, which may reset the chain height to zero, so we recommend using `block.timestamp`. | ||
|
||
### Consensus Related Field | ||
|
||
Ethereum uses a consensus protocol named Proof-of-Work (PoW). While CSC uses the Nominated Proof of Stake(NPOS). They are two completely different consensus mechanisms. Consequently, Proof of Work concepts, such as `difficulty`, `uncles`, `hashrate`, generally is not applicable to CSC. For APIs that return value related to Ethereum’s Proof of Work, default value are returned. | ||
|
||
### Genesis Block | ||
|
||
It is particularly important to note that CSC's genesis block does not start at 0 like Ethereum. It is `4969901`. This means that if you try to query the block history before `4969901` with `eth_getBlockByNumber()` or `eth_getBlockByHash()`, you will get `null`. This is because the DVM smart contract solution was added in the middle of the Substrate-base Crab chain, there are no Ethereum transactions in the Substrate history blocks and no corresponding Ethereum history blocks generated. | ||
|
||
### Ethereum Block Author | ||
|
||
The author(miner) of the ethereum block you get from `eth_getBlockByNumber()` or `eth_getBlockByHash()` is the last 20 bytes of the actual substrate block author. It's because the ethereum block is built based on substrate block and who's author is a 32-bytes address. We have to truncate to adapt ethereum block needs. **Please do not tranfer to the ethereum block author, since the private key of this address is unknown.** | ||
|
||
## Dev Tools | ||
|
||
Darwinia is EVM-compatiable, so your can use almost all toolchains for EVM. Here are some of our picks: | ||
|
||
Wallets: | ||
|
||
- [MetaMask](https://metamask.io/) | ||
|
||
Libraries: | ||
|
||
* [web3.js](https://github.com/web3/web3.js) | ||
* [ethers.js](https://github.com/ethers-io/ethers.js) | ||
|
||
Contract Libraries: | ||
|
||
* [OpenZeppelin](https://openzeppelin.com/) | ||
|
||
Dev Environment: | ||
|
||
* [Remix](https://remix.ethereum.org/) | ||
* [Hardhat](https://hardhat.org/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
sidebar_position: 104 | ||
--- | ||
|
||
# Explorers | ||
|
||
## Darwinia | ||
- https://darwinia.subscan.io/ | ||
- https://darwinia.subview.xyz/ | ||
|
||
## Crab | ||
- https://crab.subscan.io/ | ||
- https://crab.subview.xyz/ | ||
|
||
## Pangoro | ||
- https://pangoro.subscan.io/ | ||
|
||
## Pangolin | ||
- https://pangolin.subscan.io/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 7 | ||
sidebar_position: 108 | ||
--- | ||
|
||
# Glossary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Networks", | ||
"position": 101 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
sidebar_position: 1 | ||
title: Crab | ||
--- | ||
|
||
Crab Network is a canary network with real economic value for Darwinia, and its positioning is similar to Polkadot's Kusama Network. To expect chaos is a reasonable assumption! | ||
|
||
Crab is now a parachain of [Kusama](https://kusama.subscan.io/parachain/2229). | ||
|
||
## Network Info | ||
|
||
- Network Name: Crab | ||
- Token Name: CRAB | ||
- Token Decimal: 9 | ||
- Block Explorer: | ||
- https://crab.subscan.io/ | ||
- HTTP Endpoints: | ||
- https://crab-rpc.darwinia.network | ||
- https://darwinia-crab.api.onfinality.io/public | ||
- https://darwiniacrab-rpc.dwellir.com | ||
- WSS Endpoints: | ||
- wss://crab-rpc.darwinia.network | ||
- wss://darwinia-crab.api.onfinality.io/public-ws | ||
- wss://darwiniacrab-rpc.dwellir.com | ||
|
||
#### EVM Info | ||
- Network Name: Crab Smart Chain | ||
- Token Name: CRAB | ||
- Token Decimal: 18 | ||
- ChainId: 44 | ||
- Block Explorer: | ||
- https://crab.subscan.io/ | ||
- HTTP Endpoints: | ||
- https://crab-rpc.darwinia.network | ||
- https://darwinia-crab.api.onfinality.io/public | ||
- https://darwiniacrab-rpc.dwellir.com | ||
- WSS Endpoints: | ||
- wss://crab-rpc.darwinia.network | ||
- wss://darwinia-crab.api.onfinality.io/public-ws | ||
- wss://darwiniacrab-rpc.dwellir.com | ||
|
||
## Other tokens | ||
|
||
| Token Symbol | Spec | Decimals | Smart Contract Address | | ||
| --- | --- | --- | --- | | ||
| CKTON | ERC20 | 18 | 0x0000000000000000000000000000000000000402 | | ||
| WCRAB | ERC20 | 18 | 0x2d2b97ea380b0185e9fdf8271d1afb5d2bf18329 | | ||
| xWRING | ERC20 | 18 | 0x273131F7CB50ac002BDd08cA721988731F7e1092 | | ||
|
||
|
||
### Deprecated tokens | ||
|
||
| Token Symbol | Spec | Decimals | Smart Contract Address | Why | | ||
| --- | --- | --- | --- | --- | | ||
| WCKTON(Classic) | ERC20 | 18 | 0x159933C635570D5042723359fbD1619dFe83D3f3 | migrated to CKTON | | ||
| xRING(Classic) | ERC20 | 9 | 0x7399Ea6C9d35124d893B8d9808930e9d3F211501 | migrated to xWRING | | ||
|
||
## Params | ||
|
||
### Block, Epoch and Era Time | ||
|
||
| Darwinia | Time | Slots | | ||
| -------- | --------- | ----- | | ||
| Block | 6 seconds | 1 | | ||
| Epoch | 1 hour | 600 | | ||
| Era | 6 hours | 3,600 | | ||
|
||
### Staking, Validating, and Nominating | ||
|
||
| Darwinia | Time | Slots | Description | | ||
| ----------------------- | ---------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| Validator Slots | 7 | Initial slots for active validators, gradually increasing. | | | ||
| Term duration | 6 hours | 3,600 | The time for which a validator is in the set after being elected. Note, this duration can be shortened in the case that a validator misbehaves. | | ||
| Nomination period | 6 hours | 3,600 | Every 6 hours, a new validator set is elected according to Phragmen's method. | | ||
| Bonding duration | 14 days | 201,600 | How long until your funds will be transferrable after unbonding. | | ||
| Slash defer duration | 14 days | 201,600 | Prevents overslashing and validators "escaping" and getting their nominators slashed with no repercussions to themselves | | ||
| Slash Cancellation Vote | Requires 3/4 of Council to Approve | | | | ||
### Governance | ||
|
||
| Democracy | Time | Slots | Description | | ||
| ---------------- | ------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| Voting period | 7 days | 100,800 | How long the public can vote on a referendum. | | ||
| Launch period | 7 days | 100,800 | How long the public can select which proposal to hold a referendum on. i.e., Every week, the highest-weighted proposal will be selected to have a referendum | | ||
| Enactment period | 8 days | 115,200 | Time it takes for a successful referendum to be implemented on the network. | | ||
|
||
| Council | Time | Slots | Description | | ||
| ------------- | ----- | ----- | -------------------------------------------------------------------- | | ||
| Term duration | 1 day | 3,600 | The length of a council member's term until the next election round. | | ||
| Voting period | 1 day | 3,600 | The council's voting period for motions. | | ||
|
||
| Technical committee | Time | Slots | Description | | ||
| ----------------------- | ------- | ------- | ---------------------------------------------------------------------------------------------- | | ||
| Cool-off period | 7 days | 100,800 | The time a veto from the technical committee lasts before the proposal can be submitted again. | | ||
| Emergency voting period | 3 hours | 1,800 | The voting period after the technical committee expedites voting. | | ||
|
||
### Treasury | ||
|
||
| Parameter | Value | Description | | ||
| --------------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | ||
| Budgeting Period** | 6 days | When the treasury can spend again after spending previously. | | ||
| Proposal Bond | 5% and minumum 1000 CRAB | The amount required to bond in order to propose a treasury spend. If approved, it is returned, if the proposal fails, it is burnt. | | ||
| Burn unspent treasury funds | Off | This deactivates a burn of all unspent treasury funds at the end of a budgeting period. | | ||
|
||
### SS58 Address Format | ||
|
||
Chain specification name: Crab | ||
|
||
SS58 prefix: 42 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
sidebar_position: 0 | ||
title: Darwinia | ||
--- | ||
|
||
Darwinia is a chain based on substrate with cross-chain components, including substrate to ethereum and substrate to substrate. | ||
|
||
Darwinia is now a parachain of [Polkadot](https://polkadot.subscan.io/parachain/2046). | ||
|
||
## Network Info | ||
|
||
- Network Name: Darwinia | ||
- Token Name: RING | ||
- Token Decimal: 9 | ||
- Block Explorer: | ||
- https://darwinia.subscan.io/ | ||
- HTTP Endpoints: | ||
- https://rpc.darwinia.network | ||
- https://darwinia-rpc.dwellir.com | ||
- WSS Endpoints: | ||
- wss://rpc.darwinia.network | ||
- wss://darwinia-rpc.dwellir.com | ||
|
||
#### EVM Info | ||
- Network Name: Darwinia Smart Chain | ||
- Token Name: RING | ||
- Token Decimal: 18 | ||
- ChainId: 46 | ||
- Block Explorer: | ||
- https://darwinia.subscan.io/ | ||
- HTTP Endpoints: | ||
- https://rpc.darwinia.network | ||
- https://darwinia-rpc.dwellir.com | ||
- WSS Endpoints: | ||
- wss://rpc.darwinia.network | ||
- wss://darwinia-rpc.dwellir.com | ||
|
||
## Params | ||
|
||
### Block, Epoch and Era Time | ||
|
||
| Darwinia | Time | Slots | | ||
| -------- | --------- | ----- | | ||
| Block | 6 seconds | 1 | | ||
| Epoch | 4 hour | 2,400 | | ||
| Era | 24 hours |14,400 | | ||
|
||
|
||
### Staking, Validating and Nominating Time | ||
|
||
| Darwinia | Time | Slots | Description | | ||
| --- | --- | --- | --- | | ||
| Term duration | 24 hours | 14,400 | The time for which a validator is in the set after being elected. Note, this duration can be shortened in the case that a validator misbehaves. | | ||
| Nomination period | 24 hours | 14,400 | Every 24 hours, a new validator set is elected according to Phragmen's method. | | ||
| Bonding duration | 14 days | 201,600 | How long until your funds will be transferable after unbonding. | | ||
### Parameters of Validators | ||
|
||
One preliminary method to make profit is to nominate a validator. There are multiple factors to consider when choosing a validator wisely. Although we do not make recommendations out of neutrality, we provide an explanation of the meaning of the parameters related to a validator. A comprehensive understanding can help you assess your candidates accurately. | ||
|
||
#### Active Commission | ||
|
||
The *active commission* is the percentage of the gain that the validator will draw before distributing according to staking power in the current era. This parameter is set by the validator. From one perspective, it measures the willingness of the validator to share the profit with nominators. Meanwhile, it can be interpreted as an indicator of their confidence in themselves. In a nutshell, one cannot say that the higher the better or otherwise. | ||
|
||
#### Next Commission | ||
|
||
The *next commission* is the percentage of the gain that the validator will draw before distributing according to staking power in the next era. This parameter is set by the validator. It may directly affect your profit if you endorse this validator. As explained above, this is not a simple measure of good or bad. | ||
|
||
#### Own Stake(Power) | ||
|
||
The *own stake (power)* is the amount of power that the validator has locked for staking currently. It indicates how much stake the validator has put in the game. Since if the validator is punished for some reason, part of the staking power will be slashed, the higher this number is, the higher risk the validator is willing to take. | ||
|
||
#### Other Stake(Power) | ||
|
||
The *other stake (power)* is the amount of power that nominators have trusted the validator with. This partly indicates the level of confidence that nominators have on the validator. | ||
|
||
#### Points | ||
|
||
The *point* is a measure of the validator's achievement in the current era. The validator normally gets 20 points for each block produced by them. If a validator has 1200 *points*, it means that this validator has produced 60(1200/20) blocks successfully so far in current era. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
sidebar_position: 3 | ||
title: Pangolin | ||
--- | ||
|
||
Pangolin is the testnet of Crab. | ||
|
||
## Network Info | ||
|
||
- Network Name: Pangolin | ||
- Token Name: PRING | ||
- Token Decimal: 9 | ||
- Block Explorer: | ||
- https://pangolin.subscan.io/ | ||
- HTTP Endpoints: | ||
- https://pangolin-rpc.darwinia.network | ||
- WSS Endpoints: | ||
- wss://pangolin-rpc.darwinia.network | ||
|
||
#### EVM Info | ||
- Network Name: Pangolin Smart Chain | ||
- Token Name: PRING | ||
- Token Decimal: 18 | ||
- ChainId: 43 | ||
- Block Explorer: | ||
- https://pangolin.subscan.io/ | ||
- HTTP Endpoints: | ||
- https://pangolin-rpc.darwinia.network | ||
- WSS Endpoints: | ||
- wss://pangolin-rpc.darwinia.network | ||
|
||
## Params | ||
|
||
### Block, Epoch and Era Time | ||
|
||
| Darwinia | Time | Slots | | ||
| -------- | --------- | ----- | | ||
| Block | 6 seconds | 1 | | ||
| Epoch | 0.5 hour | 300 | | ||
| Era | 1.5 hours | 900 | | ||
|
Oops, something went wrong.