Browse Source

添加NFT图片

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

10
.openzeppelin/bsc-testnet.json

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

12
contracts/NFT.sol

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

3
scripts/deployProxy.ts

@ -12,7 +12,8 @@ async function main() {
console.log("開始部署NFT合約"); console.log("開始部署NFT合約");
const NFT = await ethers.getContractFactory("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("NFT合約", nft.target);
console.log("開始部署Pool合約"); console.log("開始部署Pool合約");

Loading…
Cancel
Save