This is an Android app where you can upload every resource from your smartphone and turn it into an NFT and you easily can deploy your own tokens and transfer them
Warning: This project is currently using Rinkeby testnet and NOT Ethereum mainnet, so you are actually save from wasting real Ether
Architecture:
I am strongly dedicated to use clean architecture to separate UI, Domain, Datasource and Network logic. I am using the MVI state management approach where the UI observes viewmodel state for updating UI. User interaction triggers events on the viewmodel which also yields UI changes.
UI: For the UI I use the single Activity multiple Fragment approach where UI logic is only implemented in Fragments (android sdk imports only in Fragments or Activities)
Domain Logic: Domain logic (like smart contract interaction via network or persisting or fetching data) is implemented in UseCases. For connecting Domain and UI I am going with the Model View Intent (MVI) approach and I am using orbit mvi (https://github.com/orbit-mvi/orbit-mvi) for state management.
Dependency Injection: In this project I am using Koin (https://github.com/InsertKoinIO/koin) to inject dependencies into viewmodels, usecases, etc. because in my opinion it uses least boilerplate code besides of Dagger and Hilt
Other Libraries:
- web3j for smart contract communication: https://github.com/web3j/web3j
- kotlinx-serialization for serialising data objects to json
- Java ipfs client for uploading NFT files to IPFS (inter planetary file system) https://github.com/ipfs-shipyard/java-ipfs-http-client
- QR Code Scanner https://github.com/yuriy-budiyev/code-scanner
- Vanilla fragment transactions for navigation (no jetpack navigation or much better FragNav https://github.com/ncapdevi/FragNav this time)
- Check out the project
- Deploy the NFT and Token solidity contracts from the contracts package to rinkby testnet as described here: https://medium.com/interfacing-with-a-blockchain/communicating-with-an-ethereum-smart-contract-via-android-24ee0dd2c115
- In config.kt update MYTOKEN_CONTRACT_ADDRESS and NFTOKEN_CONTRACT_ADDRESS to your NFT and Token contract addresses.
- Add a file named secret.properties in your root folder
- Add the private key like
PRIVATE_KEY = c3aa087557782766a298252c90248d0657a50349c7c3aea2643884ffbaa4070c
from the addresses you deployed the contracts. This is needed to load the contracts. - Compile the app and install it to your phone
Scan the address which will own the NFTs
When you first open the app a QR Code scanner will open where you have to scan your ethereum address e.g. from metamask
Mint your NFT
In the "Create NFT" tab you can first upload any resource (currently supported: jpg, png, jpeg, pdf, mp4, mp3, m4a) from your phones file system to ipfs. (You can add support for new filetypes by extending SUPPORTED_FILE_TYPES in config.kt)
When you are satisfied what you see in preview you can mint your NFT which will write the ipfs url to the rinkeby ethereum blockchain.
Admire your minted NFTs
In the "My NFTs" tab you can admire your NFTs in a list
Transfer Token to your address
In the "Tokens" tab you can see
- The total amount of "MyToken" with Symbol "MTK" supplied
- The amount of MTK Token the token creator holds
- The amount of MTK Token the current user holds
With tapping the "Transfer 5 Token" button you can transfer 5 MTK Token to your current address
Props to https://stackedit.io/app where I created this README