Address Contract Verified
Address
0xA218A4dfE038C9D357b49f58c69a53aC60D87DC0
Balance
0 ETH
Nonce
1
Code Size
4681 bytes
Creator
0x9723A2d2...53Ef at tx 0x7d01ecab...f4fd21
Indexed Transactions
0
Contract Bytecode
4681 bytes
0x608060405234801561000f575f80fd5b50600436106100cd575f3560e01c8063715018a61161008a578063ae87fc4b11610064578063ae87fc4b146101d3578063dab5f340146101f1578063ebf0c7171461020d578063f2fde38b1461022b576100cd565b8063715018a61461018f5780637a6126c5146101995780638da5cb5b146101b5576100cd565b806301fb6857146100d1578063144fa6d7146101015780632f52ebb71461011d5780634e01bd1014610139578063654f97a3146101555780636d282e7414610171575b5f80fd5b6100eb60048036038101906100e69190610b6b565b610247565b6040516100f89190610bb0565b60405180910390f35b61011b60048036038101906101169190610c23565b610264565b005b61013760048036038101906101329190610ce2565b6102af565b005b610153600480360381019061014e9190610d3f565b61052b565b005b61016f600480360381019061016a9190610d94565b61060c565b005b61017961066a565b6040516101869190610e1a565b60405180910390f35b61019761068f565b005b6101b360048036038101906101ae9190610e33565b6106a2565b005b6101bd61081a565b6040516101ca9190610e92565b60405180910390f35b6101db610841565b6040516101e89190610bb0565b60405180910390f35b61020b60048036038101906102069190610b6b565b610854565b005b610215610866565b6040516102229190610eba565b60405180910390f35b61024560048036038101906102409190610c23565b61086c565b005b6004602052805f5260405f205f915054906101000a900460ff1681565b61026c6108f0565b8060025f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6102b7610977565b5f33846040516020016102cb929190610f38565b604051602081830303815290604052805190602001209050600260149054906101000a900460ff16610332576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032990610fbd565b60405180910390fd5b60045f8281526020019081526020015f205f9054906101000a900460ff1615610390576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038790611025565b60405180910390fd5b6103dd8383808060200260200160405190810160405280939291908181526020018383602002808284375f81840152601f19601f82011690508083019250505050505050600354836109bd565b61041c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104139061108d565b60405180910390fd5b600160045f8381526020019081526020015f205f6101000a81548160ff02191690831515021790555060025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33866040518363ffffffff1660e01b81526004016104a19291906110ba565b6020604051808303815f875af11580156104bd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104e191906110f5565b507f30c2341ba3f2142e78472f07dcf018a42044ae1c2c2e7ce867b327257f07ef2b33854260405161051593929190611120565b60405180910390a1506105266109d3565b505050565b6105336108f0565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b815260040161058f9291906110ba565b6020604051808303815f875af11580156105ab573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105cf91906110f5565b507fde05183e6f4aa0d9ec0415e21aa5a650a2aae9db74a7b50937e2e51db7dca2cb8142604051610601929190611155565b60405180910390a150565b6106146108f0565b80600260146101000a81548160ff0219169083151502179055507f5a7af21a57ec6186ef7d0db7e94238e55426919accb47681e388c626440ec780814260405161065f92919061117c565b60405180910390a150565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106976108f0565b6106a05f6109dc565b565b6106aa6108f0565b5f82826040516020016106be929190610f38565b604051602081830303815290604052805190602001209050600160045f8381526020019081526020015f205f6101000a81548160ff02191690831515021790555060025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85846040518363ffffffff1660e01b815260040161075b9291906110ba565b6020604051808303815f875af1158015610777573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061079b91906110f5565b507fbdfa9b3b8857151a0b5d468d60d9fdf2a86e31827dce2bb239c7c152aa270c41848484426040516107d194939291906111a3565b60405180910390a17f30c2341ba3f2142e78472f07dcf018a42044ae1c2c2e7ce867b327257f07ef2b84834260405161080c93929190611120565b60405180910390a150505050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600260149054906101000a900460ff1681565b61085c6108f0565b8060038190555050565b60035481565b6108746108f0565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036108e4575f6040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016108db9190610e92565b60405180910390fd5b6108ed816109dc565b50565b6108f8610a9d565b73ffffffffffffffffffffffffffffffffffffffff1661091661081a565b73ffffffffffffffffffffffffffffffffffffffff161461097557610939610a9d565b6040517f118cdaa700000000000000000000000000000000000000000000000000000000815260040161096c9190610e92565b60405180910390fd5b565b6002600154036109b3576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600181905550565b5f826109c98584610aa4565b1490509392505050565b60018081905550565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f33905090565b5f808290505f5b8451811015610ae757610ad882868381518110610acb57610aca6111e6565b5b6020026020010151610af2565b91508080600101915050610aab565b508091505092915050565b5f818310610b0957610b048284610b1c565b610b14565b610b138383610b1c565b5b905092915050565b5f825f528160205260405f20905092915050565b5f80fd5b5f80fd5b5f819050919050565b610b4a81610b38565b8114610b54575f80fd5b50565b5f81359050610b6581610b41565b92915050565b5f60208284031215610b8057610b7f610b30565b5b5f610b8d84828501610b57565b91505092915050565b5f8115159050919050565b610baa81610b96565b82525050565b5f602082019050610bc35f830184610ba1565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610bf282610bc9565b9050919050565b610c0281610be8565b8114610c0c575f80fd5b50565b5f81359050610c1d81610bf9565b92915050565b5f60208284031215610c3857610c37610b30565b5b5f610c4584828501610c0f565b91505092915050565b5f819050919050565b610c6081610c4e565b8114610c6a575f80fd5b50565b5f81359050610c7b81610c57565b92915050565b5f80fd5b5f80fd5b5f80fd5b5f8083601f840112610ca257610ca1610c81565b5b8235905067ffffffffffffffff811115610cbf57610cbe610c85565b5b602083019150836020820283011115610cdb57610cda610c89565b5b9250929050565b5f805f60408486031215610cf957610cf8610b30565b5b5f610d0686828701610c6d565b935050602084013567ffffffffffffffff811115610d2757610d26610b34565b5b610d3386828701610c8d565b92509250509250925092565b5f60208284031215610d5457610d53610b30565b5b5f610d6184828501610c6d565b91505092915050565b610d7381610b96565b8114610d7d575f80fd5b50565b5f81359050610d8e81610d6a565b92915050565b5f60208284031215610da957610da8610b30565b5b5f610db684828501610d80565b91505092915050565b5f819050919050565b5f610de2610ddd610dd884610bc9565b610dbf565b610bc9565b9050919050565b5f610df382610dc8565b9050919050565b5f610e0482610de9565b9050919050565b610e1481610dfa565b82525050565b5f602082019050610e2d5f830184610e0b565b92915050565b5f805f60608486031215610e4a57610e49610b30565b5b5f610e5786828701610c0f565b9350506020610e6886828701610c0f565b9250506040610e7986828701610c6d565b9150509250925092565b610e8c81610be8565b82525050565b5f602082019050610ea55f830184610e83565b92915050565b610eb481610b38565b82525050565b5f602082019050610ecd5f830184610eab565b92915050565b5f8160601b9050919050565b5f610ee982610ed3565b9050919050565b5f610efa82610edf565b9050919050565b610f12610f0d82610be8565b610ef0565b82525050565b5f819050919050565b610f32610f2d82610c4e565b610f18565b82525050565b5f610f438285610f01565b601482019150610f538284610f21565b6020820191508190509392505050565b5f82825260208201905092915050565b7f436c61696d2069732070617573656400000000000000000000000000000000005f82015250565b5f610fa7600f83610f63565b9150610fb282610f73565b602082019050919050565b5f6020820190508181035f830152610fd481610f9b565b9050919050565b7f416c726561647920636c61696d656400000000000000000000000000000000005f82015250565b5f61100f600f83610f63565b915061101a82610fdb565b602082019050919050565b5f6020820190508181035f83015261103c81611003565b9050919050565b7f496e76616c69642070726f6f66000000000000000000000000000000000000005f82015250565b5f611077600d83610f63565b915061108282611043565b602082019050919050565b5f6020820190508181035f8301526110a48161106b565b9050919050565b6110b481610c4e565b82525050565b5f6040820190506110cd5f830185610e83565b6110da60208301846110ab565b9392505050565b5f815190506110ef81610d6a565b92915050565b5f6020828403121561110a57611109610b30565b5b5f611117848285016110e1565b91505092915050565b5f6060820190506111335f830186610e83565b61114060208301856110ab565b61114d60408301846110ab565b949350505050565b5f6040820190506111685f8301856110ab565b61117560208301846110ab565b9392505050565b5f60408201905061118f5f830185610ba1565b61119c60208301846110ab565b9392505050565b5f6080820190506111b65f830187610e83565b6111c36020830186610e83565b6111d060408301856110ab565b6111dd60608301846110ab565b95945050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffdfea2646970667358221220bc638b001272dfa9e8edacdb518d4c744798f0e35c6c43ee22ead1d8bbb8760264736f6c63430008180033
Verified Source Code Full Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: shanghai
Optimization: No
PngvnAllocationClaim.sol 84 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract PngvnClaim is Ownable, ReentrancyGuard {
IERC20 public pngvnToken;
bool public claimStatus;
bytes32 public root;
mapping(bytes32 => bool) public leafClaimed;
event ClaimStatusUpdated(bool newStatus, uint256 timestamp);
event TokenClaim(address holder, uint256 amount, uint256 timestamp);
event AdminHolderClaimIssued(
address newHolderAdd,
address oldHolderAdd,
uint256 amount,
uint256 timestamp
);
event EmegencyTokensWithdrawn(uint256 amount, uint256 timestamp);
constructor(
address initialOwner,
address _pngvnToken
) Ownable(initialOwner) {
pngvnToken = IERC20(_pngvnToken);
}
function claim(
uint256 claimAmount,
bytes32[] calldata proof
) external nonReentrant {
bytes32 leaf = keccak256(abi.encodePacked(msg.sender, claimAmount));
require(claimStatus, "Claim is paused");
require(!leafClaimed[leaf], "Already claimed");
require(MerkleProof.verify(proof, root, leaf), "Invalid proof");
leafClaimed[leaf] = true;
pngvnToken.transfer(msg.sender, claimAmount);
emit TokenClaim(msg.sender, claimAmount, block.timestamp);
}
function setRoot(bytes32 _root) external onlyOwner {
root = _root;
}
function setToken(address _token) external onlyOwner {
pngvnToken = IERC20(_token);
}
function setClaimStatus(bool _newClaimStatus) external onlyOwner {
claimStatus = _newClaimStatus;
emit ClaimStatusUpdated(_newClaimStatus, block.timestamp);
}
function issueAdminHolderClaim(
address holderNewAddress,
address holderOldAddress,
uint256 amount
) external onlyOwner {
bytes32 leaf = keccak256(abi.encodePacked(holderOldAddress, amount));
leafClaimed[leaf] = true;
pngvnToken.transfer(holderNewAddress, amount);
emit AdminHolderClaimIssued(holderNewAddress,holderOldAddress, amount, block.timestamp);
emit TokenClaim(holderNewAddress, amount, block.timestamp);
}
function emergencyTokenWithdrawal(uint256 amount) external onlyOwner {
pngvnToken.transfer(msg.sender, amount);
emit EmegencyTokensWithdrawn(amount, block.timestamp);
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
MerkleProof.sol 232 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.20;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Sorts the pair (a, b) and hashes the result.
*/
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
Read Contract
claimStatus 0xae87fc4b → bool
leafClaimed 0x01fb6857 → bool
owner 0x8da5cb5b → address
pngvnToken 0x6d282e74 → address
root 0xebf0c717 → bytes32
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
claim 0x2f52ebb7
uint256 claimAmount
bytes32[] proof
emergencyTokenWithdrawal 0x4e01bd10
uint256 amount
issueAdminHolderClaim 0x7a6126c5
address holderNewAddress
address holderOldAddress
uint256 amount
renounceOwnership 0x715018a6
No parameters
setClaimStatus 0x654f97a3
bool _newClaimStatus
setRoot 0xdab5f340
bytes32 _root
setToken 0x144fa6d7
address _token
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address