Skip to content
CoConnect
Акаунт
Акаунт
Base
On fleek
Rulez
Memories
Posting
Register
Edit MetaMask Profile
Create Web3 post
Web3 login
CoCommunity Chat
CoConnect
Акаунт
Акаунт
Main Menu
Base
On fleek
Rulez
Memories
Posting
Register
Edit MetaMask Profile
Create Web3 post
Web3 login
CoCommunity Chat
Please
log in
to submit content!
📤 Качи файл в IPFS (чрез Pinata)
Качи
if (!content) { alert("Моля, въведи текст за поста."); return; }if (!fileInput.files.length) { alert("Моля, прикачи изображение."); return; }try { resultDiv.innerHTML = "⏳ Качване на изображението...";const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); const userAddress = accounts[0];const imageFile = fileInput.files[0]; const imageForm = new FormData(); imageForm.append("file", imageFile);const imageUpload = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", { method: "POST", headers: { "pinata_api_key": "f21547011c70149c201b", "pinata_secret_api_key": "b4db9894e89228eef59c254be144e47051b3c632f384892749a1bb4f1a7f4f02" }, body: imageForm });const imageData = await imageUpload.json(); const imageUrl = `https://gateway.pinata.cloud/ipfs/${imageData.IpfsHash}`;resultDiv.innerHTML = "📄 Създаване на пост...";const postData = { author: userAddress, content: content, image: imageUrl, timestamp: Math.floor(Date.now() / 1000) };const postBlob = new Blob([JSON.stringify(postData)], { type: "application/json" }); const postForm = new FormData(); postForm.append("file", postBlob, "post.json");const postUpload = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", { method: "POST", headers: { "pinata_api_key": "f21547011c70149c201b", "pinata_secret_api_key": "b4db9894e89228eef59c254be144e47051b3c632f384892749a1bb4f1a7f4f02" }, body: postForm });const postDataResult = await postUpload.json(); const postUrl = `https://gateway.pinata.cloud/ipfs/${postDataResult.IpfsHash}`;resultDiv.innerHTML = ` ✅ Постът е качен успешно!
${postUrl}
`; } catch (err) { console.error(err); resultDiv.innerHTML = "❌ Грешка при качване. Виж конзолата за подробности."; } };
Влез с MetaMask
Scroll to Top