All Questions
Tagged with javascript events
43 questions
0
votes
1
answer
28
views
Create/set "subId" by createSubscription() and get "subId" vrfCoordinatorV2_5Mock calling by javascript in hardhat environment
deploy.js:
const { network, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-hardhat-config")
const { verify } = require("../...
0
votes
1
answer
157
views
Reading Ethereum contract event TypeError: Cannot read properties of undefined (reading 'toHexString')
I have the following js script that i want to use to read events from a smart contract below, but when i run the script I get the following error message
TypeError: Cannot read properties of undefined ...
0
votes
2
answers
57
views
contract.events
I am listening on an event that's happening on smart contract.
event UpdatedMaxNumber(address indexed player, uint maxNumber, uint256 timestamp);
My original code works fine and updates the new number ...
0
votes
0
answers
17
views
Forking a network to simulate events
I'm trying to simulate an event by forking a network. For example:
wss.on('block', async (blockNumber) => {
// Your code here
});
How can I accomplish this? Any guidance would be ...
1
vote
1
answer
1k
views
How to decode a bytes value from Ethereum event with ethers.js
I've got the following event declaration in my Solidity contract:
event RemoteOrderCreated(bytes32 indexed id, uint32 indexed nonce, address indexed sender, bytes input);
And I capture the event ...
1
vote
3
answers
441
views
Listening to multiple smart contracts
Is there an "optimal" way to listen to multiple smart contracts?
For example, listening to an event emitted by one smart contract in a useEffect:
useEffect(() => {
const ...
0
votes
2
answers
450
views
How to monitor events on an Solidity Smart Contract using hardhat and ethers?
I'd like to monitor events happening on-chain on a specific Smart Contract. I'd like to know every time a Transfer event happens. I tried to write a code with hardhat, but no events if being logged. ...
4
votes
1
answer
2k
views
How to listen to smart contract events using nodejs server?
I am currently trying to 'listen events' emitted from my smart contract. I am able to run my scripts created by using the node command and it works as intended, and I want to host it on a server. I ...
1
vote
1
answer
731
views
Filtering event always returns topics
I have an event in my contract:
event CreatedUnfinishedRandomSVG(uint256 indexed tokenId, address nftOwner, uint256[] randomWords);
In my JS script, I am trying to run some code only if the event that ...
0
votes
1
answer
419
views
Getting specific values from Web3js getPastEvents
I would like to know how to pull the account value from returnValues: Result {} of this web3.eth.Contract
This code logs to the console just fine, but I have scoured documentation on objects and on ...
2
votes
1
answer
11k
views
Ethers.js transfer event filters
In my dapp I'm building I want to update the contracts' balance of an ERC20 token automatically using the transfer event from the token contract. I have created the contract object using:
const ...
2
votes
1
answer
382
views
How to get events from a contract deployed on different network? - Web3
I have contract A in Avalanche FUJI C-chain.
When I'm on C-chain testnet, I can get events from A using getPastEvents() in web3.js, but when I change the testnet (for example, to Goerli), I receive an ...
4
votes
1
answer
6k
views
Ethers - get historical block.timestamp in batch mode
I am trying to build a simple database table containing block.number and block.timestamp starting at a given block number.
This could be easily done with the following JS code using ethers.js library:
...
0
votes
1
answer
825
views
Is it possible for web3 to listen to contract function call ? (For example mint() for a NFT)
Hey I have read about listening to events in web3js and it worked.
I have my abi set up and looked through all available events in it and mint(),
what I use to mint nfts is a function which makes ...
1
vote
1
answer
482
views
OpenZeppelin test helper: expectEvent.inTransaction error
I'm trying to use OZ Test helpers to pass a test when a specific event is emitted. Here is the logic:
I call function1 with a JS Promise.
function1 calls function2 which emits an event.
Parts of ...
1
vote
0
answers
377
views
How to pass Multiple Values in a Solidity Event
I am emitting within a function the following in a solidity smart contract.
emit Transfer(address(0), to, tokenId)
In my front-end JavaScript code, I am reading the values as follows:
let transfer = ...
2
votes
0
answers
296
views
How to watch/wait for events in JavaScript + Truffle?
I'm learning to develop Oracles, and, like all of us, I've encountered a dated article. After fixing all the Solidity changes (version, adding emit to fire an event, changing constructor function to ...
0
votes
1
answer
44
views
Array lenght and data miss match while storing data of events
Can someone help me in finding what is wrong here a why the length of task info is 0 even the taskInfo has some data. I'm using events to fill the taskinfo array.
I'm stuck at this place for almost 2 ...
1
vote
1
answer
471
views
How can I extract a wallet address from event data?
I have a contract that returns event data including the sender's address:
event Result(
address indexed _walletAddress,
string _name,
uint256 _amount
)
And in my Node.js app I try to ...
0
votes
1
answer
401
views
Emited Solidity Events not being watched at frontend truffle contract instance
So, I have been reading through A LOT of pages about events in Solidity and how to interact with them on frontend but I am still pretty new to this and it seems like there have been multiple changes, ...
1
vote
1
answer
104
views
Am I hashing the data in the file itself, or just the reference?
I am attempting to create an app where I upload a file to a website and then I submit a hash of that file onto Ethereum. I am unsure whether I am hashing the actual file below or just the reference to ...
12
votes
4
answers
16k
views
How to get events emitted by a transaction with web3.js
I'm writing a user interface in Javascript and I'm using the web3.js library.
I have the transaction hash of a confirmed transaction. I would like to get an array of all events emitted by that ...
0
votes
1
answer
166
views
Truffle Exec Return Events
I have set up a JavaScript file that takes in my contract and executes the various functions and then returns the correct events. The file runs through 'truffle exec'.
I am using the following line ...
2
votes
3
answers
4k
views
Truffle Tests Events via JavaScript
I am testing my contract via the chai and truffle-assertions libraries from a JavaScript file and am testing if events return the correct values. I have an event called Message. In my function, the ...
1
vote
1
answer
207
views
Accessing the Ethereum State Variables using web3js (Java Script)
I'm trying to run the below code to get the state variables using the getIdBytes method of the Smart Contract, and assign it to a java script array variable, but it doesn't seem to work.
All I can ...
6
votes
2
answers
6k
views
Truffle test, logs do not include an emitted event
I am calling a contract function which emits an event in a transaction. This transaction should include the event and is typically visible via:
const receipt = await contractInstance.someFunction()
...
2
votes
2
answers
771
views
How to stop listening to all events of contract
I am using the JavaScript API in my truffle tests to get the events from the contract:
https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-allevents
const allEvents = instance....
1
vote
2
answers
377
views
Events loading too slow
I have a dapp running on rinkeby at the moment, you can try it now on cryptogol.io, but I am facing a problem when reading events from the Blockchain. For example, yesterday I make the events happens, ...
1
vote
0
answers
103
views
Watch Events with same Name but different params
using [email protected] is there a way to get Events overloaded (with the same name, but different params) ?
I found
contract.Transfer[‘address,address,uint256,address,bytes’]({
fromBlock: 0,
...
1
vote
1
answer
1k
views
Show an event with nodejs
in my Smart Contract I have a function such that it fires an event at the end of its code.
function sendTran(arguments) public {
*code*
emit Event(argument 1,argument 3,argument 3,...
2
votes
1
answer
71
views
Unable to print event without JSONstringify
I am trying to understand the difference among following cases while printing the event:
At web3.js
listenToEvent: function(){
Contract.deployed().then(function(instance){
instance....
0
votes
1
answer
225
views
Why Event log is NOT shown in HTML page?
I want to see Event logs in UI. And for this, I use following code in JavaScript :
var EnergyEvent = Coursetro.setEnergyEvent({}, {fromBlock: 0, toBlock: 'latest'});
EnergyEvent.watch(...
0
votes
1
answer
141
views
A common error at time of using web3 options
When i use some web3 options as follows, I receive a common error i.e.
TypeError: web3.[option] is not a function
For example :
TypeError: web3.toAscii is not a function
web3.toAscii(...
5
votes
2
answers
6k
views
How to convert Hexadecimal values into readable format?
I'm using etherscan API to fetch the event logs:
http://api-ropsten.etherscan.io/api?module=logs&action=getLogs&fromBlock=3147081&toBlock=latest&address=...
1
vote
1
answer
335
views
Web3.js function(s) to help determine the block numbers inside a date range?
I just learned today that you can query past events using the Web3.js 1.0.0 getPastEvents() function. That function supports filtering via the fromBlock and toBlock call parameters, so you can limit ...
0
votes
2
answers
2k
views
Watch multiple contracts/events?
Is there a way to watch events from multiple contracts with just one watch-statement (something like [contract1.event, contract2.event, ...].watchAll() ) in Javascript?
Code is just for illustration ...
0
votes
1
answer
155
views
Watching for events returns 0 blocknumber
I am trying to listen for recently mined events from a live smartcontract(EtherDelta).
//https://github.com/praneethmendu/ethualizer/blob/master/backnd.js
tradeEvent = contractIns.Trade({}...
3
votes
1
answer
1k
views
Solidity print multiple data
I understood that print is not possible on Solidity, is recommended to use event and events can be read by using .watch. In order for an event to appear it has to be mined first.
What if I have a ...
3
votes
2
answers
563
views
Events dont fire when called too quickly
I have a very simple solidity function that just calls an event:
function sendMessage(int id, string title, string message){
Message(id, method, parameters);
}
When I call it using ...
27
votes
5
answers
22k
views
How to listen for contract events in JavaScript tests?
I'm trying to trigger events in my solidity contract to output some debug information in my javascript tests. However the events seem to get never caught.
That's the relevant contract code:
pragma ...
5
votes
1
answer
130
views
Getting event history takes a really long time or doesn't work at all
I'm having trouble getting a history of events. I'm unsure if I am misunderstanding how events work, if I'm coding wrong, or if it has anything to do with the recent Ethereum attacks slowing down the ...
7
votes
1
answer
2k
views
Event result parameters and arguments in console
I read about using events from this source http://solidity.readthedocs.io/en/latest/contracts.html#events
I used a simple multiply contract:
contract test1{
uint a;
event event_res(string msg,...
46
votes
6
answers
43k
views
How do I parse the transaction receipt log with web3.js?
The event parser in web3 provides a nice parsing functionality for events, and I use it for logging all events to a file, but it's very difficult to use for looking at individual events for a ...