git clone https://github.com/OmniBTC/polkadot.git
cd polkadot
git checkout release-v0.9.32-fix
cargo build --release
git clone https://github.com/OmniBTC/PSC.git
cargo build --release
zombienet aims to be a testing framework for Substrate based blockchains,
providing a simple cli tool that allows users to spawn and test ephemeral networks.
Make sure that zombienet
, polkadot
and psc
in your PATH
.
cd PSC
zombienet spawn --provider native ./zombienet/psc-small-network.toml
We provide polkadot
and psc
docker images to support podman
.
docker pull comingweb3/polkadot:v0.9.32
docker pull comingweb3/psc:latest
cd PSC
zombienet spawn --provider podman ./zombienet/psc-small-network.toml
Direct use polkadot.js.org
for develop accounts
Direct link: https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9944#/explorer
Direct link: https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9977#/explorer
transfer 10000000000000000
(means 1000000 DOT, decimals=10) to Alice(5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
)
transfer 1000000000000000
(means 100000 DOT, decimals=10) to Alice(15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5
)
Network name: Polkadot Smart Chain
RPC URL: http://127.0.0.1:8546
Chain ID: 1508
Currency symbol: DOT
Eth Signed Data Format
"evm:" + substrate_pubkey_hex_without_0x
Alice
account address: 15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5
Use this online tool
can get its public key: 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
To sign data is evm:d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
Open remix connect to metamask(select you evm account, here is 0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a
)
Use remix sign tool, to sign evm:d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
Get the signature: 0x861509e2adea37d7a85448fef8d857f6018bb95fe574aec21ac7977da4d0b1481fd789cc7821748b31691c7e151c45782b0535cdfd483739276ab05535f542311c
The evm address 0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a
has been bound to the Alice
substrate address 15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5
.
Call assetsBridge->teleport
deposit 1000000000000
(means 100 DOT, decimals=10)
The transferable DOT is 99.99
, because EXISTENTIAL_DEPOSIT = 0.01 DOT
on PSC.
For more details, By this tool, we can get the evm address's proxy substrate account.
node src/evm_to_dot.js 0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a
evm address: 0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a
dot account: 15gBPp5zAgaxtgzMi843onWu1gUuXbKMAy5Xu3XTNKcUqreH
The balance is indeed 100
DOT.
Transfer 10
DOT from 0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a
to 0xcaf084133cbdbe27490d3afb0da220a40c32e307
The evm address 0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a
has been bound to the Alice
substrate address 15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5
.
Alice
Call assetsBridge->teleport
to withdraw 100000000000
(means 10 DOT, decimals=10) from 0x6CfE5574639Ba46d74b6b67D2651d1470E10BA9a
,
And it will deposit 100000000000
(means 10 DOT, decimals=10) into Alice(15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5)
.
Mint 1000000000000000000000
(means 1000 Reserved0, decimals = 18) to Alice
Run remixd to access local contracts
cd PSC
bash scripts/remix.sh
Choose AssetsBridgeErc20_OnlyAdmin.sol
to compile
Deploy AssetsBridgeErc20
contract
name = Reserved0
symbol = RSV0
decimals = 18
Get the contract address 0xf3607524cAB05762cB5F0cAb17e4cA3A0F0b4E87
For this guide, the admin of assets-bridge
is Alice.
In the production environment, the admin of assets-bridge
must audits
whether the erc20 contract implements IAssetsBridge
interface and
whether it has the AssetsBridgeAdmin
modifier.
Call assetsBridge->register
Deposit 1000000000000000000000
(means 1000 Reserved0, decimals = 18) Reserved0 from wasm to evm
Before the balance is 0
, now is 1000000000000000000000
(means 1000 Reserved0, decimals = 18)
Withdraw 1000000000000000000000
(means 1000 Reserved0, decimals = 18) from evm to wasm
Before the balance is 1000000000000000000000
(means 1000 Reserved0, decimals = 18), now is 0