Skip to content

Commit

Permalink
changing network to goerli
Browse files Browse the repository at this point in the history
  • Loading branch information
eltontay committed Oct 6, 2022
1 parent 805e81d commit 6f23598
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 32 deletions.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -19,19 +19,39 @@
> 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

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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 1 addition & 9 deletions contracts/FestivalNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions remix-compiler.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
solidity: '0.8.9',
settings: {
optimizer: {
enabled: false,
runs: 200
}
}
}

30 changes: 13 additions & 17 deletions test/Festival.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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));
Expand All @@ -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

Expand All @@ -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(
Expand All @@ -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));
Expand All @@ -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
Expand All @@ -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));
});
});
});

0 comments on commit 6f23598

Please sign in to comment.