In this assessment, complete the dapp to allow users to connect their wallet accounts and purchase TESLA coins. You will also need to deploy the contracts required to mint and transfer the coins.
- total amount: 1000000
- decimals: 0
- asset name: Tesla
- asset unit name: TSLA
- manager: -
- clawback : -
- freeze: -
- reserve: -
rekey to
,close remainder to
,asset close to
addresses are not found in the transactions.
Complete the stateful smart contract assets/mint_approval.py
which allows only the contract creator to mint, transfer and burn TESLA coins. These are the following features required for each function,
- Prevent double asset creation.
- Create TESLA asset via app call.
- Enough supply to conduct asset transfer.
- Asset must be created before calling this function.
- Transfer TESLA coins to holding contract.
- Enough supply to conduct asset transfer.
- Transfer TESLA coins to burn contract.
Complete the stateful smart contract assets/holdings_approval.py
which allows the opt in users to purchase TESLA coins at the cost of 1 TSLA = 5 Algos. Contract creator can update the price if necessary.
- Saves asset ID and current purchase price in global state.
- Contract creator function.
- App call to allow contract to opt into that asset.
- Contract creator function.
- Saves the updated price in global state.
- Check receiver's coin balance and existing supply before selling tokens.
- Transaction that calls this function should be an grouped transaction which consists of a payment and an app call.
- Payment amount should include transaction fees and payment for the TESLA coins.
Complete the stateful smart contract assets/burn_approval.py
which allows contract creator to send TESLA coins to it. This contract should not allow anyone to transfer coins out of it.
- Saves asset ID in global state.
- Contract creator function.
- App call to allow contract to opt into that asset.
- Deploy the minting contract to create the TESLA coin.
- Fund minting contract with algos to perform asset transfer.
- Deploy the holding contract with the asset ID and purchase price.
- Deploy the burn contract.
- Perform asset opt in for holding and burn contracts.
Complete the server side scripts to allow creator to update prices, transfer and burn supply.
This repository contains a VueJS frontend with some basic wallet integration. It displays a form which allows connected account to request for TESLA coins in a simple HTML form. Feel free to replace this with ReactJS (or any other JS frontend frameworks) if you wish. However, the completed app should do the following,
- Allow user to successfully buy TESLA coins.
- Display remaining TESLA coins in the holding contract.
Write test cases to cover the successful contract deployment, as well as negative tests.
Your contracts should cover at least the following negative tests.
- Double asset creation fails
- Asset creation fails when non-creator calls
- Asset transfer fails when supply is insufficient
- Asset burn fails when supply is insufficient
- Asset transfer fails when non-creator calls
- Asset burn fails when non-creator calls
- Updating price of asset fails when not called by creator
- Selling token fails when supply < amount sold
- Selling tokens fails when transaction is not grouped
- Buying 0 token fails
- Buying tokens with insufficient algos
- Transfer token to non holding app fails
- Burn token to non burn app fails
Your application should be able to connect to AlgoSigner (localhost) and allow the connected account to buy tokens from the holdings contract. As an added bonus, try to deploy your application to TestNet as well.
yarn install
- Copy
.env.example
to.env
. - Update credentials in
.env
file.
# Run all deployment scripts
yarn run algob deploy
# Run one deployment script
yarn run algob deploy scripts/<filename>
# Run non deployment scripts
yarn run algob run scripts/path/to/filename
# Clear cache
yarn run algob clean
# Run tests
yarn run algob test
# Run dapp on localhost
yarn serve