Address Contract Verified
Address
0x9eb8788BEA8BEeb00427b3cBFA826048C0B4b343
Balance
0 ETH
Nonce
381
Code Size
2721 bytes
Creator
0x0Ecb4B76...9a42 at tx 0xc4673b5a...c6a112
Indexed Transactions
0
Contract Bytecode
2721 bytes
0x608060405234801561000f575f80fd5b506004361061007a575f3560e01c806382cb6b721161005857806382cb6b72146100e5578063920caa9714610117578063da7323b31461012a578063ffb390761461013d575f80fd5b80630a34a7391461007e5780633d722c59146100a75780635e9bc536146100ba575b5f80fd5b61009161008c366004610749565b610150565b60405161009e9190610764565b60405180910390f35b6100916100b5366004610749565b610280565b6100cd6100c83660046107a7565b6102fa565b6040516001600160a01b03909116815260200161009e565b6101076100f33660046107f5565b5f6020819052908152604090205460ff1681565b604051901515815260200161009e565b610091610125366004610749565b610328565b6100cd61013836600461080c565b61035d565b6100cd61014b3660046107f5565b6104b2565b60605f61015c83610328565b90505f61016884610280565b90505f8151835161017991906108cc565b67ffffffffffffffff811115610191576101916108df565b6040519080825280602002602001820160405280156101ba578160200160208202803683370190505b5090505f805b8451811015610215578481815181106101db576101db6108f3565b60200260200101518383815181106101f5576101f56108f3565b60209081029190910101528161020a81610907565b9250506001016101c0565b505f5b835181101561026d57838181518110610233576102336108f3565b602002602001015183838151811061024d5761024d6108f3565b60209081029190910101528161026281610907565b925050600101610218565b5061027782610521565b50949350505050565b600254604051634b152ed960e01b81526001600160a01b0383811660048301526060925f92911690634b152ed9906024015b5f60405180830381865afa1580156102cc573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526102f3919081019061091f565b9392505050565b5f806103098787878787610609565b8051602090910120905061031d8382610672565b979650505050505050565b60015460405162438b6360e81b81526001600160a01b0383811660048301526060925f9291169063438b6300906024016102b2565b5f8061036c8989898989610609565b90505f610382865f1b8380519060200120610672565b90506001600160a01b0381163b1561039d57915061031d9050565b604080516001600160a01b0383811682528c811660208301528183018c90528a1660608201526080810189905260a0810188905290517f07fba7bba1191da7ee1155dcfa0030701c9c9a9cc34a93b991fc6fd0c9268d8f9181900360c00190a15f878152602081905260408120805460ff19166001179055610420908784610687565b905083156104a5575f816001600160a01b031686866040516104439291906109d8565b5f604051808303815f865af19150503d805f811461047c576040519150601f19603f3d011682016040523d82523d5f602084013e610481565b606091505b50509050806104a357604051630337323560e31b815260040160405180910390fd5b505b9998505050505050505050565b6001546040516331a9108f60e11b8152600481018390525f9182916001600160a01b0390911690636352211e90602401602060405180830381865afa1580156104fd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102f391906109e7565b5f5b8151811015610605575f6105388260016108cc565b90505b82518110156105fc57828181518110610556576105566108f3565b6020026020010151838381518110610570576105706108f3565b602002602001015111156105f4575f838381518110610591576105916108f3565b602002602001015190508382815181106105ad576105ad6108f3565b60200260200101518484815181106105c7576105c76108f3565b602002602001018181525050808483815181106105e6576105e66108f3565b602002602001018181525050505b60010161053b565b50600101610523565b5050565b60408051602081018390529081018590526001600160a01b0384166060828101919091526080820184905290869060a00160408051601f19818403018152908290526106589291602001610a02565b604051602081830303815290604052905095945050505050565b5f61067e838330610709565b90505b92915050565b5f834710156106b65760405163392efb2b60e21b81524760048201526024810185905260440160405180910390fd5b81515f036106d757604051631328927760e21b815260040160405180910390fd5b8282516020840186f590506001600160a01b0381166102f357604051633a0ba96160e11b815260040160405180910390fd5b5f604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b6001600160a01b0381168114610746575f80fd5b50565b5f60208284031215610759575f80fd5b81356102f381610732565b602080825282518282018190525f9190848201906040850190845b8181101561079b5783518352928401929184019160010161077f565b50909695505050505050565b5f805f805f60a086880312156107bb575f80fd5b85356107c681610732565b94506020860135935060408601356107dd81610732565b94979396509394606081013594506080013592915050565b5f60208284031215610805575f80fd5b5035919050565b5f805f805f805f60c0888a031215610822575f80fd5b873561082d81610732565b965060208801359550604088013561084481610732565b9450606088013593506080880135925060a088013567ffffffffffffffff8082111561086e575f80fd5b818a0191508a601f830112610881575f80fd5b81358181111561088f575f80fd5b8b60208285010111156108a0575f80fd5b60208301945080935050505092959891949750929550565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610681576106816108b8565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f60018201610918576109186108b8565b5060010190565b5f6020808385031215610930575f80fd5b825167ffffffffffffffff80821115610947575f80fd5b818501915085601f83011261095a575f80fd5b81518181111561096c5761096c6108df565b8060051b604051601f19603f83011681018181108582111715610991576109916108df565b6040529182528482019250838101850191888311156109ae575f80fd5b938501935b828510156109cc578451845293850193928501926109b3565b98975050505050505050565b818382375f9101908152919050565b5f602082840312156109f7575f80fd5b81516102f381610732565b733d60ad80600a3d3981f3363d3d373d3d3d363d7360601b8152606083901b6bffffffffffffffffffffffff191660148201526e5af43d82803e903d91602b57fd5bf360881b602882015281515f908060208501603785015e5f9201603701918252509291505056fea264697066735822122000c2580405b840785a0a9dd21f9459d83ea4643d8e526b49682d1752291eab9f64736f6c63430008190033
Verified Source Code Full Match
Compiler: v0.8.25+commit.b61c2a91
EVM: cancun
Optimization: Yes (200 runs)
IERC6551Registry.sol 31 lines
// SPDX-License-Identifier: MIT
// https://github.com/erc6551/reference
pragma solidity ^0.8.0;
interface IERC6551Registry {
event AccountCreated(
address account,
address implementation,
uint256 chainId,
address tokenContract,
uint256 tokenId,
uint256 salt
);
function createAccount(
address implementation,
uint256 chainId,
address tokenContract,
uint256 tokenId,
uint256 seed,
bytes calldata initData
) external returns (address);
function account(
address implementation,
uint256 chainId,
address tokenContract,
uint256 tokenId,
uint256 salt
) external view returns (address);
}
ERC6551BytecodeLib.sol 21 lines
// SPDX-License-Identifier: MIT
// https://github.com/erc6551/reference
pragma solidity ^0.8.0;
library ERC6551BytecodeLib {
function getCreationCode(
address implementation_,
uint256 chainId_,
address tokenContract_,
uint256 tokenId_,
uint256 salt_
) internal pure returns (bytes memory) {
return
abi.encodePacked(
hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73",
implementation_,
hex"5af43d82803e903d91602b57fd5bf3",
abi.encode(salt_, chainId_, tokenContract_, tokenId_)
);
}
}
ERC6551RegistryNTP.sol 157 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Create2.sol";
import "./IERC6551Registry.sol";
import "./ERC6551BytecodeLib.sol";
interface ContractNTP {
function ownerOf(uint256 _tokenId) external view returns (address);
function walletOfOwner(address _address)
external
view
returns (uint256[] memory);
}
interface ContractStake {
function getUserStakedTokensNTP(address _address)
external
view
returns (uint256[] memory);
}
contract ERC6551RegistryNTP is IERC6551Registry {
error InitializationFailed();
// addition
mapping(uint256 => bool) public created;
address private ContractAddressNTP =
0xA65bA71d653f62c64d97099b58D25a955Eb374a0;
address private ContractAddressStake =
0x493ed2537Be3a2AA380d63f943220616f27b6a78;
// ownedNTP
function sortAscending(uint256[] memory arr) internal pure {
for (uint256 i = 0; i < arr.length; i++) {
for (uint256 j = i + 1; j < arr.length; j++) {
if (arr[i] > arr[j]) {
uint256 temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
}
function getHoldNTP(address _address)
public
view
returns (uint256[] memory)
{
uint256[] memory holdToken = getWalletOfOwnerNTP(_address);
uint256[] memory stakeToken = getWalletOfStakeToken(_address);
uint256[] memory result = new uint256[](
holdToken.length + stakeToken.length
);
uint256 index = 0;
for (uint256 i = 0; i < holdToken.length; i++) {
result[index] = holdToken[i];
index++;
}
for (uint256 j = 0; j < stakeToken.length; j++) {
result[index] = stakeToken[j];
index++;
}
sortAscending(result);
return result;
}
// NTP Contract
function getOwnerOfNTP(uint256 _tokenId) public view returns (address) {
address holder = ContractNTP(ContractAddressNTP).ownerOf(_tokenId);
return holder;
}
function getWalletOfOwnerNTP(address _address)
public
view
returns (uint256[] memory)
{
uint256[] memory walletOfOwner = ContractNTP(ContractAddressNTP)
.walletOfOwner(_address);
return walletOfOwner;
}
// Stake Contract
function getWalletOfStakeToken(address _address)
public
view
returns (uint256[] memory)
{
uint256[] memory walletOfStake = ContractStake(ContractAddressStake)
.getUserStakedTokensNTP(_address);
return walletOfStake;
}
function createAccount(
address implementation,
uint256 chainId,
address tokenContract,
uint256 tokenId,
uint256 salt,
bytes calldata initData
) external returns (address) {
bytes memory code = ERC6551BytecodeLib.getCreationCode(
implementation,
chainId,
tokenContract,
tokenId,
salt
);
address _account = Create2.computeAddress(bytes32(salt), keccak256(code));
if (_account.code.length != 0) return _account;
emit AccountCreated(_account, implementation, chainId, tokenContract, tokenId, salt);
// addition
created[tokenId] = true;
_account = Create2.deploy(0, bytes32(salt), code);
if (initData.length != 0) {
(bool success, ) = _account.call(initData);
if (!success) revert InitializationFailed();
}
return _account;
}
function account(
address implementation,
uint256 chainId,
address tokenContract,
uint256 tokenId,
uint256 salt
) external view returns (address) {
bytes32 bytecodeHash = keccak256(
ERC6551BytecodeLib.getCreationCode(
implementation,
chainId,
tokenContract,
tokenId,
salt
)
);
return Create2.computeAddress(bytes32(salt), bytecodeHash);
}
}
// Code by lettuce908
Create2.sol 96 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Create2.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
* `CREATE2` can be used to compute in advance the address where a smart
* contract will be deployed, which allows for interesting new mechanisms known
* as 'counterfactual interactions'.
*
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
* information.
*/
library Create2 {
/**
* @dev Not enough balance for performing a CREATE2 deploy.
*/
error Create2InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev There's no code to deploy.
*/
error Create2EmptyBytecode();
/**
* @dev The deployment failed.
*/
error Create2FailedDeployment();
/**
* @dev Deploys a contract using `CREATE2`. The address where the contract
* will be deployed can be known in advance via {computeAddress}.
*
* The bytecode for a contract can be obtained from Solidity with
* `type(contractName).creationCode`.
*
* Requirements:
*
* - `bytecode` must not be empty.
* - `salt` must have not been used for `bytecode` already.
* - the factory must have a balance of at least `amount`.
* - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
*/
function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
if (address(this).balance < amount) {
revert Create2InsufficientBalance(address(this).balance, amount);
}
if (bytecode.length == 0) {
revert Create2EmptyBytecode();
}
/// @solidity memory-safe-assembly
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
}
if (addr == address(0)) {
revert Create2FailedDeployment();
}
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
* `bytecodeHash` or `salt` will result in a new destination address.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40) // Get free memory pointer
// | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |
// |-------------------|---------------------------------------------------------------------------|
// | bytecodeHash | CCCCCCCCCCCCC...CC |
// | salt | BBBBBBBBBBBBB...BB |
// | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |
// | 0xFF | FF |
// |-------------------|---------------------------------------------------------------------------|
// | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
// | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |
mstore(add(ptr, 0x40), bytecodeHash)
mstore(add(ptr, 0x20), salt)
mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
mstore8(start, 0xff)
addr := keccak256(start, 85)
}
}
}
Read Contract
account 0x5e9bc536 → address
created 0x82cb6b72 → bool
getHoldNTP 0x0a34a739 → uint256[]
getOwnerOfNTP 0xffb39076 → address
getWalletOfOwnerNTP 0x920caa97 → uint256[]
getWalletOfStakeToken 0x3d722c59 → uint256[]
Write Contract 1 functions
These functions modify contract state and require a wallet transaction to execute.
createAccount 0xda7323b3
address implementation
uint256 chainId
address tokenContract
uint256 tokenId
uint256 salt
bytes initData
returns: address
Recent Transactions
No transactions found for this address