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

229
Visualizações
How can I listen to an event from my smart contract on Flow blockchain?

I used some services for listening to an event from my smart contract on Ethereum. But I can't find some document similar that when working with FLow Chain. How can I do that?

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

0

There are multiple ways of doing this. The easiest I think is to use a service for this. The one we use at .find at the moment is https://graffle.io.

You could also make your own using one of the SDKs. Kitty-items has an example of this https://github.com/onflow/kitty-items/ in javascript.

If you prefer golang I have some event fetching code in overflow https://github.com/bjartek/overflow/blob/main/overflow/event.go. Here is an example on how it can be used: https://github.com/bjartek/overflow/blob/main/overflow/event_integration_test.go#L13

about 4 years ago · Juan Pablo Isaza Relatório

0

This is a really nice question for a common task! @onflow/fcl package provides you with a helpful method events, which can be used to "subscribe" to a specific event. You can check events description on Flow Docs Site. Or you can copy/paste code bellow and play around with it:

import * as fcl from "@onflow/fcl";

// We need to point FCL to some access node.
// We will use Mainnet REST endpoint for this, as the contract
// we want to listen to is deployed there

fcl.config({
  "accessNode.api": "https://rest-mainnet.onflow.org",
  // we will set the poll rate for events to 3 seconds
  "fcl.eventPollRate": 3000
});

// FlowFees is the most active contract, since every transaction will
// trigger "FeesDeducted" event, so it will be easier to see that our code
// is working correctly
const contractAddress = "f919ee77447b7497";
const contractName = "FlowFees";
const eventName = "FeesDeducted";

// Event name consist of 2 or 4 parts
// 2 part event name have only system events
// For deployed contract, event should be constructed from 4 parts
// - "A" prefix, stands for "account"
// - address where contract, holding definition of event is deployed
// - contract name
// - event name
const event = `A.${contractAddress}.${contractName}.${eventName}`;

console.log(
  `Listening for event "${eventName}" from "${contractName}" deployed on account 0x${contractAddress}`
);
fcl.events(event).subscribe((eventData) => {
  console.log(eventData);
});

You can also try and play around with working Codesandbox Example

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