Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chainxbridge.md #670

Open
wants to merge 4 commits into
base: develop-2022
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Any kinds of contributions are highly welcome. Feel free to submit an issue if y

## Metamask config for BTC
```
Network name: ChainX
Network name: BEVM
RPC URL: https://mainnet.chainx.org/rpc
Chain ID: 1501
Currency symbol: BTC
Expand Down
Binary file added docs/account-convert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/btc-balance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/btc-evm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/btc-to-evm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions docs/chainxbridge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# ChainXBridge

Through ChainXBridge, assets in BEVM(formerly called `chainx-evm`) and Bitcoin can circulate freely

![chainx-v5](https://github.com/chainx-org/ChainX/assets/8869892/9ba9afdc-c738-4392-8f05-2d9d91d3b3bd)

## 1. Deposit

### 1.1 BTC(bitcoin -> bevm)
TODO

### 1.2 BRC20(bitcoin -> bevm)
TODO

### 1.3 PCX(chainx -> bevm)
ChainX wallet: https://dapp.chainx.org/#/chainstate/extrinsics

xAssetsBridge -> depositPcxToEvm

100000000 means 1 PCX

![deposit-pcx](./deposit-pcx.png)

PCX erc20 address: `0xf3607524cAB05762cB5F0cAb17e4cA3A0F0b4E87`

metamask wallet

![pcx-metamask](./pcx-metamask.png)

### 1.4 XBTC => BTC(chainx -> bevm)
ChainX wallet: https://dapp.chainx.org/#/chainstate/extrinsics

xAssetsBridge -> swapXbtcToBtc

1000 means 0.00001000 XBTC

![btc-to-evm](./btc-to-evm.png)

### 1.5 BTC(chainx -> bevm)
ChainX wallet: https://dapp.chainx.org/#/chainstate/extrinsics

xAssetsBridge -> transferBtcToEvm

1000 means 0.00001000 BTC

![transfer-btc-to-evm](./transfer-btc-to-evm.png)

## 2. Withdraw

### 2.1 BTC(bevm -> bitcoin)
TODO

### 2.2 BRC20(bevm -> bitcoin)
TODO

### 2.3 PCX(bevm -> chainx)
ChainXBridge(mainnet): **0xd1543A52d770D32854fc5f5F076a74033D49D41f**

通过remix调用ChainXBridge合约中的**withdrawPCX**
```solidity
function withdrawPCX(
uint256 value,
bytes32 chainxPubkey
) external autoIncreaseNonce returns (bool) {
return SystemWithdraw.withdrawPCX(value, chainxPubkey);
}
```

下载ChainX源码,启动remixd
```bash
$ git clone https://github.com/chainx-org/ChainX.git
$ cd ChainX
$ bash scripts/remix.sh
```

metamask连接chainx-evm
![img.png](remix-chainx-bridge.png)

在"At Address": 填入chainx bridge合约地址 **0xd1543A52d770D32854fc5f5F076a74033D49D41f**

调用 "withdrawPCX": 第一个参数填pcx balance(decimals=8), 第二个参数填chainx账户的公钥


chainx账户转公钥可用下面的工具: https://scan.chainx.org/tools/SS58
![img.png](account-convert.png)


## 3. Query balance

### 3.1 BTC(bevm)

![btc-evm](./btc-evm.png)

### 3.2 BTC(wasm)

`0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a` mapping to `5UKCmTuj5V4wmGnmZYm6RSDbT2mqwf2FUMTJy7phjwmwE51H`

https://evm.chainx.org/tools/SS58

![evm-to-chainx](./evm-to-chainx.png)

https://dapp.chainx.org/#/chainstate/chainstate

![btc-balance](./btc-balance.png)

### 3.3 PCX(bevm)

![pcx-evm](./pcx-evm.png)

### 3.4 PCX(wasm)

https://dapp.chainx.org/#/chainstate/chainstate

![pcx-balance](./pcx-balance.png)
Binary file added docs/deposit-pcx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/evm-to-chainx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pcx-balance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pcx-evm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pcx-metamask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/remix-chainx-bridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/transfer-btc-to-evm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading