This project contains the smart contract and related scripts for migrating DUSK tokens from ERC20/BEP20 to native DUSK. The project is built using Hardhat.
Migration Flow:
- User invokes
migrate()
with ERC20/BEP20 DUSK tokens and their Dusk mainnet Moonlight key. - The contract locks the ERC20/BEP20 tokens and emits a
Migration
event. - An external service listens to the event and reissues native DUSK on the Dusk network.
The DUSK migration contract is designed to lock DUSK into the contract, and provide a receiving address on the DUSK side. It includes:
- Smart Contracts: A Solidity migration contract and an ERC20 mock based on ERC20 DUSK for testing.
- Scripts: Scripts for compiling contracts, extracting the ABI, listening to the migrate events and collecting past events.
- Tests: Integration tests that test how the migrate function behaves.
git clone https://github.com/dusk-network/dusk-migration/tree/main
Install the dependencies:
npm install
To compile the smart contracts, run:
npm run compile
The contracts and their artifacts can be found in the artifacts/
directory.
To extract the contract ABI from the compiled DUSKMigration
contract, use:
npm run abi
To listen to migration events, set up a .env
file based on the example.env
file and run:
npm run events:listen
To get past migration events, set up a .env
file based on the example.env
file and run:
npm run events:past
This will dump an .abi.json
file in the contract
folder.
To run the tests:
npm test