Welcome to the EVM-XCM Examples repository! This repository contains examples demonstrating solidity contracts using XCM precompiles on Astar network.
The EVM-XCM Examples repository provides code implementation, set up scripts and integrations tests showcasing how to use XCM precompiles in solidity contracts in Astar. There is one example for each precompile function. Each example is compose by:
- a set up script (in ./scripts/assetsSetUp.ts)
- a solidity implementation (in ./contracts/example)
- integration tests (in ./tests/example.ts)
The goal is to provide a simple and easy to understand examples for each precompile function. The examples are not meant to be used in production but to help developers to understand how to use XCM precompiles in Astar.
To get started with these examples, follow these steps:
Please download those binaries and copy then in ./zombie-net
Polkadot
Zombie net binary
Astar
For Mac users please downlaod compatible binaries:
Polkadot (MEGA link)
Astar binary
Zombie net binary (MEGA Link)
Alternatively you can compile Polakdot & Astar node on you local machine.
1.2 please rename binaries:
polakdot
astar-collator
zombienet
1.3 Please make the binaries executable:
chmod +x ./polkadot ./astar-collator ./zombienet
1.4 Run zombie-net with the command:
./zombienet -p native spawn multi.toml
The examples rely on a Shibuya and Shiden parachain with an open HRMP channel. an asset TST (id = 1) is created in both parachain. Location is registerd as Shibuya. First ensure zombienet is running
yarn
yarn setup
yarn build
yarn transfer
yarn withdraw
This example will transfer asset id = 1 owned by alith (EVM H160 address of Alice) from Shibuya to Shiden using reserve asset transfer.
The contract can be found in ./contracts/asset-transfer/assetTransfer.sol
. Integrations tests are in the file ./test/reserveAssetTransfer.ts
.
Contributions to this repository are welcome! If you have an example or tutorial related to EVM and XCM that you'd like to add, please follow these steps:
- Fork this repository.
- Create a new branch, commit, and open a Pull Request