Comments (2)
h1 {
margin-bottom: 20px;
}
.nft-card {
border: 1px solid #ccc;
border-radius: 4px;
padding: 10px;
margin-bottom: 10px;
}
.nft-card img {
width: 100%;
max-height: 200px;
object-fit: cover;
border-radius: 4px;
}
.nft-card h3 {
margin-top: 10px;
}
.nft-card p {
margin-top: 5px;
font-size: 14px;
color: #888;
}
.create-form {
margin-bottom: 20px;
}
.create-form input {
margin-right: 10px;
}
</style>
NFT Marketplace
<div class="create-form">
<h3>Create NFT</h3>
<input type="text" id="nftName" placeholder="NFT Name">
<input type="number" id="listingPrice" placeholder="Listing Price">
<button onclick="createNFT()">Create</button>
</div>
<div id="nftList"></div>
<script>
// Endereço do contrato inteligente
const contractAddress = "YOUR_CONTRACT_ADDRESS";
// Objeto Web3
let web3;
// Função para criar um NFT
async function createNFT() {
const nftName = document.getElementById("nftName").value;
const listingPrice = document.getElementById("listingPrice").value;
// Valide os campos aqui se necessário
const accounts = await web3.eth.requestAccounts();
const account = accounts[0];
const contract = new web3.eth.Contract(contractABI, contractAddress);
await contract.methods.createNFT(nftName).send({ from: account, value: web3.utils.toWei(listingPrice, "ether") });
// Atualize a lista de NFTs após a criação bem-sucedida
fetchNFTs();
}
// Função para buscar e exibir NFTs
async function fetchNFTs() {
const contract = new web3.eth.Contract(contractABI, contractAddress);
const totalSupply = await contract.methods.totalSupply().call();
const nftListElement = document.getElementById("nftList");
nftListElement.innerHTML = "";
for (let i = 1; i <= totalSupply; i++) {
const nft = await contract.methods.nfts(i).call();
const owner = await contract.methods.ownerOf(i).call();
const nftCard = document.createElement("div");
nftCard.classList.add("nft-card");
const image = document.createElement("img");
image.src = "NFT_IMAGE_URL/" + nft.id + ".jpg"; // Insira a URL da imagem do NFT aqui
nftCard.appendChild(image);
const name = document.createElement("h3");
name.textContent = nft.name;
nftCard.appendChild(name);
const ownerText = document.createElement("p");
ownerText.textContent = "Owner: " + owner;
nftCard.appendChild(ownerText);
nftListElement.appendChild(nftCard);
}
}
// Função para inicializar o Web3 e buscar os NFTs
async function init() {
if (typeof window.ethereum !== 'undefined') {
web3 = new Web3(window.ethereum);
await window.ethereum.enable();
} else {
console.log("Metamask não detectado");
}
fetchNFTs();
}
// Execute a função de inicialização
init();
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
<script src="YOUR_CONTRACT_ABI.js"></script> <!-- Insira o arquivo do ABI do seu contrato aqui -->
from developer.
good idea but the chatgpt plus allows only 25 messages in three hours... that wont be enough for most applications.
from developer.
Related Issues (20)
- Suggestion: lookup API docs before building code
- Please add releases HOT 1
- No Module named 'openai' HOT 5
- args not defined error HOT 2
- stream_handler error: 'content' {} ←[0m ←[0m ←[0m ←[0m ←[0m ←[0m
- NameError: name 'args' is not defined HOT 3
- pip install modal-client error
- OpenAI key error HOT 4
- JavaScript files contain code fences
- Add a new feature - test and debug to create self-healing code
- Timeout issue
- Error: The system cannot find the file specified. HOT 1
- Can anyone fix the Basic Usate in Git Repo mode? HOT 1
- PyPI Package is Broken
- Run demo through pip package, no response, no output, no error reported, program automatically ends HOT 1
- Is there a way to bind with azure openai?
- Errors when running `poetry run python main.py --prompt "poetry prompt"`
- Feature Proposal: New feature proposal HOT 1
- Test
- how to use codellama instead of openai api? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from developer.