Skip to content

Commit

Permalink
Add rpc info
Browse files Browse the repository at this point in the history
  • Loading branch information
dqtkien committed Sep 16, 2024
1 parent 99f6eba commit e9d32e6
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 261 deletions.
37 changes: 37 additions & 0 deletions contracts/test/TestERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.19;

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/access/Ownable.sol';

contract TestERC20 is ERC20, Ownable {
// Constructor
constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {}

//====================[ Internal ]====================

// Unpack data to get token amount and wallet address
function _unpack(uint256 value) internal pure returns (uint96, address) {
return (uint96(value >> 160), address(uint160(value)));
}

//====================[ Owner ]====================

// Mint token in packed data
function batchMint(uint256[] calldata packedData) external onlyOwner returns (uint256) {
for (uint i = 0; i < packedData.length; i += 1) {
(uint96 amount, address to) = _unpack(packedData[i]);
_mint(to, amount);
}
return packedData.length;
}

// Burn token in packed data
function batchBurn(uint256[] calldata packedData) external onlyOwner returns (uint256) {
for (uint i = 0; i < packedData.length; i += 1) {
(uint96 amount, address from) = _unpack(packedData[i]);
_burn(from, amount);
}
return packedData.length;
}
}
Loading

0 comments on commit e9d32e6

Please sign in to comment.