Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

0

Found the answer to my question: The data field from the returned Log struct contains indeed the transferred token amount value: The Bytes' vector needs to be converted into a hexadecimal figure (by looping through the vector and converting its value at each index into a hex and concatenating all the converted values together) to look like the log's data ...


0

FileViewed is an event if you are using web3 v1.2 you have to use like this: marketplace.events.FileViewed({ fromBlock: 0 }, function (error, event) { if (error) { console.log("Error: ", error); } else { console.log("File viewed: ", event); } }) For more details see this: https://web3js.readthedocs.io/en/v1.2.1/web3-eth-...


0

So I fixed it finally! It seems like the 2nd parameter in the event handler which which specified fromBlock and toBlock is not compatible with Metamask. It worked after I removed the toBlock parameter. Working snippet: App.PlatoonContract.PlatoonCreated({}, {fromBlock:0}).watch(function(err, result) { if (err) { console.log(err); ...


0

Update the event to output JSON and utilize your contract in a filter. ... contract = web3.eth.contract(address=contract_address, abi=contract_abi) def handle_event(event): print(Web3.toJSON(event)) # and whatever async def log_loop(event_filter, poll_interval): while True: for event in event_filter.get_new_entries(): ...


1

Keep in mind that a contract is generally immutable so it is appropriate to aim for a comprehensive solution that will accommodate client-side requirements not anticipated at this time. In this context, a "client" can be another contract, a user, a server, or something else--everything external to the contract. There is more than one approach. The following ...


0

The truffle-assertion package can easily help with this. Once the package is installed you can run the following: // Import the package to your file const truffleAssert = require('truffle-assertions'); // Deploy the contract let testContract = await TestContract.new() // Get the hash of the deployment transaction let txHash = testContract.transactionHash ...


0

As those both functions are in the same contract you simply have to call the other function inside deposit. Also if you want to receive Ethers with the deposit function it has to be marked payable. So something like this: pragma solidity ^0.5.0; contract MyContract { function deposit() payable external { // do some stuff ...


Top 50 recent answers are included