Comments (4)
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.
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.
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.
@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.
@johnmpotter @soundyogi is correct, @kartojal has the right idea.
from drizzle-legacy.
Related Issues (20)
- Drizzle cache does not clear error message HOT 3
- Allow empty drizzleOptions HOT 1
- Better error message for invalid event name HOT 3
- incorrect from address when switching account with Metamask HOT 2
- Potential error in polling
- cacheCall() sometimes hangs. Needs a browser restart to fix. HOT 4
- Calling function with multiple return values HOT 2
- npm install with app directory fails for Drizzle HOT 1
- print revert() in new Contract function HOT 1
- Support for meta transactions HOT 4
- H
- H
- Question: Can I generateStore() with extra initialState? HOT 2
- drizzle installation Error HOT 5
- Support for Typescript HOT 3
- Fallback issue with infura ws HOT 2
- Calling cacheCall on a contract method which returns a struct gives an error - Web3 related HOT 3
- If user denies access through MetaMask (6.6.0+) drizzle does not fail gracefully HOT 2
- ..
- Failed to compile. Module not found: Can't resolve 'drizzle' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drizzle-legacy.