Git Product home page Git Product logo

Comments (4)

kartojal avatar kartojal commented on May 23, 2024 2

I'm using drizzle and drizzle-react packages, and a way to use getPastEvents is to use the "web3" instance that comes with Drizzle, injecting the contract ABI and the deployed contract address to new web3.eth.Contract(abi, address, options), creating a raw Web3 contract instance, with all the web3 methods.

Some pseudocode example, can be wrapped into a function for reusing it:

const web3 = drizzle.web3;
const yourContract = drizzle.contracts.YourContract;
const yourContractWeb3 = new web3.eth.Contract(yourContract.abi, yourContract.address);
const pastEvents = await yourContractWeb3.getPastEvents(
  'eventName or allEvents',
  {
     fromBlock: 0,
     toBlock: 'latest'
  }
);

Could try to recreate a Fiddle for a real React example if you want 😄 Hope it works for you.

from drizzle-legacy.

johnmpotter avatar johnmpotter commented on May 23, 2024

My short-term solution was to fork drizzle and add the raw web3Contract instance to the drizzle contract and just use that when calling getPastEvents.

johnmpotter@0ff0995

I believe the reason the function isn't being added to the DrizzleContract instance has to do with Object.assign, but i'm not sure what the solution would be. I'll leave this open incase someone smarter than myself has the answer.

from drizzle-legacy.

soundyogi avatar soundyogi commented on May 23, 2024

@kartojal answer is correct.

To access getPastEvents you need to access a web3 contract instance.

This Issue can be closed.

Related: trufflesuite/drizzle#149

from drizzle-legacy.

OnlyOneJMJQ avatar OnlyOneJMJQ commented on May 23, 2024

@johnmpotter @soundyogi is correct, @kartojal has the right idea.

from drizzle-legacy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.