Skip to content

Commit bd992b4

Browse files
committed
feat: added XSGD ERC20 token
1 parent 93daa57 commit bd992b4

3 files changed

Lines changed: 158 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
1. Registry.sol: [0x2b4836d81370e37030727e4dcbd9cc5a772cf43a](https://sepolia.basescan.org/address/0x2b4836d81370e37030727e4dcbd9cc5a772cf43a)
99
2. Exchange.sol: [0xd9004Edc4bdEB308C4A40fdCbE320bbE5DF4AF77](https://sepolia.basescan.org/address/0xd9004edc4bdeb308c4a40fdcbe320bbe5df4af77)
1010
3. Vault.sol: [0xd580248163CDD5AE3225A700E9f4e7CD525b27b0](https://sepolia.basescan.org/address/0xd580248163cdd5ae3225a700e9f4e7cd525b27b0)
11+
4. XSGD.sol [0xd7260d7063fE5A62A90E6A8DD5A39Ab27A05986B](https://sepolia.basescan.org/token/0xd7260d7063fe5a62a90e6a8dd5a39ab27a05986b)
1112

1213
## Deployment
1314

@@ -29,6 +30,12 @@ forge script script/deploy/Exchange.s.sol:DeployExchange --rpc-url <PRC_URL> --b
2930
forge script script/deploy/Vault.s.sol:DeployVault --rpc-url <PRC_URL> --broadcast --private-key <PRIVATE_KEY>
3031
```
3132

33+
4. XSGD.sol
34+
35+
```
36+
forge script script/deploy/XSGD.s.sol:DeployXSGD --rpc-url <PRC_URL> --broadcast
37+
```
38+
3239
## Tests
3340

3441
```

script/deploy/XSGD.s.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import {Script} from "forge-std/Script.sol";
5+
import {XSGD} from "../../src/XSGD.sol";
6+
import {console} from "forge-std/console.sol";
7+
8+
contract DeployXSGD is Script {
9+
function run() public {
10+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
11+
vm.startBroadcast(deployerPrivateKey);
12+
13+
string memory name = "StraitsX Singapore Dollar";
14+
string memory symbol = "XSGD";
15+
uint256 initialSupply = 1000000 * 10**18; // 1 million tokens
16+
17+
XSGD xsgd = new XSGD(name, symbol, initialSupply);
18+
19+
console.log("XSGD deployed at:", address(xsgd));
20+
21+
vm.stopBroadcast();
22+
}
23+
}

src/XSGD.sol

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5+
import "@openzeppelin/contracts/access/Ownable.sol";
6+
import "@openzeppelin/contracts/utils/Pausable.sol";
7+
8+
/**
9+
* @title XSGD Token
10+
* @author @dannweeeee
11+
* @dev Implementation of the XSGD Token
12+
*/
13+
contract XSGD is ERC20, Ownable, Pausable {
14+
// Mapping to track if an address is blacklisted
15+
mapping(address => bool) private _blacklisted;
16+
17+
// Events
18+
event TokensMinted(address indexed to, uint256 amount);
19+
event TokensBurned(address indexed from, uint256 amount);
20+
event AddressBlacklisted(address indexed account);
21+
event AddressUnblacklisted(address indexed account);
22+
23+
constructor(string memory name, string memory symbol, uint256 initialSupply)
24+
ERC20(name, symbol)
25+
Ownable(msg.sender)
26+
{
27+
_mint(msg.sender, initialSupply);
28+
}
29+
30+
/**
31+
* @dev Pause token transfers
32+
*/
33+
function pause() public onlyOwner {
34+
_pause();
35+
}
36+
37+
/**
38+
* @dev Unpause token transfers
39+
*/
40+
function unpause() public onlyOwner {
41+
_unpause();
42+
}
43+
44+
/**
45+
* @dev Mint new tokens
46+
* @param to Address to receive the minted tokens
47+
* @param amount Amount of tokens to mint
48+
*/
49+
function mint(address to, uint256 amount) public onlyOwner {
50+
require(to != address(0), "Cannot mint to zero address");
51+
require(!_blacklisted[to], "Recipient is blacklisted");
52+
_mint(to, amount);
53+
emit TokensMinted(to, amount);
54+
}
55+
56+
/**
57+
* @dev Burn tokens from the caller's balance
58+
* @param amount Amount of tokens to burn
59+
*/
60+
function burn(uint256 amount) public {
61+
require(!_blacklisted[msg.sender], "Sender is blacklisted");
62+
_burn(msg.sender, amount);
63+
emit TokensBurned(msg.sender, amount);
64+
}
65+
66+
/**
67+
* @dev Burn tokens from a specific address
68+
* @param account Address to burn tokens from
69+
* @param amount Amount of tokens to burn
70+
*/
71+
function burnFrom(address account, uint256 amount) public onlyOwner {
72+
require(!_blacklisted[account], "Account is blacklisted");
73+
_burn(account, amount);
74+
emit TokensBurned(account, amount);
75+
}
76+
77+
/**
78+
* @dev Blacklist an address
79+
* @param account Address to blacklist
80+
*/
81+
function blacklist(address account) public onlyOwner {
82+
require(account != address(0), "Cannot blacklist zero address");
83+
_blacklisted[account] = true;
84+
emit AddressBlacklisted(account);
85+
}
86+
87+
/**
88+
* @dev Remove an address from blacklist
89+
* @param account Address to unblacklist
90+
*/
91+
function unblacklist(address account) public onlyOwner {
92+
_blacklisted[account] = false;
93+
emit AddressUnblacklisted(account);
94+
}
95+
96+
/**
97+
* @dev Check if an address is blacklisted
98+
* @param account Address to check
99+
* @return bool True if the address is blacklisted
100+
*/
101+
function isBlacklisted(address account) public view returns (bool) {
102+
return _blacklisted[account];
103+
}
104+
105+
/**
106+
* @dev Override transfer function to include blacklist check
107+
*/
108+
function transfer(address to, uint256 amount) public virtual override whenNotPaused returns (bool) {
109+
require(!_blacklisted[msg.sender], "Sender is blacklisted");
110+
require(!_blacklisted[to], "Recipient is blacklisted");
111+
return super.transfer(to, amount);
112+
}
113+
114+
/**
115+
* @dev Override transferFrom function to include blacklist check
116+
*/
117+
function transferFrom(address from, address to, uint256 amount)
118+
public
119+
virtual
120+
override
121+
whenNotPaused
122+
returns (bool)
123+
{
124+
require(!_blacklisted[from], "Sender is blacklisted");
125+
require(!_blacklisted[to], "Recipient is blacklisted");
126+
return super.transferFrom(from, to, amount);
127+
}
128+
}

0 commit comments

Comments
 (0)