This document will guide you through all the necessary steps to locally run this project.
Download the latest release of the Astar node to run it locally:
$ astar-collator --dev --tmp
Create 2 assets (loan, collateral):
From under Network -> Assets click create asset and create them as follows
You have to mint some token for each asset.
Afterwards the tokens can be used as ERC20 tokes (via XC20):
- AssetID 4242 -> 0xFFFFFFFF00000000000000000000000000001092
- AssetID 4243 -> 0xFFFFFFFF00000000000000000000000000001093
You can add these tokens to your Metamask wallet via "Import token" and using the above as contract address.
To provide liquidity to an account in Metamask you need to convert the H160 address from the Metamask wallet. You can transfer the native token or assets to the converted SS58 address with the polkadot.js explorer.
Or you can add the Test account that is funded with native token to Metamask.
Using the Openzeppelin Contract wizard, you can create an ERC721 contract and deploy it through Remix+Metamask.
Apart from the Mintable and Auto Increment Ids, the Enumerable option is useful for debugging and testing.
Copy the address of the onchain substrate account ID of your test-user (not the wallet address) and use the address converter to convert the SS58 account ID to an H160 EVM compatible address:
Now use the Remix interface to call the safeMint an NFT to this H160 address.
Copy the ERC721 contract address (H160) and the ID of the NFT that you just minted.
You can use the build-all.sh script to build all the contracts.
- Deploy sign_transfer.contract
- Deploy oracle.contract
Copy the hash (Not the address!) of both and supply them as argument for the constructor when deploying collateral.contract, also set usingMock to true for manual testing.
Now that the Collateral contract is successful deployed, you can call the registerNFTCollection function to start accepting NFTs from this collection as collateral for a loan.
You can verify the register action was successfull using the functions registeredNFTCollection and testQueryOracle
The first step for an account to start using the Collateral contract is to call the depositNFT function.
The arguments for this function are:
- The H160 EVM ERC721 contract address
- The ID of the previously minted NFT
A successful call to depositNFT can be verified by using myLoanStatus for the same user.
If your ERC721-contract has the Enumerable option, you can verify the NFT changed owner by calling ownerOf for the given NFT ID.