├── homepage.png
├── public
├── logo.png
└── favicon.ico
├── jsconfig.json
├── next.config.js
├── src
├── config
│ └── config.js
├── pages
│ ├── _document.js
│ ├── _app.js
│ ├── api
│ │ ├── transactionCount.js
│ │ ├── nodeHours.js
│ │ ├── rewardAmount.js
│ │ ├── stakeEnough.js
│ │ ├── unstakeCount.js
│ │ └── transfer.js
│ ├── index.js
│ ├── node.js
│ ├── rpc.js
│ ├── defi.js
│ └── nft.js
├── styles
│ ├── defi.module.css
│ ├── globals.css
│ └── Home.module.css
├── context
│ └── WalletContext.js
├── components
│ └── Header.js
├── abis
│ ├── TSTTokenABI.js
│ └── UniswapAbi.js
├── SwapToken.json
├── TSTToken.json
└── NFTMinter.json
├── scripts
├── deployNFT.js
├── deploySwapToken.js
├── deployTSTERC20.js
└── deploy.js
├── hardhat.config.js
├── contracts
├── TSTERC20.sol
├── NFT.sol
└── SwapToken.sol
├── .gitignore
├── test
├── SwapToken.js
├── TSTERC20.js
└── Lock.js
├── package.json
└── README.md
/homepage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shardeum/shardeum-dapp-boilerplate/HEAD/homepage.png
--------------------------------------------------------------------------------
/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shardeum/shardeum-dapp-boilerplate/HEAD/public/logo.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shardeum/shardeum-dapp-boilerplate/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "paths": {
4 | "@/*": ["./src/*"]
5 | }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {
3 | reactStrictMode: true,
4 | }
5 |
6 | module.exports = nextConfig
7 |
--------------------------------------------------------------------------------
/src/config/config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | "TSTToken": "0x31213FF9ff4296B747028041eF354002aD785b85",
3 | "SHMToken": "0x2d9FE6DFa994261c46e3a203ba6619726BB05e63",
4 | "UniswapRouter": "0xECA7c18438c86F63Cc8a56F376Da97Fd77ccC365",
5 | Slippage:2,//2%
6 | }
--------------------------------------------------------------------------------
/src/pages/_document.js:
--------------------------------------------------------------------------------
1 | import { Html, Head, Main, NextScript } from 'next/document'
2 |
3 | export default function Document() {
4 | return (
5 |
6 |
8 |
9 |
10 |
11 |
12 | )
13 | }
14 |
--------------------------------------------------------------------------------
/scripts/deployNFT.js:
--------------------------------------------------------------------------------
1 | const hre = require("hardhat");
2 |
3 | async function main() {
4 | const NFT = await hre.ethers.getContractFactory("NFTMinter");
5 | const nft = await NFT.deploy();
6 |
7 | await nft.deployed();
8 |
9 | console.log(
10 | `Deployed at ${nft.address}`
11 | );
12 | }
13 |
14 | main().catch((error) => {
15 | console.error(error);
16 | process.exitCode = 1;
17 | });
--------------------------------------------------------------------------------
/hardhat.config.js:
--------------------------------------------------------------------------------
1 | require("@nomicfoundation/hardhat-toolbox");
2 |
3 | /** @type import('hardhat/config').HardhatUserConfig */
4 | module.exports = {
5 | solidity: "0.8.20",
6 | networks: {
7 | localhost: {
8 | url: "http://127.0.0.1:8545/",
9 | },
10 | shm: {
11 | url: "https://hackathon.shardeum.org/",
12 | accounts: ["pk"],
13 | gas: 20000000,
14 | },
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/src/pages/_app.js:
--------------------------------------------------------------------------------
1 | import '@/styles/globals.css';
2 | import WalletHeader from '@/components/Header';
3 | import { WalletProvider } from '@/context/WalletContext';
4 |
5 | function App({ Component, pageProps }) {
6 | return (
7 |
8 |
9 |
10 |
11 |
12 |
13 | );
14 | }
15 |
16 | export default App;
17 |
--------------------------------------------------------------------------------
/src/pages/api/transactionCount.js:
--------------------------------------------------------------------------------
1 | import fetch from 'node-fetch';
2 |
3 | export default async (req, res) => {
4 | const { address } = req.query;
5 |
6 | try {
7 | const response = await fetch(`https://api.shardeum.org/api/count?address=${address}`);
8 | const data = await response.json();
9 |
10 | res.status(200).json(data);
11 | } catch (error) {
12 | res.status(500).json({ error: 'Failed to fetch data' });
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/src/pages/api/nodeHours.js:
--------------------------------------------------------------------------------
1 | import fetch from 'node-fetch';
2 |
3 | export default async (req, res) => {
4 | const { address } = req.query;
5 |
6 | try {
7 | const response = await fetch(`https://api.shardeum.org/api/nodeActiveHours?address=${address}`);
8 | const data = await response.json();
9 |
10 | res.status(200).json(data);
11 | } catch (error) {
12 | res.status(500).json({ error: 'Failed to fetch data' });
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/src/pages/api/rewardAmount.js:
--------------------------------------------------------------------------------
1 | import fetch from 'node-fetch';
2 |
3 | export default async (req, res) => {
4 | const { address } = req.query;
5 |
6 | try {
7 | const response = await fetch(`https://api.shardeum.org/api/rewardAmount?address=${address}`);
8 | const data = await response.json();
9 |
10 | res.status(200).json(data);
11 | } catch (error) {
12 | res.status(500).json({ error: 'Failed to fetch data' });
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/src/pages/api/stakeEnough.js:
--------------------------------------------------------------------------------
1 | import fetch from 'node-fetch';
2 |
3 | export default async (req, res) => {
4 | const { address } = req.query;
5 |
6 | try {
7 | const response = await fetch(`https://api.shardeum.org/api/stakeEnough?address=${address}`);
8 | const data = await response.json();
9 |
10 | res.status(200).json(data);
11 | } catch (error) {
12 | res.status(500).json({ error: 'Failed to fetch data' });
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/src/pages/api/unstakeCount.js:
--------------------------------------------------------------------------------
1 | import fetch from 'node-fetch';
2 |
3 | export default async (req, res) => {
4 | const { address } = req.query;
5 |
6 | try {
7 | const response = await fetch(`https://api.shardeum.org/api/unstakeCount?address=${address}`);
8 | const data = await response.json();
9 |
10 | res.status(200).json(data);
11 | } catch (error) {
12 | res.status(500).json({ error: 'Failed to fetch data' });
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/src/styles/defi.module.css:
--------------------------------------------------------------------------------
1 | .header{
2 | text-align: center;
3 | }
4 | .swapcard{
5 | position: relative;
6 | display: flex;
7 | flex-direction: column;
8 | justify-content: center;
9 | padding: 2rem;
10 | width:30%;
11 | gap: 10px;
12 | height: 50%;
13 | margin:5% auto;
14 | border-radius: 10px;
15 | color: #ffffff;
16 | border: 2px solid rgb(210, 208, 206) ;
17 | background-color: #001529;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/contracts/TSTERC20.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.0;
3 |
4 | import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
5 |
6 |
7 | contract TSTToken is ERC20{
8 |
9 | constructor(uint256 intialSupply) ERC20("TSTToken", "TSTT") {
10 | _mint(msg.sender, intialSupply * 10 ** 18); // Mint 1,000,000 tokens during deployment
11 | }
12 |
13 | function mint(address to, uint256 amount) external {
14 | _mint(to, amount);
15 | }
16 |
17 |
18 | }
--------------------------------------------------------------------------------
/src/pages/api/transfer.js:
--------------------------------------------------------------------------------
1 | import fetch from 'node-fetch';
2 |
3 | export default async (req, res) => {
4 | const { address } = req.body;
5 |
6 | try {
7 | const response = await fetch(`https://api.shardeum.org/api/transfer?address=${address}`, {
8 | method: 'POST'
9 | });
10 |
11 | if (!response.ok) {
12 | return res.status(response.status).json({ error: 'Transfer failed.' });
13 | }
14 |
15 | const data = await response.json();
16 | res.status(200).json(data);
17 | } catch (error) {
18 | res.status(500).json({ error: 'Transfer failed.' });
19 | }
20 | };
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env*.local
29 |
30 | # vercel
31 | .vercel
32 |
33 | # typescript
34 | *.tsbuildinfo
35 | next-env.d.ts
36 |
37 | node_modules
38 | .env
39 | coverage
40 | coverage.json
41 | typechain
42 | typechain-types
43 |
44 | # Hardhat files
45 | cache
46 | artifacts
47 |
48 |
--------------------------------------------------------------------------------
/test/SwapToken.js:
--------------------------------------------------------------------------------
1 | const { expect } = require("chai");
2 | const hre = require("hardhat");
3 | const provider=hre.provider;
4 |
5 | describe("SwapToken", async function () {
6 |
7 |
8 |
9 | const [owner, otherAccount1,otherAccount2] = await ethers.getSigners();
10 |
11 | const swap = await ethers.getContractFactory("SwapToken");
12 | // deploy a TSTTOkeN contract tokens can be minted
13 | const swapresult = await swap.deploy();
14 | it("Should swap TST for SHM", async function () {
15 |
16 |
17 | // assert that the value is correct
18 | const tokenresult=await swapresult.swap(10,0)
19 | expect(await tokenresult.to.equal(10));
20 | });
21 |
22 | });
--------------------------------------------------------------------------------
/scripts/deploySwapToken.js:
--------------------------------------------------------------------------------
1 | const { ethers } = require("hardhat");
2 | const fs = require("fs");
3 |
4 |
5 | async function main() {
6 | const SwapContract = await ethers.getContractFactory("SwapToken");
7 | const swap = await SwapContract.deploy();
8 | await swap.deployed();
9 |
10 | console.log('CONTRACT_ADDRESS=' + swap.address);
11 | const contractInfo = {
12 | address: swap.address,
13 | abi: swap.interface.format("json"),
14 | };
15 | const contractAddress = swap.address;
16 | fs.writeFileSync('swapcontract-info.json', JSON.stringify(contractInfo, null, 2));
17 | fs.writeFileSync('swapcontract-address.txt', contractAddress);
18 | }
19 |
20 | main()
21 | .then(() => process.exit(0))
22 | .catch((error) => {
23 | console.error(error);
24 | process.exit(1);
25 | });
26 |
--------------------------------------------------------------------------------
/scripts/deployTSTERC20.js:
--------------------------------------------------------------------------------
1 | const { ethers } = require("hardhat");
2 | const fs = require("fs");
3 |
4 |
5 | async function main() {
6 | const TSTContract = await ethers.getContractFactory("TSTToken");
7 | const tst20 = await TSTContract.deploy(1000000);
8 | await tst20.deployed();
9 |
10 | console.log('CONTRACT_ADDRESS=' + tst20.address);
11 | const contractInfo = {
12 | address: tst20.address,
13 | abi: tst20.interface.format("json"),
14 | };
15 | const contractAddress = tst20.address;
16 | fs.writeFileSync('contract-info.json', JSON.stringify(contractInfo, null, 2));
17 | fs.writeFileSync('contract-address.txt', contractAddress);
18 | }
19 |
20 | main()
21 | .then(() => process.exit(0))
22 | .catch((error) => {
23 | console.error(error);
24 | process.exit(1);
25 | });
26 |
--------------------------------------------------------------------------------
/test/TSTERC20.js:
--------------------------------------------------------------------------------
1 | const { expect } = require("chai");
2 | const hre = require("hardhat");
3 | const provider=hre.provider;
4 |
5 | describe("TSTTOKEN", async function () {
6 |
7 | const initialAmount = 1000000;
8 |
9 | const [owner, otherAccount1,otherAccount2] = await ethers.getSigners();
10 |
11 | const tst = await ethers.getContractFactory("TSTToken");
12 | // deploy a TSTTOkeN contract tokens can be minted
13 | const tstresult = await tst.deploy(initialAmount );
14 | it("Should mint initial supply 1000000", async function () {
15 |
16 |
17 | // assert that the value is correct
18 | expect(await tstresult.totalSupply()).to.equal(initialAmount);
19 | });
20 | it("should mint 25 TSTOken",async function(){
21 | await tstresult.mint(otherAccount1.address,25);
22 |
23 | // assert that address balance is equal 25
24 | expect(await tstresult.balanceOf(otherAccount1.address).to.equal(25));
25 | })
26 | });
--------------------------------------------------------------------------------
/contracts/NFT.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.3;
3 |
4 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
5 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
6 |
7 | contract NFTMinter is ERC721URIStorage {
8 | uint256 private _tokenIds; // Initialize token ID counter
9 |
10 | // Set the price for minting an NFT
11 | uint256 public mintPrice = 1 ether;
12 |
13 | constructor() ERC721("Shardeum Dev NFTMinter", "SNFT") {}
14 |
15 | function mintNFT(address recipient, string memory tokenURI) external payable returns (uint256) {
16 | // Ensure exactly 1 Ether is sent
17 | require(msg.value == mintPrice, "You must send exactly 1 SHM to mint an NFT");
18 |
19 | _tokenIds++; // Increment the token ID
20 | uint256 newItemId = _tokenIds;
21 |
22 | _mint(recipient, newItemId);
23 | _setTokenURI(newItemId, tokenURI);
24 |
25 | return newItemId;
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/scripts/deploy.js:
--------------------------------------------------------------------------------
1 | // We require the Hardhat Runtime Environment explicitly here. This is optional
2 | // but useful for running the script in a standalone fashion through `node