Follow the Aleph Zero guide to install rust and ink!. Note, that:
- probably you'll have to run
cargo install dylint-link
during the installation, when prompted so, - You can now safely execute
cargo install cargo-contract
to install cargo-contract, instead of installing a specific snapshot as noted in the tutorial.
When adding new contract/library, make sure the ink!
version used in Cargo.toml
is 3.3
.
There are only a few unit tests, because cross-contract unit testing is not available at the current version of ink!, and PSP22 token transfers calls by standard specification _before_transaction method on receiver.
To run these tests, type make test
in console.
make all
ormake all RELEASE_FLAGS="--optimization-passes=0"
.- Open online blockchain frontend and login to your account.
- Make sure you have enough
SZERO
tokens (or get them on https://faucet-smartnet.test.azero.dev/). - Upload & deploy these contracts: contracts/example_borrower and contracts/psp22_token_a. For contracts/default_provider set
fee_per_1M_tokens
to, for example, 900 (correcponding to 0.09% fee).
- Mint some (e.g 1'000'000) "PSP22 token A" tokens to provider, and some less to borrower (e.g 10).
- Execute provide_flashloan method on contracts/default_provider, setting receiver to exaple_borrower, token to PSP22 token A and amount to some integer.
- Transaction should be successfull and balances of both accounts should be equal to previous state +- flash loan fee.