Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda