Fixing script and adding auto minting to airdrops accounts

This commit is contained in:
David E. Perez Negron R. 2024-04-24 20:05:27 -06:00
parent 065607af5d
commit 3e448767d9
1 changed files with 40 additions and 14 deletions

View File

@ -1,32 +1,58 @@
// SPDX-License-Identifier: UNLICENSED // SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23; pragma solidity ^0.8.23;
import {Script, console2} from "forge-std/Script.sol"; import { Script, console2 } from "forge-std/Script.sol";
import { DCO2s } from "src/DCO2s.sol"; import { DCO2s } from "src/DCO2s.sol";
contract DCO2sScript is Script { contract DCO2sScript is Script {
DCO2s public dco2sc; DCO2s public dco2sc;
address public defaultAdmin;
address public minter;
address[] public airdrops;
string public baseURI; string public baseURI;
string public name;
string public symbol;
string[] public nfts;
function setUp() public { function setUp() public {
baseURI = "https://gateway.decentralizedscience.org/ipfs/"; baseURI = vm.envString("BASE_URI");
dco2sc = new DCO2s(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, defaultAdmin = vm.envAddress("DEFAULT_ADMIN");
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, minter = vm.envAddress("MINTER");
baseURI, name = vm.envString("NAME");
"DCO2s", symbol = vm.envString("SYMBOL");
"DCO2"); // Import nfts array from .env and split by ' '
console2.log("The DCO2s contract address is: ", address(dco2sc)); nfts = vm.envString("nfts", ' ');
airdrops = vm.envAddress("airdrops", '\n');
} }
// run is the entry point // run is the entry point
function run() public { function run() public {
// startBroadcast and stopBraodcast will let us execute transactions anything between them // startBroadcast and stopBraodcast will let us execute transactions anything between them
vm.startBroadcast(); uint256 deployerPrivateKey = vm.envUint("PK0");
vm.startBroadcast(deployerPrivateKey);
// here we just need to deploy a new contract // here we just need to deploy a new contract
string memory URI = "bafkreibc6p3y36yjmeqqnttqfrpb2yttxa6aonoywxwdxl7nqym4jj3jwa"; dco2sc = new DCO2s(defaultAdmin,
dco2sc.safeMint(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, URI); minter,
string memory tokenURI = dco2sc.tokenURI(0); baseURI,
name,
symbol);
console2.log("The DCO2s contract address is: ", address(dco2sc));
// minting all nfts to airdrops accounts
// @notice: uses module for airdrops accounts to distribute the nfts
for(uint i; i < nfts.length; i++) {
dco2sc.safeMint(airdrops[i % airdrops.length], nfts[i]);
string memory tokenURI = dco2sc.tokenURI(i);
console2.log("Token0 URI is:", tokenURI); console2.log("Token0 URI is:", tokenURI);
}
// minting NFT0 to the contract admin
//string memory URI = nfts[0];
//dco2sc.safeMint(defaultAdmin, URI);
//string memory tokenURI = dco2sc.tokenURI(0);
//console2.log("Token0 URI is:", tokenURI);
vm.stopBroadcast(); vm.stopBroadcast();
} }
} }