Browse Source

添加NFT图片

master
yyy 6 months ago
parent
commit
c605a46d3a
  1. 10
      .openzeppelin/bsc-testnet.json
  2. 12
      contracts/NFT.sol
  3. 13
      scripts/deployProxy.ts

10
.openzeppelin/bsc-testnet.json

@ -115,6 +115,16 @@
"address": "0xf13Bdb02610672144381Fc6A3A438B62CB579934",
"txHash": "0x33a174a7a830468f0b6eeb9435340801a42685b13aa42b41b43ba056cbdd7b7a",
"kind": "transparent"
},
{
"address": "0x1D321a4FE34310f49F72cf73A0d573Eb3B7CdB03",
"txHash": "0xa4e740f0cc6247881a186717373a5e84f0a2b4c5c66e01b1d2c075c19a1b35e9",
"kind": "transparent"
},
{
"address": "0x9a1baA5b0282dc948Af3011e730da7236060f806",
"txHash": "0x953e6746fa3c3d5efa634a16f7c07cf7d72e32b8b25e12615c645d01f387048e",
"kind": "transparent"
}
],
"impls": {

12
contracts/NFT.sol

@ -11,12 +11,14 @@ contract NFT is ERC721Enumerable {
bool first;
address public pledgeAddress;
uint256[] public blacks;
string public baseURI;
constructor(string memory name,string memory symbol) ERC721(name,symbol) {
constructor(string memory name,string memory symbol,string memory uri) ERC721(name,symbol) {
require(first == false,"You can only use it once.");
admins.push(msg.sender);
deployAddress = msg.sender;
first = true;
baseURI = uri;
}
modifier onlyAdmin(){
@ -62,6 +64,10 @@ contract NFT is ERC721Enumerable {
admins = _admins;
}
function setBaseURI(string memory _uri) external onlyAdmin {
baseURI = _uri;
}
function getAdmin() public view returns(address[] memory){
return admins;
}
@ -88,4 +94,8 @@ contract NFT is ERC721Enumerable {
return super._update(to,tokenId,auth);
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
return baseURI;
}
}

13
scripts/deployProxy.ts

@ -12,19 +12,20 @@ async function main() {
console.log("開始部署NFT合約");
const NFT = await ethers.getContractFactory("NFT");
const nft = await NFT.deploy("MyNFT", "MNFT");
const baseURI = "ipfs://QmQpgq4FvXNHZfoytpiwk617Nozmeu7iMiyiSzthVg1ZV7/metadata.json"
const nft = await NFT.deploy("SOFIL NFT", "SFSC", baseURI);
console.log("NFT合約", nft.target);
console.log("開始部署Pool合約");
const Pool = await ethers.getContractFactory("Pool");
const pool = await upgrades.deployProxy(Pool,[FIL_ADDRESS,nft.target],{ initializer: "initialize" });
const pool = await upgrades.deployProxy(Pool, [FIL_ADDRESS, nft.target], { initializer: "initialize" });
console.log("Pool合約", pool.target);
console.log("開始部署Pledge合約");
const Pledge = await ethers.getContractFactory("Pledge");
const pledge = await upgrades.deployProxy(
Pledge,
[nft.target,pool.target],
[nft.target, pool.target],
{ initializer: "initialize" }
);
console.log("Pledge合約", pledge.target);
@ -37,9 +38,9 @@ async function main() {
// 測試使用
console.log('設置成功');
console.log('NFT的質押合約地址',await nft.pledgeAddress());
console.log('Pool的質押合約地址',await pool._pledgeContractAddress());
console.log('质押时间',await pledge.dayTime());
console.log('NFT的質押合約地址', await nft.pledgeAddress());
console.log('Pool的質押合約地址', await pool._pledgeContractAddress());
console.log('质押时间', await pledge.dayTime());
}

Loading…
Cancel
Save