Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SwapToken.sol #23

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# Shardeum Dapp Boilerplate

![Homepage](/homepage.png)

Welcome to the Shardeum Dapp Boilerplate repository! This is a comprehensive starting point for rapid prototyping your ideas on Shardeum.

This boilerplate is great for:

✅ Learning Blockchain fundmentals

✅ Hackathon participants

✅ Experiencing Shardeum
# myDapp

## 🚀 Getting Started

Expand All @@ -29,9 +17,9 @@ Your boilerplate is now ready and running on your local machine!
Alternatively, you can manually set up the boilerplate by cloning the repository and installing the necessary dependencies:

```
git clone https://github.com/Shardeum/shardeum-dapp-boilerplate
git clone https://github.com/etherbiln/myDapp

cd shardeum-dapp-boilerplate
cd myDapp

npm install

Expand Down
8 changes: 7 additions & 1 deletion contracts/SwapToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ contract SwapToken {

return amounts[2];
}

event SwapSHMForTST(address indexed user, uint amountIn, uint amountOut);

function swapSHMForTST(
uint amountOutDesired,
uint amountInMax
) external returns (uint amountOut) {
require(amountOutDesired > 0, "Invalid amountOutDesired");
require(amountInMax > 0, "Invalid amountInMax");

shm.transferFrom(msg.sender, address(this), amountInMax);
shm.approve(address(uniswapRouter), amountInMax);

Expand All @@ -72,7 +78,7 @@ contract SwapToken {
if (amounts[0] < amountInMax) {
shm.transfer(msg.sender, amountInMax - amounts[0]);
}

emit SwapSHMForTST(msg.sender, amounts[0], amounts[2]);
return amounts[2];
}
}
Binary file removed homepage.png
Binary file not shown.
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shardeum-dapp-boilerplate",
"version": "0.1.0",
"name": "myDapp",
"version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down Expand Up @@ -45,6 +45,6 @@
"typescript": "^5.3.3"
},
"bin": {
"shardeum-dapp-boilerplate": "./src/pages/index.js"
"myDapp": "./src/pages/index.js"
}
}
Binary file modified public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const WalletHeader = () => {
return (
<Header style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Link href="/">
<img src="/logo.png" alt="Logo" style={{ height: '256px', marginRight: '10px', marginTop: '30px' }} />
<img src="/logo.png" alt="Logo" style={{ height: '200px', marginRight: '10px', marginTop: '30px' }} />
</Link>
<nav style={{ display: 'flex', gap: '20px' }}>
<Link href="/" style={{ color: router.pathname === '/' ? '#A4FF00' : 'white', cursor: 'pointer' }}>Home</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Home() {
<>
<Row justify="center" align="top" style={{ minHeight: '100vh', backgroundColor: '#001529', color: '#fff' }}>
<Col span={24} style={{ textAlign: 'center', paddingTop: '10vh' }}>
<Title style={{ color: '#fff', fontWeight: 'bold' }}>Welcome to Shardeum Dapp Boilerplate</Title>
<Title style={{ color: '#fff', fontWeight: 'bold' }}>Welcome to myDapp</Title>
<Text style={{ fontSize: '18px', color: '#fff' }}>
Kickstart your decentralized application journey with confidence.
</Text>
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function Home() {
<Link href="/rpc">
<Button type="primary" size="large">Get Started</Button>
</Link>
<Link href="https://github.com/Shardeum/shardeum-dapp-boilerplate">
<Link href="https://github.com/etherbiln">
<Button type="default" size="large">Contribute</Button>
</Link>

Expand Down