From 6f235987dd239927515359743883d998ce035ef2 Mon Sep 17 00:00:00 2001 From: Elton <57287843+eltontay@users.noreply.github.com> Date: Thu, 6 Oct 2022 08:48:40 +0800 Subject: [PATCH] changing network to goerli --- README.md | 31 +++++++++++++++++++++++++------ contracts/FestivalNFT.sol | 10 +--------- remix-compiler.config.js | 10 ++++++++++ test/Festival.ts | 30 +++++++++++++----------------- 4 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 remix-compiler.config.js diff --git a/README.md b/README.md index c1a69ac..89f4bf3 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Overview -> Blockchain Festival is a web-based platform powered by Settlemint for buying and reselling of festival tickets using blockchain technology. By utilising blockchain technology, numerous issues can be eliminated : Scalping , Security and Data Collection. This platform is built on the public Ethereum blockchain with 2 smart contracts utilising the latest standards, where *"FestivalNFT"* follows the ERC721 standard and *"FestivalToken"* follows the ERC20 standard. +> Blockchain Festival is a web-based platform powered by Settlemint for buying and reselling of festival tickets using blockchain technology. By utilising blockchain technology, numerous issues can be eliminated : Scalping , Security and Data Collection. This platform is built on the public Ethereum blockchain with 2 smart contracts utilising the latest standards, where _"FestivalNFT"_ follows the ERC721 standard and _"FestivalToken"_ follows the ERC20 standard. ### Issues tackled @@ -19,6 +19,7 @@ > Data collection is an important aspect for organisers to better understand their target audience to ensure a successful launch of their festival. With blockchain technology, every transaction is tracked and monitored. This gives not just ownership of data to the organiser but also detailed insights. With these insights, organisers will be able to analyse the data and use them to achieve more successful campaigns. # + ## Technical Details ### Smart Contracts @@ -26,12 +27,31 @@ There are 2 contracts listed under the `./contracts` directory. - **FestivalToken** - - ERC20 Token, named FTK, which is used to transact festival tickets (FNFT). + - ERC20 Token, named FTK, which is used to transact festival tickets (FNFT). +- **FestivalNFT** + - ERC721 NFT, named FNFT, which is a representation of festival tickets. + - Takes in an ERC20 Token as a parameter for transactions of tickets. In this case, FTK. + +### Deployment of Smart Contract + +Since the Ethereum Merge, Infura does not support Rinkeby, Kovan or Ropsten. Currently (5 October 2022), facing issue connecting to a node provided by Settlemint, hence, with respect of time, will be switching to Infura Goerli testnet for the deployment of this project. + +You can view the contracts here + +- **FestivalToken** + +```bash +https://goerli.etherscan.io/token/0x32c2e50014417da4516fb78d683c574d38c0b37d +``` + - **FestivalNFT** - - ERC721 NFT, named FNFT, which is a representation of festival tickets. - - Takes in an ERC20 Token as a parameter for transactions of tickets. In this case, FTK. + +```bash +https://goerli.etherscan.io/token/0x52e18abefb44e0ceb543ecb0935d5c42c6b2f233 +``` # + ## How does it work? #### Creation of FTK @@ -67,8 +87,7 @@ There are 2 contracts listed under the `./contracts` directory. #### Purchase of FNFT on the Secondary Market -- When the customer wants to buy a FNFT on the secondary marketplace, the FNFT contract will first `approve()` the customer before the customer is - +- When the customer wants to buy a FNFT on the secondary marketplace, the FNFT contract will first `approve()` the customer before the customer is ### Explanation through HardHat Testing diff --git a/contracts/FestivalNFT.sol b/contracts/FestivalNFT.sol index 2960e35..812d198 100755 --- a/contracts/FestivalNFT.sol +++ b/contracts/FestivalNFT.sol @@ -280,11 +280,6 @@ contract FestivalNFT is checkTicketIsOwner(ticketId, _msgSender()) checkTicketNotOnSale(ticketId) { - // // Approving organiser - // approve(_organiser,ticketId); - // // Transferring of FNFT - // transferFrom(_msgSender(),_organiser, ticketId); - // Setting ticket details _ticketDetails[ticketId].sellingPrice = sellingPrice_; _ticketDetails[ticketId].forSale = true; @@ -302,9 +297,6 @@ contract FestivalNFT is checkTicketIsOwner(ticketId, _msgSender()) checkTicketOnSale(ticketId) { - // // Transferring of FNFT - // transferFrom(_organiser,_msgSender(), ticketId); - // Setting ticket details _ticketDetails[ticketId].sellingPrice = 0; _ticketDetails[ticketId].forSale = false; @@ -354,7 +346,7 @@ contract FestivalNFT is } // Transferring of NFT - transferFrom(seller, _msgSender(), ticketId); + this.transferFrom(seller, _msgSender(), ticketId); // Adjust ticket details _ticketDetails[ticketId].ticketOwner = _msgSender(); diff --git a/remix-compiler.config.js b/remix-compiler.config.js new file mode 100644 index 0000000..a963efc --- /dev/null +++ b/remix-compiler.config.js @@ -0,0 +1,10 @@ +module.exports = { + solidity: '0.8.9', + settings: { + optimizer: { + enabled: false, + runs: 200 + } + } + } + \ No newline at end of file diff --git a/test/Festival.ts b/test/Festival.ts index 7916c7a..3db99e9 100755 --- a/test/Festival.ts +++ b/test/Festival.ts @@ -7,7 +7,7 @@ describe('Festival', function () { // and reset Hardhat Network to that snapshot in every test. async function deployLockFixture() { // Contracts are deployed using the first signer/account by default - const [ organiser, buyer1, buyer2, buyer3] = await ethers.getSigners(); + const [organiser, buyer1, buyer2, buyer3] = await ethers.getSigners(); // Deploying Festival Token const FestivalToken = await ethers.getContractFactory('FestivalToken'); @@ -64,7 +64,7 @@ describe('Festival', function () { describe('Check Public Minting of FNFT', function () { it('Successful minting of 1 FNFT', async function () { - const { buyer1, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); + const { buyer1, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); await festivalToken.mint(buyer1.address, ethers.utils.parseUnits('1', 20)); // minting 100 FTK @@ -144,7 +144,7 @@ describe('Festival', function () { describe('Check Listing of FNFT on Secondary Marketplace', function () { it('Successful listing of 1 FNFT', async function () { - const {organiser, buyer1, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); + const { organiser, buyer1, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); await festivalToken.mint(buyer1.address, ethers.utils.parseUnits('1', 20)); // minting 100 FTK @@ -158,7 +158,7 @@ describe('Festival', function () { await festivalNFT.connect(buyer1).publicMint(1); // Approving organiser to transfer FNFT - await festivalNFT.connect(buyer1).approve(organiser.address,1); + await festivalNFT.connect(buyer1).approve(organiser.address, 1); // Listing 1 FNFT at 11 FTK await festivalNFT.connect(buyer1).setListing(1, ethers.utils.parseUnits('11', 18)); @@ -169,7 +169,7 @@ describe('Festival', function () { }); it('Failure listing of 1 FNFT above 110% Threshold', async function () { - const { organiser, buyer1, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); + const { organiser, buyer1, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); await festivalToken.mint(buyer1.address, ethers.utils.parseUnits('1', 20)); // minting 100 FTK @@ -183,7 +183,7 @@ describe('Festival', function () { await festivalNFT.connect(buyer1).publicMint(1); // Approving organiser to transfer FNFT - await festivalNFT.connect(buyer1).approve(organiser.address,1); + await festivalNFT.connect(buyer1).approve(organiser.address, 1); // Listing 1 FNFT at 12 FTK await expect(festivalNFT.connect(buyer1).setListing(1, ethers.utils.parseUnits('12', 18))).to.be.revertedWith( @@ -208,13 +208,13 @@ describe('Festival', function () { await festivalNFT.connect(buyer1).publicMint(1); // Approving organiser to transfer FNFT - await festivalNFT.connect(buyer1).approve(organiser.address,1); + await festivalNFT.connect(buyer1).approve(organiser.address, 1); // Listing 1 FNFT at 11 FTK await festivalNFT.connect(buyer1).setListing(1, ethers.utils.parseUnits('11', 18)); // Approving buyer2 to purchase - await festivalNFT.approve(buyer2.address,1) + await festivalNFT.approve(buyer2.address, 1); // Purchasing of 1 FNFT at 11 FTK await festivalNFT.connect(buyer2).purchaseListing(1, ethers.utils.parseUnits('11', 18)); @@ -226,7 +226,7 @@ describe('Festival', function () { describe('Check Monetisation', function () { it('Successful monetisation - 10%', async function () { - const { buyer1, buyer2, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); + const { organiser, buyer1, buyer2, festivalToken, festivalNFT } = await loadFixture(deployLockFixture); await festivalToken.mint(buyer1.address, ethers.utils.parseUnits('1', 20)); // minting 100 FTK await festivalToken.mint(buyer2.address, ethers.utils.parseUnits('1', 20)); // minting 100 FTK @@ -243,26 +243,22 @@ describe('Festival', function () { await festivalNFT.connect(buyer1).publicMint(1); // Approving organiser to transfer FNFT - await festivalNFT.connect(buyer1).approve(organiser.address,1); + await festivalNFT.connect(buyer1).approve(organiser.address, 1); // Listing 1 FNFT at 11 FTK await festivalNFT.connect(buyer1).setListing(1, ethers.utils.parseUnits('10', 18)); // Approving buyer2 to purchase - await festivalNFT.approve(buyer2.address,1) + await festivalNFT.approve(buyer2.address, 1); // Purchasing of 1 FNFT at 10 FTK await festivalNFT.connect(buyer2).purchaseListing(1, ethers.utils.parseUnits('10', 18)); // Checking FTK balance of buyer1, should be 10% less of 10, note need to deduct the price of public mint - expect(await festivalToken.balanceOf(buyer1.address)).to.equal( - ethers.utils.parseUnits('99', 18) - ); + expect(await festivalToken.balanceOf(buyer1.address)).to.equal(ethers.utils.parseUnits('99', 18)); // Checking FTK balance of buyer2 - expect(await festivalToken.balanceOf(buyer2.address)).to.equal( - ethers.utils.parseUnits('90', 18) - ); + expect(await festivalToken.balanceOf(buyer2.address)).to.equal(ethers.utils.parseUnits('90', 18)); }); }); });