Ongoing
I updated the code of tokenContract I was able to make work the functions:
-
buyToken() function allows a buyer to purchase a token from the contract. The buyer needs to send a payment equal to or greater than VALUE_PER_TOKEN. If the payment is sufficient and the token supply has not reached the maximum, a new token is minted for the buyer, the payment is transferred to the contract owner, and the buyer's token balance is incremented by 1.
-
sellToken() function allows the owner of a token to put it up for sale. The caller must be the owner of the token and provide a sale price greater than or equal to
VALUE_PER_TOKEN
. The token should not already be on sale, and the buyer must not have already bought a token. If all conditions are met, the token is put on sale with the specified price and the buyer is defined. -
buyToken_byID() function allows a buyer to purchase a token by its ID. It checks if the token is for sale and if the caller is allowed to buy it. The buyer must send the required payment, including the sale price and a fee. The token ownership is transferred, and funds are distributed to the seller and the contract owner. The token prices and buyers are updated, and token balances are adjusted.
For the function retrieveAllTokens() which should give back all nfts to the owner does not work. Maybe we cannot do so many transfers in one transaction. We should try to modify the function such that it does it by ID like retrieveByID(). But I did not try. I will stop for today.
If you want to try to developp you should do the setup which I said the other day (metamask + alchemy + sepolia eth ; cf old message). You should:
- Copy paste the code on remix (be sure to be on sepolia blockchain)
- Compile it
- Deploy it
- Copy the adress of the created smart contract
- Create an account on oppenzepplin (if not done already)
- Go on https://defender.openzeppelin.com
- Click on Add Contract and Import Contract
- Give a name, choose the right blockchain (sepolia) paste the contract address and paste the ABI (check Notion if you want a small tuto)
After that you can try the functions by making a "New Proposal" -> Admin Section. Choose the function which you want to try and complete the arguments if needed. For the "Execution Strategy" choose EOA and select your metamask adress. After that you should be able to "create admin action" at the bottom of the page.