git clone https://github.com/whale3070/git-connect-helper-edbe1c7c
前端运行
git reset --hard 841c394d38fb25beb09586405e1e1a58c1132762
回退版本
rm -rf node_modules
产出之前的依赖
npm install
重新编译依赖库
npm run build
npm run preview -- --host --port 5173
访问http://ip:5173
后端运行
cd backend/
go run main.go
查看redis数据库
既然你的“终焉大盘系统”需要通过 Redis 来管理 Hash Code 的状态(如 Reward_Paid),那么安装一个稳定运行的 Redis 是当务之急。
鉴于你目前正在 Linux 服务器(Root 权限)上操作,以下是最快捷的安装与运行步骤:
1. 安装 Redis
在 Ubuntu/Debian 系统上,直接使用包管理器安装最稳妥:
| apt update apt install redis-server -y
|
2. 配置与启动
安装完成后,Redis 通常会自动启动。你可以通过以下命令管理它:
- 检查状态:
systemctl status redis-server
- 启动服务:
systemctl start redis-server
- 开机自启:
systemctl enable redis-server
3. 验证运行状态
使用 Redis 自带的客户端工具进行“Ping-Pong”测试:
4. 针对你项目的进阶配置
由于你的项目涉及 DOT 奖励发放 和 代付 gas 服务费,数据的安全性非常重要。建议进行以下微调:
设置密码(保护你的 Hash Code 数据)
- 打开配置文件:
vim /etc/redis/redis.conf
- 找到
# requirepass foobared 这一行。
- 去掉注释,改为:
requirepass 你的强密码
- 重启服务:
systemctl restart redis-server
查看hashcode
cd backend/
python python tell_me_valid_hash.py
复制hashcode,访问http://ip:5173/valut_mint_nft/
部署工厂合约
成功部署的工厂合约地址:
0xfd19cc70af0a45d032df566ef8cc8027189fd5f3
工厂合约的源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
| pragma solidity ^0.8.24;
import "./QuickNFT.sol";
contract BookFactory { address public treasury; uint256 public deployFee; address[] public deployedBooks; mapping(address => address[]) public publisherBooks; struct BookInfo { string name; string symbol; string author; address publisher; uint256 deployedAt; } mapping(address => BookInfo) public bookInfo;
event BookDeployed( address indexed bookContract, address indexed publisher, string name, string symbol, string author ); event DeployFeeUpdated(uint256 oldFee, uint256 newFee); event TreasuryUpdated(address oldTreasury, address newTreasury);
constructor(address _treasury, uint256 _deployFee) { require(_treasury != address(0), "Invalid treasury address"); treasury = _treasury; deployFee = _deployFee; }
function deployBook( string memory bookName, string memory symbol, string memory authorName, string memory baseURI, address relayer ) external payable returns (address) { require(msg.value >= deployFee, "Insufficient deploy fee"); require(bytes(bookName).length > 0, "Book name required"); require(bytes(symbol).length > 0, "Symbol required"); QuickNFT newBook = new QuickNFT( bookName, symbol, authorName, msg.sender, // 出版社成为 Owner baseURI ); address bookAddress = address(newBook); if (relayer != address(0)) { newBook.setRelayerAuthorization(relayer, true); } deployedBooks.push(bookAddress); publisherBooks[msg.sender].push(bookAddress); bookInfo[bookAddress] = BookInfo({ name: bookName, symbol: symbol, author: authorName, publisher: msg.sender, deployedAt: block.timestamp }); if (msg.value > 0) { (bool success, ) = payable(treasury).call{value: msg.value}(""); require(success, "Transfer failed"); } emit BookDeployed(bookAddress, msg.sender, bookName, symbol, authorName); return bookAddress; }
function totalBooks() external view returns (uint256) { return deployedBooks.length; }
function getPublisherBooks(address publisher) external view returns (address[] memory) { return publisherBooks[publisher]; }
function getBookSales(address bookContract) external view returns (uint256) { return QuickNFT(bookContract).totalSales(); }
function updateDeployFee(uint256 newFee) external { require(msg.sender == treasury, "Only treasury"); emit DeployFeeUpdated(deployFee, newFee); deployFee = newFee; }
function updateTreasury(address newTreasury) external { require(msg.sender == treasury, "Only treasury"); require(newTreasury != address(0), "Invalid address"); emit TreasuryUpdated(treasury, newTreasury); treasury = newTreasury; }
receive() external payable {} }
|
手动部署子合约
| cast send 0xfd19cc70af0a45d032df566ef8cc8027189fd5f3 \ "deployBook(string,string,string,string,address)" \ "Whale3070 Autobiography" "W3070" "Whale3070" "https://arweave.net/example_cid" \ 0x0000000000000000000000000000000000000000 \ --rpc-url https://evmtestnet.confluxrpc.com \ --private-key $PUBLISHER_PRIVATE_KEY \ --value 1ether \ --legacy
|
可以成功部署子合约,也可以通过子合约mint nft
问题
输入出版社的hashcode
进到后台,通过前端调用智能合约,无法部署子合约。