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

202
Visualizações
How to set OpenSea.js provider from Onboard.js or Web3Modal.js then inject globally in Nuxt.js?

Using opensea-js to build static generated storefront with Nuxt. As wallet providers seems like best options are onboard.js or Web3modal.

To share code and state across components used "inject" in Nuxt. Loaded onboard.js and opensea-js as a client plugin.

On initial load Onboard is injected globally. After user selects the Wallet, onboard subscription fires a callback function wallet: (wallet) => {...} and in its scope current provider becomes available. Then I pass the provider to OpenSeaPort and inject it globally. But it does not work, this.$seaport is not defined when called from other components (pages).

/plugins/onboardopensea.client.js

import { OpenSeaPort, Network } from "opensea-js";
import Onboard from "bnc-onboard";

export default ({ app }, inject) => {

  let seaport = {};

  const onboard = Onboard({
    dappId: "...",
    networkId: 1,
    subscriptions: {
      wallet: (wallet) => {

      seaport = new OpenSeaPort(wallet.provider, {
      networkName: Network.Main,
      apiKey: "...",
       });

      inject("seaport", seaport);
      },
    },
    walletSelect: {
      wallets: ...,
    },
)};

  inject("onboard", onboard);
}

Seems like inject function runs only once, on first load, and does run when called at later time from Onboard wallet callback function.

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

0

After researching more in-depth seems like "Inject" is called only once and attach to Vue instance and Nuxt app. Used "Vue.prototype.$seaport = seaport" instead which can be called at any time from Onboard Subscription callback function.

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