Skip to content

Latest commit

 

History

History
157 lines (120 loc) · 4.63 KB

readme.md

File metadata and controls

157 lines (120 loc) · 4.63 KB

Local Network Config

This is a tutorial to run a local network with a rococo relay chain and two parachain (statemint and trappist).

You need to download Zombienet for linux or macOs and for test purposes we've prepared some parachain binaries that you can donwload all chains binaries from:

Then, create a folder called bin with all binaries inside and copy this config.toml, your folder should look like this:

make all binaries executable:

sudo chmod +x polkadot
sudo chmod +x polkadot-parachain
sudo chmod +x trappist-collator
sudo chmod +x zombienet-linux

run:

# or ./zombienet-macos
./zombienet-linux -p native spawn config.toml

If you you want to run it in windows see zombienet repo.

Relay chain and Parachains

There is a default config:

  • Relay chain is in port 9900
  • Statemine Parachain is in port 9910 with id 1000
  • Trappist Parachain is in port 9920 with id 2000
  • Otrher Trappist Parachain is in port 9930 with id 3000

Config Assets

If you want to transfer asset between parachains, we already prepared a script that will create xUSD asset on Statemine and txUSD asset on Trappist. You will able to transfer only xUSD to txUSD. It takes ~30s to finish.

run script:

npx ts-node src/examples/local-network/config-assets.ts

Then, mint some asset to Alice (for the examples) or any account. We recommend to mint 10000000 (1 million of xUSD) to have enough xUSD to test transfers.

If you want to create you own assets, you can follow this guide that we've prepared.

Examples

All the examples have alice as sender and bob as destination account per default. If you want to change it, modify src/examples/local-network/local-network-utils.ts

default config:

export const localNetworkUtils = {
  relayRpc: 'ws://127.0.0.1:9900',
  parachain1Rpc: 'ws://127.0.0.1:9911',
  parachain2Rpc: 'ws://127.0.0.1:9921',
  parachain1ChainId: 1000,
  parachain1DestinationAccount: 'FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP', // bob account on statemine
  parachain2ChainId: 2000,
  parachain2DestinationAccount: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty', //bob account on trappist
  relayChainDestintionAccount: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty', // bob account on relay
}

Transfer Asset from Relaychain to Statemine

command:

npx ts-node src/examples/local-network/teleportAssets-to-parachain.ts

manually:

  const destination = "Parachain"
  const destinationValue = 1000 // Statemine parchain id
  const beneficiary = "AccountId32"
  const beneficiaryValue = "<bob acount>" // account address
  const amount = 1000000000000000

  const res = await provider.teleportAssets({
    destination,
    destinationValue,
    beneficiary,
    beneficiaryValue,
    amount,
  });

Transfer Asset from Statemine to Relaychain

command:

npx ts-node src/examples/local-network/limitedTeleportAssets-to-relaychain.ts

manually:

  const destinationParents = 1
  const beneficiary = 'AccountId32'
  const beneficiaryValue = "<bob account>"
  const assetParents = 1
  const amount = 1000000000000

  const res = await provider.limitedTeleportAssets({
    destination,
    destinationValue,
    beneficiary,
    beneficiaryValue,
    amount,
  });

Transfer xUSD from statemine to txUSD on Trappist

Make sure alice has enough xUSD minted, and you already run the script for the asset configuration.

command:

npx ts-node src/examples/local-network/limitedTeleportAssets-to-relaychain.ts

manually:

  const destination = 'Parachain'
  const destinationValue = 2000 // trappist parachain id
  const destinationParents = 1
  const beneficiary = 'AccountId32'
  const beneficiaryValue = "<bob account>"
  const assetId = 1 // xUSD
  const amount = 100000000000000 // 100 xUSD

  const res = await provider.limitedReserveTransferAssets({
    destination,
    destinationValue,
    destinationParents,
    beneficiary,
    beneficiaryValue,
    assetId,
    amount,
  })