From 38db63180e196e8884cab566d5ac9f34bebae974 Mon Sep 17 00:00:00 2001 From: Abhishek Chauhan Date: Mon, 24 Oct 2022 21:43:31 +0200 Subject: [PATCH 1/3] Readme infura update A solution to Infura public API and gateway is deprecated. --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9582274..cd90339 100644 --- a/README.md +++ b/README.md @@ -429,10 +429,22 @@ npm install ##### Upload `Image` to `IPFS` +Get IPFS infura credentials (here)[https://infura.io/]. Remeber to create a DEDICATED GATEWAY SUBDOMAIN to get uploaded files. + ```javascripts -import { create as ipfsHttpClient } from 'ipfs-http-client' +import { create } from 'ipfs-http-client'; + +const auth = + 'Basic ' + Buffer.from(INFURA_IPFS_ID + ':' + INFURA_IPFS_SECRET).toString('base64'); -const client = ipfsHttpClient('https://ipfs.infura.io:5001/api/v0'); +const client = create({ + host: 'ipfs.infura.io', + port: 5001, + protocol: 'https', + headers: { + authorization: auth, + }, + }); async function onChange(e) { const file = e.target.files[0]; @@ -443,7 +455,7 @@ async function onChange(e) { progress: (prog) => console.log(`received: ${prog}`) } ); - const url = `https://ipfs.infura.io/ipfs/${added.path}`; + const url = `YOUR_DEDICATED_DOMAIN/ipfs/${added.path}`; setFileUrl(url) } catch (error) { console.log('Error uploading file: ', error) From 4556f7ab4fabfcaf0272de16a2ed59bdaac95fb5 Mon Sep 17 00:00:00 2001 From: Abhishek Chauhan Date: Mon, 24 Oct 2022 21:44:48 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd90339..8162d0d 100644 --- a/README.md +++ b/README.md @@ -429,7 +429,7 @@ npm install ##### Upload `Image` to `IPFS` -Get IPFS infura credentials (here)[https://infura.io/]. Remeber to create a DEDICATED GATEWAY SUBDOMAIN to get uploaded files. +Get IPFS infura credentials [here](https://infura.io/). Remeber to create a DEDICATED GATEWAY SUBDOMAIN to get uploaded files. ```javascripts import { create } from 'ipfs-http-client'; From fc8abd32d0e7c80f40351bde7f165d31b91cbb34 Mon Sep 17 00:00:00 2001 From: Abhishek Chauhan Date: Mon, 24 Oct 2022 21:52:13 +0200 Subject: [PATCH 3/3] Ipfs update ipfs file uploading update. --- src/components/NFTMarket/index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/NFTMarket/index.js b/src/components/NFTMarket/index.js index bc6b727..dc6aea5 100755 --- a/src/components/NFTMarket/index.js +++ b/src/components/NFTMarket/index.js @@ -1,6 +1,6 @@ import React from 'react' import { ethers } from 'ethers' -import { create as ipfsHttpClient } from 'ipfs-http-client' +import { create } from 'ipfs-http-client'; import { Button, Form, Header, Image, Input, Modal } from 'semantic-ui-react' import './nft.css' @@ -9,7 +9,17 @@ import NFTMarket from '../../abis/NFTMarket' import { useWeb3React } from '@web3-react/core' import { nftaddress, nftmarketaddress } from '../../config' -const client = ipfsHttpClient('https://ipfs.infura.io:5001/api/v0'); +const auth = + 'Basic ' + Buffer.from(INFURA_IPFS_ID + ':' + INFURA_IPFS_SECRET).toString('base64'); + +const client = create({ + host: 'ipfs.infura.io', + port: 5001, + protocol: 'https', + headers: { + authorization: auth, + }, +}); const FormNoFile = { @@ -43,7 +53,7 @@ export default function NFTDAppIndex() { progress: (prog) => console.log(`received: ${prog}`) } ); - const url = `https://ipfs.infura.io/ipfs/${added.path}`; + const url = `{YOUR_DEDICATED_DOMAIN}/ipfs/${added.path}`; setFileUrl(url) } catch (error) { console.log('Error uploading file: ', error)