IPFS

Sample code for integrating IPFS into a Typescript frontend client.

Install dependencies

npm install ipfs-http-client 

Initialise the client object

const projectId = process.env.INFURA_PROJECTID
const projectSecret = process.env.INFURA_PROJECTSECRET
const auth =
  'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64')

const client = create({
  host: 'ipfs.infura.io',
  protocol: 'https',
  port: 5001,
  headers: {
    authorization: auth,
  },
})
 

Upload data to IPFS

Last updated