yeesh
0beaf9c0
12 file(s) · +178 −127
| 1 | 1 | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 2 | + | pragma solidity ^0.8.0; |
|
| 3 | 3 | ||
| 4 | 4 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; |
|
| 5 | 5 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; |
|
| 16 | 16 | Ownable |
|
| 17 | 17 | { |
|
| 18 | 18 | uint256 private _nextTokenId; |
|
| 19 | + | uint256 public latestTokenId; |
|
| 19 | 20 | enum Location { |
|
| 20 | 21 | Home, |
|
| 21 | 22 | Bar, |
|
| 22 | 23 | SupplyDepot |
|
| 23 | 24 | } |
|
| 24 | 25 | mapping(uint256 => Location) public tokenLocation; |
|
| 26 | + | mapping(uint256 => uint8) public tokenHealth; // Mapping to store health of each token |
|
| 25 | 27 | ||
| 26 | 28 | // Events |
|
| 27 | 29 | event VisitArea(uint256 indexed tokenId, string location); |
|
| 28 | 30 | event GetCurrentLocation(uint256 indexed tokenId, string location); |
|
| 31 | + | event SetHealth(uint256 indexed tokenId, uint8 health); // Event emitted when health is set |
|
| 29 | 32 | ||
| 30 | 33 | constructor( |
|
| 31 | 34 | address initialOwner |
|
| 32 | 35 | ) ERC721("Cosmic Cowboys", "CCNPC") Ownable(initialOwner) {} |
|
| 33 | 36 | ||
| 37 | + | //function to set health |
|
| 38 | + | function setHealth(uint256 tokenId, uint8 health) public onlyOwner { |
|
| 39 | + | require(health >= 0 && health <= 10, "Health out of range"); // Check health is within valid range |
|
| 40 | + | tokenHealth[tokenId] = health; |
|
| 41 | + | emit SetHealth(tokenId, health); // Emit event |
|
| 42 | + | } |
|
| 43 | + | ||
| 34 | 44 | function safeMint(address to, string memory uri) public onlyOwner { |
|
| 35 | 45 | uint256 tokenId = _nextTokenId++; |
|
| 46 | + | latestTokenId = tokenId; |
|
| 36 | 47 | _safeMint(to, tokenId); |
|
| 37 | 48 | _setTokenURI(tokenId, uri); |
|
| 49 | + | setHealth(tokenId, 10); |
|
| 50 | + | tokenLocation[tokenId] = Location.Home; |
|
| 51 | + | } |
|
| 52 | + | ||
| 53 | + | // Function to get health of a token |
|
| 54 | + | function getHealth(uint256 tokenId) external view returns (uint8) { |
|
| 55 | + | return tokenHealth[tokenId]; |
|
| 38 | 56 | } |
|
| 39 | 57 | ||
| 40 | 58 | // Function to visit a location |
|
| 57 | 75 | function locationToString( |
|
| 58 | 76 | Location _location |
|
| 59 | 77 | ) internal pure returns (string memory) { |
|
| 60 | - | if (_location == Location.Home) return "Home"; |
|
| 78 | + | if (_location == Location.SupplyDepot) return "Supply Depot"; |
|
| 61 | 79 | if (_location == Location.Bar) return "Bar"; |
|
| 62 | - | return "Supply Depot"; |
|
| 80 | + | return "Home"; |
|
| 63 | 81 | } |
|
| 64 | 82 | ||
| 65 | 83 | // The following functions are overrides required by Solidity. |
|
| 94 | 112 | returns (bool) |
|
| 95 | 113 | { |
|
| 96 | 114 | return super.supportsInterface(interfaceId); |
|
| 115 | + | } |
|
| 116 | + | ||
| 117 | + | function getOwner() external view returns (address) { |
|
| 118 | + | return owner(); |
|
| 97 | 119 | } |
|
| 98 | 120 | } |
|
| 1 | 1 | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 2 | + | pragma solidity ^0.8.0; |
|
| 3 | 3 | ||
| 4 | 4 | import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; |
|
| 5 | 5 | import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; |
| 1 | 1 | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 2 | + | pragma solidity ^0.8.0; |
|
| 3 | 3 | ||
| 4 | 4 | import "@openzeppelin/contracts/utils/Create2.sol"; |
|
| 5 | 5 |
| 1 | 1 | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 2 | + | pragma solidity ^0.8.0; |
|
| 3 | 3 | ||
| 4 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; |
|
| 5 | 5 | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; |
| 1 | 1 | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 2 | + | pragma solidity ^0.8.0; |
|
| 3 | 3 | ||
| 4 | + | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 4 | 5 | import "./CosmicCowboy.sol"; |
|
| 5 | - | import "./SpaceGrub.sol"; |
|
| 6 | - | import "./RocketFuel.sol"; |
|
| 6 | + | import "./ERC6551Account.sol"; |
|
| 7 | + | import "./ERC6551Registry.sol"; |
|
| 7 | 8 | import "./GoldenCorn.sol"; |
|
| 9 | + | import "./SpaceSlop.sol"; |
|
| 10 | + | import "./JupiterJunk.sol"; |
|
| 11 | + | ||
| 12 | + | contract Operator is Ownable { |
|
| 13 | + | CosmicCowboys public cosmicCowboys; |
|
| 14 | + | GoldenCorn public goldenCorn; |
|
| 15 | + | SpaceSlop public spaceSlop; |
|
| 16 | + | JupiterJunk public jupiterJunk; |
|
| 17 | + | ||
| 18 | + | uint256 public newTokenId; |
|
| 19 | + | ||
| 20 | + | constructor( |
|
| 21 | + | address initialOwner, |
|
| 22 | + | address _cosmicCowboys, |
|
| 23 | + | address _goldenCorn, |
|
| 24 | + | address _spaceSlop, |
|
| 25 | + | address _jupiterJunk |
|
| 26 | + | ) Ownable(initialOwner) { |
|
| 27 | + | cosmicCowboys = CosmicCowboys(_cosmicCowboys); |
|
| 28 | + | goldenCorn = GoldenCorn(_goldenCorn); |
|
| 29 | + | spaceSlop = SpaceSlop(_spaceSlop); |
|
| 30 | + | jupiterJunk = JupiterJunk(_jupiterJunk); |
|
| 31 | + | } |
|
| 32 | + | ||
| 33 | + | function createNPC(address to, string memory uri) public { |
|
| 34 | + | cosmicCowboys.safeMint(to, uri); |
|
| 35 | + | } |
|
| 36 | + | ||
| 37 | + | function getLatestTokenId() external view returns (uint256) { |
|
| 38 | + | return cosmicCowboys.latestTokenId(); |
|
| 39 | + | } |
|
| 40 | + | ||
| 41 | + | function equipNPC( |
|
| 42 | + | address to, |
|
| 43 | + | uint256 currencyAmount, |
|
| 44 | + | uint256 foodAmount, |
|
| 45 | + | uint256 suppliesAmount |
|
| 46 | + | ) public { |
|
| 47 | + | goldenCorn.mint(to, currencyAmount); |
|
| 48 | + | spaceSlop.mint(to, foodAmount); |
|
| 49 | + | jupiterJunk.mint(to, suppliesAmount); |
|
| 50 | + | } |
|
| 51 | + | ||
| 52 | + | function getOwner() external view returns (address) { |
|
| 53 | + | return owner(); |
|
| 54 | + | } |
|
| 55 | + | } |
| 1 | 1 | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 2 | + | pragma solidity ^0.8.0; |
|
| 3 | 3 | ||
| 4 | 4 | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; |
|
| 5 | 5 | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 6 | 6 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; |
|
| 7 | 7 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; |
|
| 8 | 8 | ||
| 9 | - | contract RocketFuel is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 9 | + | contract SpaceSlop is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 10 | 10 | constructor( |
|
| 11 | 11 | address initialOwner |
|
| 12 | - | ) ERC1155("ipfs://CID") Ownable(initialOwner) {} |
|
| 12 | + | ) |
|
| 13 | + | ERC1155("ipfs://QmRPT3zHx71Dd9KtRdYJkY9hsbu9RcCeRdoNWypJMpiybf") |
|
| 14 | + | Ownable(initialOwner) |
|
| 15 | + | {} |
|
| 13 | 16 | ||
| 14 | 17 | function setURI(string memory newuri) public onlyOwner { |
|
| 15 | 18 | _setURI(newuri); |
|
| 16 | 19 | } |
|
| 17 | 20 | ||
| 18 | - | function mint( |
|
| 19 | - | address account, |
|
| 20 | - | uint256 id, |
|
| 21 | - | uint256 amount, |
|
| 22 | - | bytes memory data |
|
| 23 | - | ) public onlyOwner { |
|
| 24 | - | _mint(account, id, amount, data); |
|
| 21 | + | function mint(address account, uint256 amount) public onlyOwner { |
|
| 22 | + | _mint(account, 0, amount, new bytes(0)); |
|
| 25 | 23 | } |
|
| 26 | 24 | ||
| 27 | 25 | function mintBatch( |
|
| 44 | 42 | super._update(from, to, ids, values); |
|
| 45 | 43 | } |
|
| 46 | 44 | } |
|
| 47 | - | ||
| 1 | 1 | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 2 | + | pragma solidity ^0.8.0; |
|
| 3 | 3 | ||
| 4 | 4 | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; |
|
| 5 | 5 | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 6 | 6 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; |
|
| 7 | 7 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; |
|
| 8 | 8 | ||
| 9 | - | contract SpaceGrub is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 9 | + | contract JupiterJunk is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 10 | 10 | constructor( |
|
| 11 | 11 | address initialOwner |
|
| 12 | - | ) ERC1155("ipfs://CID") Ownable(initialOwner) {} |
|
| 12 | + | ) |
|
| 13 | + | ERC1155("ipfs://QmUE1hMRA85uaaoYAotPxXzAfVUy4hsMHyyjPXvayQQWHB") |
|
| 14 | + | Ownable(initialOwner) |
|
| 15 | + | {} |
|
| 13 | 16 | ||
| 14 | 17 | function setURI(string memory newuri) public onlyOwner { |
|
| 15 | 18 | _setURI(newuri); |
|
| 16 | 19 | } |
|
| 17 | 20 | ||
| 18 | - | function mint( |
|
| 19 | - | address account, |
|
| 20 | - | uint256 id, |
|
| 21 | - | uint256 amount, |
|
| 22 | - | bytes memory data |
|
| 23 | - | ) public onlyOwner { |
|
| 24 | - | _mint(account, id, amount, data); |
|
| 21 | + | function mint(address account, uint256 amount) public onlyOwner { |
|
| 22 | + | _mint(account, 0, amount, new bytes(0)); |
|
| 25 | 23 | } |
|
| 26 | 24 | ||
| 27 | 25 | function mintBatch( |
| 1 | - | // SPDX-License-Identifier: MIT |
|
| 2 | - | pragma solidity ^0.8.20; |
|
| 3 | - | ||
| 4 | - | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; |
|
| 5 | - | import "@openzeppelin/contracts/access/Ownable.sol"; |
|
| 6 | - | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; |
|
| 7 | - | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; |
|
| 8 | - | ||
| 9 | - | contract SetllarSixShooter is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply { |
|
| 10 | - | constructor( |
|
| 11 | - | address initialOwner |
|
| 12 | - | ) ERC1155("ipfs://CID") Ownable(initialOwner) {} |
|
| 13 | - | ||
| 14 | - | function setURI(string memory newuri) public onlyOwner { |
|
| 15 | - | _setURI(newuri); |
|
| 16 | - | } |
|
| 17 | - | ||
| 18 | - | function mint( |
|
| 19 | - | address account, |
|
| 20 | - | uint256 id, |
|
| 21 | - | uint256 amount, |
|
| 22 | - | bytes memory data |
|
| 23 | - | ) public onlyOwner { |
|
| 24 | - | _mint(account, id, amount, data); |
|
| 25 | - | } |
|
| 26 | - | ||
| 27 | - | function mintBatch( |
|
| 28 | - | address to, |
|
| 29 | - | uint256[] memory ids, |
|
| 30 | - | uint256[] memory amounts, |
|
| 31 | - | bytes memory data |
|
| 32 | - | ) public onlyOwner { |
|
| 33 | - | _mintBatch(to, ids, amounts, data); |
|
| 34 | - | } |
|
| 35 | - | ||
| 36 | - | // The following functions are overrides required by Solidity. |
|
| 37 | - | ||
| 38 | - | function _update( |
|
| 39 | - | address from, |
|
| 40 | - | address to, |
|
| 41 | - | uint256[] memory ids, |
|
| 42 | - | uint256[] memory values |
|
| 43 | - | ) internal override(ERC1155, ERC1155Supply) { |
|
| 44 | - | super._update(from, to, ids, values); |
|
| 45 | - | } |
|
| 46 | - | } |
| 1 | 1 | require("@nomicfoundation/hardhat-toolbox"); |
|
| 2 | + | require('dotenv').config() |
|
| 2 | 3 | ||
| 3 | 4 | /** @type import('hardhat/config').HardhatUserConfig */ |
|
| 4 | 5 | module.exports = { |
|
| 5 | 6 | solidity: "0.8.20", |
|
| 7 | + | networks: { |
|
| 8 | + | goerli: { |
|
| 9 | + | url: `${process.env.ALCHEMY_URL}`, |
|
| 10 | + | accounts: [process.env.PRIVATE_KEY] |
|
| 11 | + | }, |
|
| 12 | + | scroll: { |
|
| 13 | + | url: "https://sepolia-rpc.scroll.io/", |
|
| 14 | + | accounts: [process.env.PRIVATE_KEY] |
|
| 15 | + | }, |
|
| 16 | + | } |
|
| 17 | + | ||
| 6 | 18 | }; |
| 7 | 7 | "name": "hardhat-project", |
|
| 8 | 8 | "dependencies": { |
|
| 9 | 9 | "@openzeppelin/contracts": "^5.0.0", |
|
| 10 | + | "dotenv": "^16.3.1", |
|
| 10 | 11 | "ethers": "^6.7.1" |
|
| 11 | 12 | }, |
|
| 12 | 13 | "devDependencies": { |
|
| 3099 | 3100 | }, |
|
| 3100 | 3101 | "engines": { |
|
| 3101 | 3102 | "node": ">=8" |
|
| 3103 | + | } |
|
| 3104 | + | }, |
|
| 3105 | + | "node_modules/dotenv": { |
|
| 3106 | + | "version": "16.3.1", |
|
| 3107 | + | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", |
|
| 3108 | + | "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", |
|
| 3109 | + | "engines": { |
|
| 3110 | + | "node": ">=12" |
|
| 3111 | + | }, |
|
| 3112 | + | "funding": { |
|
| 3113 | + | "url": "https://github.com/motdotla/dotenv?sponsor=1" |
|
| 3102 | 3114 | } |
|
| 3103 | 3115 | }, |
|
| 3104 | 3116 | "node_modules/elliptic": { |
|
| 7 | 7 | }, |
|
| 8 | 8 | "dependencies": { |
|
| 9 | 9 | "@openzeppelin/contracts": "^5.0.0", |
|
| 10 | + | "dotenv": "^16.3.1", |
|
| 10 | 11 | "ethers": "^6.7.1" |
|
| 11 | 12 | } |
|
| 12 | 13 | } |
| 1 | 1 | // Import the ethers library |
|
| 2 | 2 | const { ethers } = require("hardhat"); |
|
| 3 | 3 | ||
| 4 | - | async function CosmicCoyboys() { |
|
| 5 | - | let contract; |
|
| 6 | - | let owner; |
|
| 7 | - | let addr1; |
|
| 8 | - | let addr2; |
|
| 9 | - | ||
| 10 | - | // Get the signers from ethers |
|
| 11 | - | [owner, addr1, addr2] = await ethers.getSigners(); |
|
| 12 | - | ||
| 13 | - | // Deploy the contract |
|
| 14 | - | const Contract = await ethers.getContractFactory("CosmicCowboys"); |
|
| 15 | - | contract = await Contract.deploy(owner.address); |
|
| 16 | - | const contractAddress = await contract.getAddress() |
|
| 17 | - | console.log("Contract deployed to address:", contractAddress); |
|
| 18 | - | ||
| 19 | - | // Mint tokens |
|
| 20 | - | await contract.safeMint(addr1.address, "ipfs://QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng"); |
|
| 21 | - | console.log("Minted token 1"); |
|
| 22 | - | await contract.safeMint(addr2.address, "ipfs://QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng"); |
|
| 23 | - | console.log("Minted token 2"); |
|
| 24 | - | ||
| 25 | - | const tokenURI = await contract.tokenURI(1); |
|
| 26 | - | console.log(tokenURI); |
|
| 27 | - | }; |
|
| 4 | + | async function Operator() { |
|
| 28 | 5 | ||
| 29 | - | async function GoldenCorn() { |
|
| 30 | - | let contract; |
|
| 31 | 6 | let owner; |
|
| 32 | 7 | let addr1; |
|
| 33 | 8 | let addr2; |
|
| 9 | + | let deployedAccountTx, deployedAccountReceipt, deployedAccountAddress; |
|
| 34 | 10 | ||
| 35 | 11 | // Get the signers from ethers |
|
| 36 | 12 | [owner, addr1, addr2] = await ethers.getSigners(); |
|
| 37 | 13 | ||
| 38 | - | // Deploy the contract |
|
| 39 | - | const Contract = await ethers.getContractFactory("GoldenCorn"); |
|
| 40 | - | contract = await Contract.deploy(owner.address); |
|
| 41 | - | const contractAddress = await contract.getAddress() |
|
| 42 | - | console.log("Contract deployed to address:", contractAddress); |
|
| 14 | + | // Deploy NPC contract |
|
| 15 | + | const NPCContract = await ethers.getContractFactory("CosmicCowboys"); |
|
| 16 | + | const npcContract = await NPCContract.deploy(owner.address); |
|
| 17 | + | const npcContractAddress = await npcContract.getAddress() |
|
| 18 | + | console.log("NPC Contract deploywed to address:", npcContractAddress); |
|
| 43 | 19 | ||
| 44 | - | // Mint tokens |
|
| 45 | - | await contract.mint(addr1.address, 100); |
|
| 46 | - | console.log("Minted token 1"); |
|
| 20 | + | // Deploy ERC-20 Contract |
|
| 21 | + | const CurrencyContract = await ethers.getContractFactory("GoldenCorn"); |
|
| 22 | + | const currencyContract = await CurrencyContract.deploy(owner.address); |
|
| 23 | + | const currencyContractAddress = await currencyContract.getAddress() |
|
| 24 | + | console.log("NPC Contract deploywed to address:", currencyContractAddress); |
|
| 47 | 25 | ||
| 48 | - | const balance = await contract.balanceOf(addr1.address); |
|
| 49 | - | console.log(balance) |
|
| 26 | + | // Deploy 1155 Contracts |
|
| 27 | + | const FoodContract = await ethers.getContractFactory("SpaceSlop"); |
|
| 28 | + | const foodContract = await FoodContract.deploy(owner.address); |
|
| 29 | + | const foodContractAddress = await foodContract.getAddress() |
|
| 30 | + | console.log("NPC Contract deploywed to address:", foodContractAddress); |
|
| 50 | 31 | ||
| 51 | - | } |
|
| 52 | - | ||
| 53 | - | async function TBA() { |
|
| 54 | - | let contract; |
|
| 55 | - | let owner; |
|
| 56 | - | let addr1; |
|
| 57 | - | let addr2; |
|
| 32 | + | const SupplyContract = await ethers.getContractFactory("JupiterJunk"); |
|
| 33 | + | const supplyContract = await SupplyContract.deploy(owner.address); |
|
| 34 | + | const supplyContractAddress = await supplyContract.getAddress() |
|
| 35 | + | console.log("NPC Contract deploywed to address:", supplyContractAddress); |
|
| 58 | 36 | ||
| 59 | - | // Get the signers from ethers |
|
| 60 | - | [owner, addr1, addr2] = await ethers.getSigners(); |
|
| 61 | - | ||
| 62 | - | // Deploy the contract |
|
| 37 | + | // Deploy ERC6551 |
|
| 63 | 38 | const RegistryContract = await ethers.getContractFactory("ERC6551Registry"); |
|
| 64 | - | const regristryContract = await RegistryContract.deploy(); |
|
| 65 | - | const registryContractAddress = await regristryContract.getAddress() |
|
| 39 | + | const registryContract = await RegistryContract.deploy(); |
|
| 40 | + | const registryContractAddress = await registryContract.getAddress() |
|
| 66 | 41 | console.log("Registry Contract deployed to address:", registryContractAddress); |
|
| 67 | 42 | ||
| 68 | 43 | const AccountContract = await ethers.getContractFactory("ERC6551Account"); |
|
| 70 | 45 | const accountContractAddress = await accountContract.getAddress() |
|
| 71 | 46 | console.log("Account Contract deployed to address:", accountContractAddress); |
|
| 72 | 47 | ||
| 73 | - | } |
|
| 48 | + | // Deploy Operator Contract |
|
| 49 | + | const OperatorContract = await ethers.getContractFactory("Operator"); |
|
| 50 | + | const operatorContract = await OperatorContract.deploy(owner.address, npcContractAddress, currencyContractAddress, foodContractAddress, supplyContractAddress) |
|
| 51 | + | const operatorContractAddress = await operatorContract.getAddress() |
|
| 52 | + | console.log("Operator Contract deployed to address:", operatorContractAddress) |
|
| 74 | 53 | ||
| 75 | - | TBA() |
|
| 54 | + | // Transfer NPC contract to Operator |
|
| 55 | + | await npcContract.transferOwnership(operatorContractAddress); |
|
| 56 | + | await currencyContract.transferOwnership(operatorContractAddress); |
|
| 57 | + | await foodContract.transferOwnership(operatorContractAddress); |
|
| 58 | + | await supplyContract.transferOwnership(operatorContractAddress); |
|
| 59 | + | ||
| 60 | + | // create NPC |
|
| 61 | + | const npcTx = await operatorContract.createNPC(owner.address, "ipfs://") |
|
| 62 | + | const npcTxReceipt = await npcTx.wait() |
|
| 63 | + | ||
| 64 | + | // After the NPC is created |
|
| 65 | + | const latestTokenId = await operatorContract.getLatestTokenId(); |
|
| 66 | + | console.log("Latest Token ID:", latestTokenId.toString()); |
|
| 67 | + | ||
| 68 | + | // create TBA for NPC |
|
| 69 | + | deployedAccountTx = await registryContract.createAccount( |
|
| 70 | + | accountContractAddress, |
|
| 71 | + | 5, |
|
| 72 | + | npcContractAddress, |
|
| 73 | + | latestTokenId.toString(), |
|
| 74 | + | 0, |
|
| 75 | + | "0x" |
|
| 76 | + | ) |
|
| 77 | + | deployedAccountReceipt = await deployedAccountTx.wait() |
|
| 78 | + | console.log(deployedAccountReceipt) |
|
| 79 | + | ||
| 80 | + | // equip NPC via TBA |
|
| 81 | + | ||
| 82 | + | } |
|