Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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)
Expand Down
16 changes: 13 additions & 3 deletions src/components/NFTMarket/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down