增加用于base链的token购买合约
This commit is contained in:
parent
fb0eb52f25
commit
fd91d3f2e4
72
config/config_base_sepolia.js
Normal file
72
config/config_base_sepolia.js
Normal file
@ -0,0 +1,72 @@
|
||||
const market = {
|
||||
feeToAddress: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
mallFeeAddress: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
paymentTokens: [
|
||||
"0x819677A74F316DD77Fe5f9759E44771Df89ccdf6", // USDC
|
||||
],
|
||||
tokenToBuy: "0x11E8cdbFf2B55c2c74b233baeb2223c5FA042009",
|
||||
paywallet: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
verifier: "0x50A8e60041A206AcaA5F844a1104896224be6F39"
|
||||
};
|
||||
|
||||
const admins = {
|
||||
admin: "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
proposers: [
|
||||
"0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
"0x746338765a8FbDD1c5aB61bfb92CD6D960C3C662",
|
||||
],
|
||||
confirmers: ["0x50A8e60041A206AcaA5F844a1104896224be6F39"],
|
||||
executors: [
|
||||
"0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
"0x746338765a8FbDD1c5aB61bfb92CD6D960C3C662",
|
||||
"0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
|
||||
],
|
||||
};
|
||||
|
||||
const token = {
|
||||
baseTokenURIHero: "https://nft-test.kingsome.cn/hero/meta/13473/",
|
||||
contractURIHero: 'https://nft-test.kingsome.cn/hero/home_meta/13473',
|
||||
royaltyReceiver: '0x5Ab03Aa79Ab91B7420b5CFF134a4188388888888',
|
||||
baseTokenURIGold: "https://nft-test.kingsome.cn/gold_bullion/meta/13473/",
|
||||
contractURIGold: 'https://nft-test.kingsome.cn/gold_bullion/home_meta/13473',
|
||||
royaltyFee: 5,
|
||||
};
|
||||
|
||||
const imtbl = {
|
||||
operatorAllowlist: '0x6b969FD89dE634d8DE3271EbE97734FEFfcd58eE',
|
||||
}
|
||||
const mint = {
|
||||
// 2期mint支付的代币
|
||||
mintCurrency: '0xFd42bfb03212dA7e1A4608a44d7658641D99CF34',
|
||||
// 2期mint, 单个nft价格
|
||||
mintPrice: '75000000000000000',
|
||||
// 2期mint接收代币的钱包地址
|
||||
mintFeeAddress: '0x50A8e60041A206AcaA5F844a1104896224be6F39',
|
||||
// 2期mint nftid 开始
|
||||
mintStartNftId: '6240603010010301',
|
||||
// 2期mint 最大可mint数量
|
||||
maxSupply: 2000,
|
||||
// 2期mint airdrop数量
|
||||
airdropCount: 500,
|
||||
}
|
||||
|
||||
const staking = {
|
||||
cec: '0xfa1223747bae6d519580c53Cbb9C11a45b13c6b7',
|
||||
// stake cec时, 每质押一个cec, 每年可获得的收益
|
||||
// rewardPerSecond: BigInt(1.5 * 10 ** 18) / BigInt(365 * 24 * 60 * 60),
|
||||
rewardPerSecond: BigInt(1.5 * 10 ** 18) / BigInt(24 * 60 * 60),
|
||||
// esCEC 转化为cec的时间
|
||||
// vestingDuration: BigInt(365 * 24 * 60 * 60)
|
||||
vestingDuration: BigInt(60 * 60)
|
||||
}
|
||||
|
||||
var config = {
|
||||
market,
|
||||
admins,
|
||||
token,
|
||||
imtbl,
|
||||
mint,
|
||||
staking
|
||||
};
|
||||
|
||||
module.exports = config;
|
119
contracts/mall/TokenMall.sol
Normal file
119
contracts/mall/TokenMall.sol
Normal file
@ -0,0 +1,119 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
|
||||
import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
|
||||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
import {HasSignature} from "../core/HasSignature.sol";
|
||||
import {TimeChecker} from "../utils/TimeChecker.sol";
|
||||
|
||||
contract TokenMall is HasSignature, ReentrancyGuard, Pausable, TimeChecker {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
uint256 public immutable _CACHED_CHAIN_ID;
|
||||
address public immutable _CACHED_THIS;
|
||||
address public verifier;
|
||||
|
||||
mapping(address token => address wallet) public erc20Wallets;
|
||||
mapping(address currency => bool status) public currencySupported;
|
||||
mapping(uint256 code => uint256 count) public codeUsed;
|
||||
|
||||
event EventERC20Wallet(address erc20, address wallet);
|
||||
event EventVerifierUpdated(address indexed verifier);
|
||||
event EventCurrencySupportUpdated(address indexed currency, bool status);
|
||||
event EventTokenBuy(address indexed user, address indexed token, address currency,uint256 amount, uint256 currencyAmount, uint256 code, uint256 nonce);
|
||||
|
||||
constructor(address _wallet, address _token, address _verifier, uint256 _duration) TimeChecker(_duration) {
|
||||
_CACHED_CHAIN_ID = block.chainid;
|
||||
_CACHED_THIS = address(this);
|
||||
erc20Wallets[_token] = _wallet;
|
||||
verifier = _verifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev update verifier address
|
||||
*/
|
||||
function updateVerifier(address _verifier) external onlyOwner {
|
||||
require(_verifier != address(0), "TokenClaim: address can not be zero");
|
||||
verifier = _verifier;
|
||||
emit EventVerifierUpdated(_verifier);
|
||||
}
|
||||
|
||||
function updateCurrencySupport(address currency, bool status) external onlyOwner {
|
||||
require(currency != address(0), "currency address can not be zero");
|
||||
currencySupported[currency] = status;
|
||||
emit EventCurrencySupportUpdated(currency, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev update pause state
|
||||
*/
|
||||
function pause() external onlyOwner {
|
||||
_pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev update unpause state
|
||||
*/
|
||||
function unpause() external onlyOwner {
|
||||
_unpause();
|
||||
}
|
||||
|
||||
function withdrawToken(address erc20, address to, uint256 amount) external onlyOwner {
|
||||
IERC20(erc20).safeTransfer(to, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev update ERC20 wallet
|
||||
*/
|
||||
function updateERC20Wallet(address erc20, address wallet) external onlyOwner {
|
||||
require(erc20Wallets[erc20] != wallet, "TokenClaim: ERC20 wallet not changed");
|
||||
erc20Wallets[erc20] = wallet;
|
||||
emit EventERC20Wallet(erc20, wallet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev buy Token with signature
|
||||
* @param token address of token
|
||||
* @param currency address of currency
|
||||
* @param vals amount, currencyAmount, code, maxUseCount, signTime, nonce
|
||||
* @param signature signature of buy
|
||||
*/
|
||||
|
||||
function buy(
|
||||
address token,
|
||||
address currency,
|
||||
uint256[6] calldata vals,
|
||||
bytes calldata signature
|
||||
) external signatureValid(signature) timeValid(vals[4]) nonReentrant whenNotPaused {
|
||||
require(erc20Wallets[token] != address(0), "TokenClaim: token is not supported");
|
||||
require(vals[0] > 0, "TokenClaim: amount is zero");
|
||||
require(currencySupported[currency], "TokenClaim: currency is not supported");
|
||||
require(codeUsed[vals[2]] <= vals[3], "TokenClaim: code is used");
|
||||
|
||||
address user = _msgSender();
|
||||
bytes32 criteriaMessageHash = getMessageHash(user, token, currency, _CACHED_THIS, _CACHED_CHAIN_ID, vals);
|
||||
checkSigner(verifier, criteriaMessageHash, signature);
|
||||
_useSignature(signature);
|
||||
codeUsed[vals[2]] += 1;
|
||||
|
||||
IERC20(currency).safeTransferFrom(user, _CACHED_THIS, vals[1]);
|
||||
IERC20(token).safeTransferFrom(erc20Wallets[token], user, vals[0]);
|
||||
emit EventTokenBuy(user, token, currency, vals[0], vals[1], vals[2], vals[5]);
|
||||
}
|
||||
|
||||
function getMessageHash(
|
||||
address _user,
|
||||
address _token,
|
||||
address _currency,
|
||||
address _contract,
|
||||
uint256 _chainId,
|
||||
uint256[6] calldata _vals
|
||||
) public pure returns (bytes32) {
|
||||
bytes memory encoded = abi.encodePacked(_user, _token, _currency, _contract, _chainId);
|
||||
for (uint256 i = 0; i < _vals.length; i++) {
|
||||
encoded = bytes.concat(encoded, abi.encodePacked(_vals[i]));
|
||||
}
|
||||
return keccak256(encoded);
|
||||
}
|
||||
}
|
71
deploy/11_deploy_tokenmall.ts
Normal file
71
deploy/11_deploy_tokenmall.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { deplayOne, updateArray } from "../scripts/utils"
|
||||
|
||||
|
||||
const deployTokenMall: DeployFunction =
|
||||
async function (hre: HardhatRuntimeEnvironment) {
|
||||
const provider = hre.ethers.provider;
|
||||
const from = await (await provider.getSigner()).getAddress();
|
||||
const config = require(`../config/config_${hre.network.name}`);
|
||||
const { paywallet, tokenToBuy, paymentTokens, verifier } = config.market
|
||||
|
||||
// const name = "Test USDC";
|
||||
// const symbol = "TUSD";
|
||||
// const ret = await hre.deployments.deploy("MintableBaseToken", {
|
||||
// from,
|
||||
// args: [name, symbol],
|
||||
// log: true,
|
||||
// });
|
||||
// console.log("==MintableBaseToken addr=", ret.address);
|
||||
// updateArray({
|
||||
// name: "TestUSDC",
|
||||
// type: "erc20",
|
||||
// json: "assets/contracts/MintableBaseToken.json",
|
||||
// address: ret.address,
|
||||
// network: hre.network.name,
|
||||
// });
|
||||
|
||||
// const name = "Test Token";
|
||||
// const symbol = "TCEC";
|
||||
// const ret = await hre.deployments.deploy("MintableBaseToken", {
|
||||
// from,
|
||||
// args: [name, symbol],
|
||||
// log: true,
|
||||
// });
|
||||
// console.log("==MintableBaseToken addr=", ret.address);
|
||||
// updateArray({
|
||||
// name: "TestToken",
|
||||
// type: "erc20",
|
||||
// json: "assets/contracts/MintableBaseToken.json",
|
||||
// address: ret.address,
|
||||
// network: hre.network.name,
|
||||
// });
|
||||
|
||||
|
||||
const tokenMall = await deplayOne({
|
||||
hre,
|
||||
name: "TokenMall",
|
||||
type: "logic",
|
||||
contractName: "TokenMall",
|
||||
args: [paywallet, tokenToBuy, verifier, 3600],
|
||||
verify: true,
|
||||
});
|
||||
|
||||
const tokenMallContract = await hre.ethers.getContractAt("TokenMall", tokenMall.address);
|
||||
let tx = await tokenMallContract.updateCurrencySupport(paymentTokens[0], true);
|
||||
await tx.wait();
|
||||
console.log("==tokenMall updateCurrencySupport");
|
||||
|
||||
const tokenContract = await hre.ethers.getContractAt("MintableBaseToken", tokenToBuy);
|
||||
tx = await tokenContract.mint(paywallet, '1000000000000000000000000');
|
||||
await tx.wait();
|
||||
console.log("==token minted to tokenMall");
|
||||
tx = await tokenContract.approve(tokenMall.address, '1000000000000000000000000');
|
||||
await tx.wait();
|
||||
console.log("==token approved to tokenMall");
|
||||
};
|
||||
|
||||
deployTokenMall.tags = ["TokenMall"];
|
||||
|
||||
export default deployTokenMall;
|
1
deployments/base_sepolia/.chainId
Normal file
1
deployments/base_sepolia/.chainId
Normal file
@ -0,0 +1 @@
|
||||
84532
|
782
deployments/base_sepolia/TokenMall.json
Normal file
782
deployments/base_sepolia/TokenMall.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
544
deployments/bsc_test/SimpleStake.json
Normal file
544
deployments/bsc_test/SimpleStake.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,337 +0,0 @@
|
||||
{
|
||||
"address": "0xEc2D43E9E7F54E279B08d2d76BDfAE61400651C7",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "_password",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "_password",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "addUser",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "count",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "data",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "slot",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "index",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "elementSize",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getArrayLocation",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "slot",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "key",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getMapLocation",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "isTrue",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "someConst",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "u16",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint16",
|
||||
"name": "",
|
||||
"type": "uint16"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"transactionHash": "0x9d1defa3d5e3228bb2c062420e24b2a288409bf28ec6dd625c4ae576113c9f09",
|
||||
"receipt": {
|
||||
"to": null,
|
||||
"from": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
|
||||
"contractAddress": "0xEc2D43E9E7F54E279B08d2d76BDfAE61400651C7",
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "321301",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x507c7a3a4444697cd5b094c3e7f7aa7bd1f2da5ae235cde3ec6eeef900268497",
|
||||
"transactionHash": "0x9d1defa3d5e3228bb2c062420e24b2a288409bf28ec6dd625c4ae576113c9f09",
|
||||
"logs": [],
|
||||
"blockNumber": 44580826,
|
||||
"cumulativeGasUsed": "321301",
|
||||
"status": 1,
|
||||
"byzantium": true
|
||||
},
|
||||
"args": [
|
||||
"0xd948549711a1f1198851e8eb8b4857a6159c6388bbab253fbc5b0160b0f9cd5d"
|
||||
],
|
||||
"numDeployments": 1,
|
||||
"solcInputHash": "0f8deec237bf5f05ad838036ecf818f6",
|
||||
"metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_password\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_password\",\"type\":\"bytes32\"}],\"name\":\"addUser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"data\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"slot\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"elementSize\",\"type\":\"uint256\"}],\"name\":\"getArrayLocation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"slot\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"key\",\"type\":\"uint256\"}],\"name\":\"getMapLocation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isTrue\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"someConst\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"u16\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TestSlot.sol\":\"TestSlot\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[],\"viaIR\":true},\"sources\":{\"contracts/test/TestSlot.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2.0\\npragma solidity 0.8.19;\\ncontract TestSlot {\\n uint public count = 123;\\n address public owner = msg.sender;\\n bool public isTrue = true;\\n uint16 public u16 = 31;\\n bytes32 private password;\\n uint public constant someConst = 123;\\n bytes32[3] public data;\\n struct User {\\n uint id;\\n bytes32 password;\\n }\\n User[] private users;\\n mapping(uint => User) private idToUser;\\n constructor(bytes32 _password) {\\n password = _password;\\n }\\n function addUser(bytes32 _password) public {\\n User memory user = User({id: users.length, password: _password});\\n users.push(user);\\n idToUser[user.id] = user;\\n }\\n function getArrayLocation(uint slot, uint index, uint elementSize) public pure returns (uint) {\\n return uint(keccak256(abi.encodePacked(slot))) + (index * elementSize);\\n }\\n function getMapLocation(uint slot, uint key) public pure returns (uint) {\\n return uint(keccak256(abi.encodePacked(key, slot)));\\n }\\n}\\n\",\"keccak256\":\"0x7125359c59989b80246568b655b9577da8dae4704882855a6874010ba9829073\",\"license\":\"Apache 2.0\"}},\"version\":1}",
|
||||
"bytecode": "0x60803461008357601f61043738819003918201601f19168301916001600160401b03831184841017610088578084926020946040528339810103126100835751607b600055600180546001600160a81b0319163360ff60a01b191617600160a01b1761ffff60a81b1916601f60a81b179055600255604051610398908161009f8239f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604081815260048036101561001557600080fd5b600092833560e01c90816274530a1461033e5750806306661abd146103215780630a6b4e06146102fb57806359d168b6146102df578063881374d71461027d5780638da5cb5b146102545780638faf850d14610157578063992ddc6f146100b35763f0ba84401461008557600080fd5b346100af5760203660031901126100af573560038110156100af5760209250600301549051908152f35b8280fd5b50913461015457606036600319011261015457602435906044358351602081019086358252602081528581019581871067ffffffffffffffff881117610141578690525190209281810291818304149015171561012e57820180921161011b57602083838152f35b634e487b7160e01b815260118452602490fd5b634e487b7160e01b825260118552602482fd5b634e487b7160e01b855260418852602485fd5b80fd5b50919034610250576020366003190112610250576006549080519181830183811067ffffffffffffffff82111761023d578252808352843560208401526801000000000000000081101561022a57600181018060065581101561021757906101f88361021494936006875260011b7ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01906020600191805184550151910155565b8151845260076020528320906020600191805184550151910155565b80f35b634e487b7160e01b845260328552602484fd5b634e487b7160e01b845260418552602484fd5b634e487b7160e01b855260418652602485fd5b5080fd5b50503461025057816003193601126102505760015490516001600160a01b039091168152602090f35b50919034610250578060031936011261025057805160208101916024358352843581830152808252606082019382851067ffffffffffffffff8611176102cc5750602094508390525190208152f35b634e487b7160e01b815260418652602490fd5b50503461025057816003193601126102505760209051607b8152f35b50503461025057816003193601126102505760209061ffff60015460a81c169051908152f35b505034610250578160031936011261025057602091549051908152f35b84903461025057816003193601126102505760209060ff60015460a01c1615158152f3fea2646970667358221220e73d55bd9adeeb30fe2d7ef10777b0cb3d9c6b85ee29dd94bbcfd58ad70abd4864736f6c63430008130033",
|
||||
"deployedBytecode": "0x6080604081815260048036101561001557600080fd5b600092833560e01c90816274530a1461033e5750806306661abd146103215780630a6b4e06146102fb57806359d168b6146102df578063881374d71461027d5780638da5cb5b146102545780638faf850d14610157578063992ddc6f146100b35763f0ba84401461008557600080fd5b346100af5760203660031901126100af573560038110156100af5760209250600301549051908152f35b8280fd5b50913461015457606036600319011261015457602435906044358351602081019086358252602081528581019581871067ffffffffffffffff881117610141578690525190209281810291818304149015171561012e57820180921161011b57602083838152f35b634e487b7160e01b815260118452602490fd5b634e487b7160e01b825260118552602482fd5b634e487b7160e01b855260418852602485fd5b80fd5b50919034610250576020366003190112610250576006549080519181830183811067ffffffffffffffff82111761023d578252808352843560208401526801000000000000000081101561022a57600181018060065581101561021757906101f88361021494936006875260011b7ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01906020600191805184550151910155565b8151845260076020528320906020600191805184550151910155565b80f35b634e487b7160e01b845260328552602484fd5b634e487b7160e01b845260418552602484fd5b634e487b7160e01b855260418652602485fd5b5080fd5b50503461025057816003193601126102505760015490516001600160a01b039091168152602090f35b50919034610250578060031936011261025057805160208101916024358352843581830152808252606082019382851067ffffffffffffffff8611176102cc5750602094508390525190208152f35b634e487b7160e01b815260418652602490fd5b50503461025057816003193601126102505760209051607b8152f35b50503461025057816003193601126102505760209061ffff60015460a81c169051908152f35b505034610250578160031936011261025057602091549051908152f35b84903461025057816003193601126102505760209060ff60015460a01c1615158152f3fea2646970667358221220e73d55bd9adeeb30fe2d7ef10777b0cb3d9c6b85ee29dd94bbcfd58ad70abd4864736f6c63430008130033",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
"methods": {},
|
||||
"version": 1
|
||||
},
|
||||
"userdoc": {
|
||||
"kind": "user",
|
||||
"methods": {},
|
||||
"version": 1
|
||||
},
|
||||
"storageLayout": {
|
||||
"storage": [
|
||||
{
|
||||
"astId": 4,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "count",
|
||||
"offset": 0,
|
||||
"slot": "0",
|
||||
"type": "t_uint256"
|
||||
},
|
||||
{
|
||||
"astId": 8,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "owner",
|
||||
"offset": 0,
|
||||
"slot": "1",
|
||||
"type": "t_address"
|
||||
},
|
||||
{
|
||||
"astId": 11,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "isTrue",
|
||||
"offset": 20,
|
||||
"slot": "1",
|
||||
"type": "t_bool"
|
||||
},
|
||||
{
|
||||
"astId": 14,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "u16",
|
||||
"offset": 21,
|
||||
"slot": "1",
|
||||
"type": "t_uint16"
|
||||
},
|
||||
{
|
||||
"astId": 16,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "password",
|
||||
"offset": 0,
|
||||
"slot": "2",
|
||||
"type": "t_bytes32"
|
||||
},
|
||||
{
|
||||
"astId": 23,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "data",
|
||||
"offset": 0,
|
||||
"slot": "3",
|
||||
"type": "t_array(t_bytes32)3_storage"
|
||||
},
|
||||
{
|
||||
"astId": 32,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "users",
|
||||
"offset": 0,
|
||||
"slot": "6",
|
||||
"type": "t_array(t_struct(User)28_storage)dyn_storage"
|
||||
},
|
||||
{
|
||||
"astId": 37,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "idToUser",
|
||||
"offset": 0,
|
||||
"slot": "7",
|
||||
"type": "t_mapping(t_uint256,t_struct(User)28_storage)"
|
||||
}
|
||||
],
|
||||
"types": {
|
||||
"t_address": {
|
||||
"encoding": "inplace",
|
||||
"label": "address",
|
||||
"numberOfBytes": "20"
|
||||
},
|
||||
"t_array(t_bytes32)3_storage": {
|
||||
"base": "t_bytes32",
|
||||
"encoding": "inplace",
|
||||
"label": "bytes32[3]",
|
||||
"numberOfBytes": "96"
|
||||
},
|
||||
"t_array(t_struct(User)28_storage)dyn_storage": {
|
||||
"base": "t_struct(User)28_storage",
|
||||
"encoding": "dynamic_array",
|
||||
"label": "struct TestSlot.User[]",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_bool": {
|
||||
"encoding": "inplace",
|
||||
"label": "bool",
|
||||
"numberOfBytes": "1"
|
||||
},
|
||||
"t_bytes32": {
|
||||
"encoding": "inplace",
|
||||
"label": "bytes32",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_uint256,t_struct(User)28_storage)": {
|
||||
"encoding": "mapping",
|
||||
"key": "t_uint256",
|
||||
"label": "mapping(uint256 => struct TestSlot.User)",
|
||||
"numberOfBytes": "32",
|
||||
"value": "t_struct(User)28_storage"
|
||||
},
|
||||
"t_struct(User)28_storage": {
|
||||
"encoding": "inplace",
|
||||
"label": "struct TestSlot.User",
|
||||
"members": [
|
||||
{
|
||||
"astId": 25,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "id",
|
||||
"offset": 0,
|
||||
"slot": "0",
|
||||
"type": "t_uint256"
|
||||
},
|
||||
{
|
||||
"astId": 27,
|
||||
"contract": "contracts/test/TestSlot.sol:TestSlot",
|
||||
"label": "password",
|
||||
"offset": 0,
|
||||
"slot": "1",
|
||||
"type": "t_bytes32"
|
||||
}
|
||||
],
|
||||
"numberOfBytes": "64"
|
||||
},
|
||||
"t_uint16": {
|
||||
"encoding": "inplace",
|
||||
"label": "uint16",
|
||||
"numberOfBytes": "2"
|
||||
},
|
||||
"t_uint256": {
|
||||
"encoding": "inplace",
|
||||
"label": "uint256",
|
||||
"numberOfBytes": "32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"contracts/test/TestSlot.sol": {
|
||||
"content": "// SPDX-License-Identifier: Apache 2.0\npragma solidity 0.8.19;\ncontract TestSlot {\n uint public count = 123;\n address public owner = msg.sender;\n bool public isTrue = true;\n uint16 public u16 = 31;\n bytes32 private password;\n uint public constant someConst = 123;\n bytes32[3] public data;\n struct User {\n uint id;\n bytes32 password;\n }\n User[] private users;\n mapping(uint => User) private idToUser;\n constructor(bytes32 _password) {\n password = _password;\n }\n function addUser(bytes32 _password) public {\n User memory user = User({id: users.length, password: _password});\n users.push(user);\n idToUser[user.id] = user;\n }\n function getArrayLocation(uint slot, uint index, uint elementSize) public pure returns (uint) {\n return uint(keccak256(abi.encodePacked(slot))) + (index * elementSize);\n }\n function getMapLocation(uint slot, uint key) public pure returns (uint) {\n return uint(keccak256(abi.encodePacked(key, slot)));\n }\n}\n"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"viaIR": true,
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi",
|
||||
"evm.bytecode",
|
||||
"evm.deployedBytecode",
|
||||
"evm.methodIdentifiers",
|
||||
"metadata",
|
||||
"devdoc",
|
||||
"userdoc",
|
||||
"storageLayout",
|
||||
"evm.gasEstimates"
|
||||
],
|
||||
"": [
|
||||
"ast"
|
||||
]
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"useLiteralContent": true
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -65,6 +65,10 @@ const config: HardhatUserConfig = {
|
||||
url: process.env.ARBITRUM_TEST_URL || "",
|
||||
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
|
||||
},
|
||||
base_sepolia: {
|
||||
url: process.env.BASE_SEPOLIA_URL || "",
|
||||
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
|
||||
},
|
||||
},
|
||||
sourcify: {
|
||||
enabled: false,
|
||||
@ -73,6 +77,7 @@ const config: HardhatUserConfig = {
|
||||
apiKey: {
|
||||
bsc_test: process.env.BSC_TEST_API_KEY || "",
|
||||
imtbl_test: process.env.IMTBL_TEST_API_KEY || "",
|
||||
baseSepolia: process.env.BASE_SEPOLIA_API_KEY || "",
|
||||
},
|
||||
customChains: [
|
||||
{
|
||||
|
20
out/base_sepolia_dev.json
Normal file
20
out/base_sepolia_dev.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"name": "TestUSDC",
|
||||
"type": "erc20",
|
||||
"json": "assets/contracts/MintableBaseToken.json",
|
||||
"address": "0x819677A74F316DD77Fe5f9759E44771Df89ccdf6"
|
||||
},
|
||||
{
|
||||
"name": "TestToken",
|
||||
"type": "erc20",
|
||||
"json": "assets/contracts/MintableBaseToken.json",
|
||||
"address": "0x11E8cdbFf2B55c2c74b233baeb2223c5FA042009"
|
||||
},
|
||||
{
|
||||
"name": "TokenMall",
|
||||
"type": "logic",
|
||||
"json": "assets/contracts/TokenMall.json",
|
||||
"address": "0x877d90e87Fd3810CE5469c1fFC3228107ca80C74"
|
||||
}
|
||||
]
|
@ -70,5 +70,11 @@
|
||||
"type": "logic",
|
||||
"json": "assets/contracts/RewardRouter.json",
|
||||
"address": "0x3455e5D4962de708050278FA2761A613028bdf08"
|
||||
},
|
||||
{
|
||||
"name": "simpleStake",
|
||||
"type": "logic",
|
||||
"json": "assets/contracts/SimpleStake.json",
|
||||
"address": "0xD7A603Da0A0c3f59d74956175bB545D356B9d24c"
|
||||
}
|
||||
]
|
@ -23,6 +23,8 @@
|
||||
"deploy:staking:escec": "hardhat deploy --tags StakingEsCEC --network bsc_test --reset",
|
||||
"deploy:staking": "npm run deploy:staking:token && npm run deploy:staking:cec && npm run deploy:staking:escec",
|
||||
"deploy:cec:distributor": "hardhat deploy --tags CECDistributor --network bsc_test --reset",
|
||||
"deploy:tokenmall:test": "hardhat deploy --tags TokenMall --network base_sepolia --reset",
|
||||
"deploy:simplestake:test": "hardhat deploy --tags SimpleStake --network bsc_test --reset",
|
||||
"solhint": "solhint --config ./.solhint.json",
|
||||
"show_verify_list": "npx hardhat verify --list-networks",
|
||||
"convert-abi": "npx hardhat run scripts/convert-abi.js",
|
||||
|
22
simple_abi/SimpleStake.json
Normal file
22
simple_abi/SimpleStake.json
Normal file
@ -0,0 +1,22 @@
|
||||
[
|
||||
"constructor(address,uint256,uint256,uint256)",
|
||||
"event MaxStakeAmountUpdated(uint256)",
|
||||
"event OwnershipTransferred(address indexed,address indexed)",
|
||||
"event PeriodUpdated(uint256,uint256)",
|
||||
"event StakeCreated(address indexed,uint256,uint256)",
|
||||
"event Unlocked(address indexed,uint256,uint256)",
|
||||
"function endTime() view returns (uint256)",
|
||||
"function maxStakeAmount() view returns (uint256)",
|
||||
"function owner() view returns (address)",
|
||||
"function renounceOwnership()",
|
||||
"function setMaxStakeAmount(uint256)",
|
||||
"function setTime(uint256,uint256)",
|
||||
"function stake(uint256)",
|
||||
"function stakes(address,uint256) view returns (uint256,uint256,bool)",
|
||||
"function stakingToken() view returns (address)",
|
||||
"function startTime() view returns (uint256)",
|
||||
"function totalStaked() view returns (uint256)",
|
||||
"function transferOwnership(address)",
|
||||
"function unstake(uint256)",
|
||||
"function userStakes(address) view returns ((uint256,uint256,bool)[])"
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user