add .env, prepare 18_deploy...
This commit is contained in:
parent
e835cd9a13
commit
5c32aae3e7
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,4 +8,5 @@ openzeppelin
|
||||
.key
|
||||
.addr
|
||||
.selfaddr
|
||||
.selfkey
|
||||
.selfkey
|
||||
.env
|
34
abi_code.js
34
abi_code.js
@ -285,12 +285,30 @@ const CODE_ABI = [
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "to",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "tokenId",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "mint",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
const Web3 = require('web3');
|
||||
const w3 = new Web3('https://arbitrum-goerli.publicnode.com');
|
||||
|
||||
// const w3 = new Web3('https://arbitrum-goerli.publicnode.com');
|
||||
const w3 = new Web3('https://okbtestrpc.okbchain.org');
|
||||
module.exports = {
|
||||
getBalance: async ()=>{
|
||||
const erc721addr = '0x9e45716bF916FBa3F460DDdDB0254F60e34C9853'
|
||||
@ -300,5 +318,17 @@ module.exports = {
|
||||
const res = await instance.methods.balanceOf(account).call();
|
||||
console.log('bananceof:', res)
|
||||
return res
|
||||
},
|
||||
|
||||
getPastEvents: async ()=>{
|
||||
const erc20addr = '0x27431808bCDbc12EBFDc8A1e3B6b70e3E44E79Af'
|
||||
const instance = new w3.eth.Contract(CODE_ABI, erc20addr);
|
||||
|
||||
const res = await instance.getPastEvents("allEvents",{
|
||||
fromBlock: 5106256,
|
||||
toBlock: 5107123
|
||||
});
|
||||
console.log('getPastEvents over.')
|
||||
return res
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -15,6 +15,8 @@ contract NFTSbt is AccessControl, ERC721Enumerable {
|
||||
|
||||
Counters.Counter private _tokenIdCounter;
|
||||
|
||||
uint256 public maxBatchSize = 500;
|
||||
|
||||
constructor(
|
||||
string memory _name,
|
||||
string memory _symbol,
|
||||
@ -73,6 +75,28 @@ contract NFTSbt is AccessControl, ERC721Enumerable {
|
||||
return IMetaData(_metaAddress).getMetaData(address(this), tokenId);
|
||||
}
|
||||
|
||||
function batchMint(
|
||||
address to,
|
||||
uint256 count
|
||||
) external onlyRole(MINTER_ROLE) returns (uint256[] memory) {
|
||||
require(count > 0, "tokenIds too small");
|
||||
require(count <= maxBatchSize, "tokenIds too many");
|
||||
if (supplyLimit > 0) {
|
||||
require(
|
||||
(totalSupply() + count) <= supplyLimit,
|
||||
"Exceed the total supply"
|
||||
);
|
||||
}
|
||||
uint256[] memory tokenIds = new uint256[](count);
|
||||
for (uint256 i = 0; i < count; i++) {
|
||||
_tokenIdCounter.increment();
|
||||
uint256 tokenId = _tokenIdCounter.current();
|
||||
_safeMint(to, tokenId);
|
||||
tokenIds[i] = tokenId;
|
||||
}
|
||||
return tokenIds;
|
||||
}
|
||||
|
||||
function mint(address to) external onlyRole(MINTER_ROLE) returns (uint256) {
|
||||
require(to != address(0), "Cannot mint to zero address");
|
||||
if (supplyLimit > 0) {
|
||||
|
29
init_scripts/generate_candy.js
Normal file
29
init_scripts/generate_candy.js
Normal file
@ -0,0 +1,29 @@
|
||||
const Candy = artifacts.require("tokens/erc721/BEBadge");
|
||||
|
||||
const base = require("../scripts/base");
|
||||
|
||||
module.exports = async function main(callback) {
|
||||
try {
|
||||
const account = "0x62871e8e348FDC5bE370E92FF8d17cB04A248242";
|
||||
// const badgeInstance = await Badge.deployed();
|
||||
const network = "arbitrum_one";
|
||||
let cfgs = base.loadData({ network });
|
||||
const candyInstance = await Candy.at(
|
||||
cfgs.find((c) => c.name === "Candy").address
|
||||
);
|
||||
|
||||
if(candyInstance)
|
||||
{
|
||||
console.log('candyInstance:', candyInstance.address)
|
||||
// await badgeInstance.batchMint(account, 1);
|
||||
// await candyInstance.setMintRole(account)
|
||||
console.log(`success add mintrole`);
|
||||
}
|
||||
// await badgeInstance.updateBaseURI("https://gateway.pinata.cloud/ipfs/QmRWDE2y8Zw32tQYtwaCT8JtJJVrGnQoNj4AbKyTPF4Atb");
|
||||
console.log("update mintrole over!")
|
||||
callback(0);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
callback(1);
|
||||
}
|
||||
};
|
92
migrations/18_deploy_explorer.js
Normal file
92
migrations/18_deploy_explorer.js
Normal file
@ -0,0 +1,92 @@
|
||||
const Box = artifacts.require("tokens/erc721/BEBadge");
|
||||
const Metadata = artifacts.require("core/JSONMetadata");
|
||||
const base = require("../scripts/base");
|
||||
const config = require("../config/config");
|
||||
const Distributor = artifacts.require("logic/NftDistributor");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
const name = "Candy";
|
||||
const symbol = "CANDY";
|
||||
// await deployer.deploy(Box, name, symbol, 0);
|
||||
const gachaInstance = await Box.deployed();
|
||||
if (gachaInstance) {
|
||||
console.log("Candy successfully deployed.");
|
||||
}
|
||||
// base.updateArray({
|
||||
// name: "Candy",
|
||||
// type: "erc721",
|
||||
// json: "assets/contracts/BEBadge.json",
|
||||
// address: gachaInstance.address,
|
||||
// network,
|
||||
// });
|
||||
|
||||
let metaaddr = '0xfba1F2861718993B94edd5DCe1D06b3Cbe19353d'
|
||||
|
||||
if(network == 'arbitrum_one'){
|
||||
// await deployer.deploy(Metadata);
|
||||
const metadataInstance = await Metadata.deployed();
|
||||
if (metadataInstance) {
|
||||
console.log("metadataInstance successfully deployed.");
|
||||
}
|
||||
// base.updateArray({
|
||||
// name: "JSONMetadata",
|
||||
// type: "logic",
|
||||
// json: "assets/contracts/JSONMetadata.json",
|
||||
// address: metadataInstance.address,
|
||||
// network,
|
||||
// });
|
||||
|
||||
const mtname = name
|
||||
const mtdesc = "Candy Badge are exclusive to new friends entering the world of CiunterFire,\\n\
|
||||
it will have airdrop attributes and in-game benefits."
|
||||
const mtimg = "https://gateway.pinata.cloud/ipfs/QmWuHBFGirZS7uyGDyEJNBnMjGLsP9Ke4QZaoL2MxYWtat"
|
||||
const mtex = ',"animation_url": "https://gateway.pinata.cloud/ipfs/QmRJAN58RaFZUeor9VhdiqCziujwvwD98zq7xHUnmbzMXW"'
|
||||
|
||||
await metadataInstance.setMetaData(
|
||||
gachaInstance.address,
|
||||
mtname,
|
||||
mtdesc,
|
||||
mtimg,
|
||||
mtex
|
||||
);
|
||||
console.log(`success update metadata for: ${gachaInstance.address}`);
|
||||
|
||||
metaaddr = metadataInstance.address
|
||||
}
|
||||
|
||||
console.log('meta addr:', metaaddr)
|
||||
|
||||
await gachaInstance.updateMetaAddress(metaaddr);
|
||||
console.log(`success update meta address for: ${gachaInstance.address}`);
|
||||
|
||||
const testexec = ['0x1cC73CE74BA0BC080e7C0a37cb3a68f435Ab333A']
|
||||
|
||||
let exec = network == 'arbitrum_one'? config.admins.executors: testexec
|
||||
|
||||
console.log('exec addrs:', exec)
|
||||
|
||||
await deployer.deploy(
|
||||
Distributor,
|
||||
gachaInstance.address,
|
||||
exec
|
||||
);
|
||||
const distributorInstance = await Distributor.deployed();
|
||||
if (distributorInstance) {
|
||||
console.log("NftDistributor successfully deployed.");
|
||||
console.log("address: " + distributorInstance.address);
|
||||
}
|
||||
base.updateArray({
|
||||
name: "NftDistributor",
|
||||
type: "logic",
|
||||
json: "assets/contracts/NftDistributor.json",
|
||||
address: distributorInstance.address,
|
||||
network,
|
||||
});
|
||||
await gachaInstance.setMintRole(distributorInstance.address);
|
||||
|
||||
console.log(
|
||||
`success set mint role to: ${distributorInstance.address} claim box `
|
||||
);
|
||||
|
||||
|
||||
};
|
24
package-lock.json
generated
24
package-lock.json
generated
@ -10,7 +10,9 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "4.9.2",
|
||||
"fs-jetpack": "^5.1.0"
|
||||
"dotenv": "^16.3.1",
|
||||
"fs-jetpack": "^5.1.0",
|
||||
"process": "^0.11.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openzeppelin/test-helpers": "^0.5.15",
|
||||
@ -5010,6 +5012,17 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.3.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
||||
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/double-ended-queue": {
|
||||
"version": "2.1.0-0",
|
||||
"resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz",
|
||||
@ -10580,7 +10593,6 @@
|
||||
"version": "0.11.10",
|
||||
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
|
||||
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
}
|
||||
@ -17271,6 +17283,11 @@
|
||||
"is-obj": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "16.3.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
||||
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ=="
|
||||
},
|
||||
"double-ended-queue": {
|
||||
"version": "2.1.0-0",
|
||||
"resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz",
|
||||
@ -21905,8 +21922,7 @@
|
||||
"process": {
|
||||
"version": "0.11.10",
|
||||
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
|
||||
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
|
||||
"dev": true
|
||||
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
|
@ -28,6 +28,7 @@
|
||||
"candy_deploy:one": "truffle migrate --network arbitrum_one -f 17 --to 17 --compile-none",
|
||||
"stake_deploy:one": "truffle migrate --network arbitrum_one -f 9 --to 9 --compile-none",
|
||||
"update:stake": "npx truffle exec --network arbitrum_one ./init_scripts/update_stake.js",
|
||||
"update:candy": "npx truffle exec --network arbitrum_one ./init_scripts/generate_candy.js",
|
||||
"size": "truffle run contract-size"
|
||||
},
|
||||
"author": "",
|
||||
@ -44,6 +45,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "4.9.2",
|
||||
"fs-jetpack": "^5.1.0"
|
||||
"dotenv": "^16.3.1",
|
||||
"fs-jetpack": "^5.1.0",
|
||||
"process": "^0.11.10"
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,16 @@
|
||||
const jetpack = require("fs-jetpack");
|
||||
const dotenv = require("dotenv")
|
||||
const path = require("path");
|
||||
|
||||
console.log('[dirname]', __dirname)
|
||||
let dir = path.join(__dirname, "../") + '.env'
|
||||
|
||||
dotenv.config({path: dir});
|
||||
|
||||
module.exports = {
|
||||
updateArray: function ({ name, type, json, address, network }) {
|
||||
let env = process.env.NODE_ENV || "dev";
|
||||
let env = process.env.BEPUB || "dev";
|
||||
console.log('[env]', env)
|
||||
const filename = `./out_${network}_${env}.json`;
|
||||
let cfgs = jetpack.read(filename, "json");
|
||||
cfgs = cfgs || [];
|
||||
@ -23,8 +31,9 @@ module.exports = {
|
||||
},
|
||||
|
||||
loadData: function ({ network }) {
|
||||
let env = process.env.NODE_ENV || "dev";
|
||||
let env = process.env.BEPUB || "dev";
|
||||
console.log('[env]', process.env.BEPUB)
|
||||
const filename = `./out_${network}_${env}.json`;
|
||||
return jetpack.read(filename, "json");
|
||||
},
|
||||
}
|
||||
};
|
||||
|
11
signmsg.js
11
signmsg.js
@ -33,11 +33,14 @@ async function main(){
|
||||
|
||||
// console.log(hash)
|
||||
|
||||
let res = await abimodule.getBalance()
|
||||
console.log(res)
|
||||
if (res > 0){
|
||||
// let res = await abimodule.getBalance()
|
||||
// console.log(res)
|
||||
// if (res > 0){
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
let res = await abimodule.getPastEvents()
|
||||
console.log(res)
|
||||
}
|
||||
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user