-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4db4695
commit 97be9a8
Showing
11 changed files
with
532 additions
and
1,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"address":"e643cf465ede9ad11e152bab8d3cdc6cbc3712e1","id":"7b1c4539-2590-487b-a185-a80cd9ec6803","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"1604473865ba5ae684d58ce0dc53400e"},"ciphertext":"4c98240a7df683c3e5eba5194fcc91decaaa46318420dcb431cb47fb5f705054","kdf":"scrypt","kdfparams":{"salt":"c4925ac4115a60e3e7181a1ec7777aaedb404ffe8af9089372bc430436cfa111","n":131072,"dklen":32,"p":1,"r":8},"mac":"4ba3f626b20ec10e973ade9c3375b11243ec82d46ed5acee50d9aaed634fd4f7"},"x-ethers":{"client":"ethers.js","gethFilename":"UTC--2023-02-08T05-02-54.0Z--e643cf465ede9ad11e152bab8d3cdc6cbc3712e1","mnemonicCounter":"62f51230c6b456199c87b3c6183648e6","mnemonicCiphertext":"eb67bf6a3fb736177f455acf202a6a74","path":"m/44'/60'/0'/0/0","locale":"en","version":"0.1"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract LinkPay { | ||
struct Payment { | ||
address sender; | ||
address receiver; | ||
uint256 amount; | ||
uint256 timestamp; | ||
string tokenName; | ||
} | ||
|
||
struct tokenDetails { | ||
address tokenAddress; | ||
string tokenName; | ||
} | ||
|
||
struct User { | ||
address userAddress; | ||
string image; | ||
string name; | ||
string bio; | ||
string twitter; | ||
uint256 totalReceived; | ||
uint256 totalSent; | ||
} | ||
|
||
mapping(string => User) public users; | ||
mapping(address => string) public addressToUsername; | ||
mapping(address => Payment[]) public paymentsByAddress; | ||
mapping(string => tokenDetails[]) public acceptableTokens; | ||
|
||
Payment[] public payments; | ||
|
||
function generateLink( | ||
string memory _username, | ||
string memory _image, | ||
string memory _name, | ||
string memory _bio, | ||
string memory _twitter, | ||
tokenDetails[] memory _tokens | ||
) public { | ||
require(bytes(_username).length > 0, "Username cannot be empty"); | ||
require(bytes(_name).length > 0, "Name cannot be empty"); | ||
require(bytes(_bio).length > 0, "Bio cannot be empty"); | ||
require(bytes(_twitter).length > 0, "Twitter cannot be empty"); | ||
require( | ||
bytes(addressToUsername[msg.sender]).length == 0, | ||
"Address already exists" | ||
); | ||
|
||
users[_username] = User( | ||
msg.sender, | ||
_image, | ||
_name, | ||
_bio, | ||
_twitter, | ||
0, | ||
0 | ||
); | ||
|
||
for (uint256 i = 0; i < _tokens.length; i++) { | ||
acceptableTokens[_username].push(_tokens[i]); | ||
} | ||
|
||
addressToUsername[msg.sender] = _username; | ||
} | ||
|
||
function getDetailsByName(string memory _username) | ||
public | ||
view | ||
returns (User memory) | ||
{ | ||
return users[_username]; | ||
} | ||
|
||
function getDetailsByAddress(address _address) | ||
public | ||
view | ||
returns (User memory) | ||
{ | ||
return users[addressToUsername[_address]]; | ||
} | ||
|
||
function payToUser( | ||
string memory _username, | ||
uint256 _amount, | ||
address tokenAddress, | ||
string memory _tokenName | ||
) public { | ||
require(_amount > 0, "Amount cannot be 0"); | ||
User storage user = users[_username]; | ||
require(user.userAddress != address(0), "User does not exist"); | ||
require(user.userAddress != msg.sender, "Cannot send to yourself"); | ||
|
||
Payment memory payment = Payment( | ||
msg.sender, | ||
user.userAddress, | ||
_amount, | ||
block.timestamp, | ||
_tokenName | ||
); | ||
user.totalReceived += _amount; | ||
users[addressToUsername[msg.sender]].totalSent += _amount; | ||
paymentsByAddress[msg.sender].push(payment); | ||
payments.push(payment); | ||
|
||
ERC20 token = ERC20(tokenAddress); | ||
token.transferFrom( | ||
msg.sender, | ||
user.userAddress, | ||
_amount * (10**token.decimals()) | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.9; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract MyToken is ERC20 { | ||
constructor() ERC20("MyToken", "DIN") { | ||
_mint(msg.sender, 1000 * 10**decimals()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
97be9a8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
linkpay – ./
linkpay.vercel.app
linkpay-dinesh11515.vercel.app
linkpay-git-main-dinesh11515.vercel.app