Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

387
Visualizações
How to send my content to a global IPFS node?

To use IPFS in NodeJS, I require ipfs module. To connect a IPFS node I try:

const IPFS=require("ipfs");
const node= await IPFS.create();

After that, When I run NodeJS in PowerShell, The below messages emerge:

Swarm listening on /ip4/192.168.1.100/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/192.168.88.1/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/192.168.49.1/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp

I think the above messages are mentioning that I connected to a local IPFS node. If my thought is true, It can be because of IPFS.create(). So, I should put a gateway as an argument to that to connecting a global node. I saw some IPFS public gateways on Public Gateway Checker but I don't know how to put one sample in IPFS.create();

Please giude me:

  1. Am I right about the messages on PowerShell?

  2. How to use a global IPFS gateway in my code?

My whole NodeJS code:

const IPFS=require("ipfs");
    async function register(){
        const node=await IPFS.create();
        node.add("Main Content!").then(function(ipfsHash){console.log(ipfsHash)});
    }

Whole result in PowerShell:

Swarm listening on /ip4/192.168.1.100/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/192.168.88.1/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/192.168.49.1/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/12D3KooWCGvmbySrpdCVKACJPjZeeUiMR6gSQffa7W3gWZLSGBxp
{
  path: 'QmUaTPt2Uus46Cgo4YMKze8PpHrCKvZ1YXD2zpffNt8U9S',
  cid: CID(QmUaTPt2Uus46Cgo4YMKze8PpHrCKvZ1YXD2zpffNt8U9S),
  size: 21,
  mode: 420,
  mtime: undefined
}

Thank you a lot!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When you call create(), the client connects to a local node the URL http://localhost:5001. To connect to another HTTP gateway to a global node, simply pass the gateway's URL instead.

const client = await IPFS.create("https://<your-preferred-gateway>");
const { cid } = await client.add("Your content");

See also: create options

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda