We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

0

// Assuming we are inside async function this.socket.emit ( 'playerAnimals', await Promise.all ( (await this.contract.methods.getPlayerAnimals (this.address). call ({ from: this.address })). map (animal => this.contract.methods.getAnimal (animal). call ({ from: this.address }))));


1

You're missing () after myContractInstance.methods['0xc4e41b22'].


0

What you are doing wrong is in your code myContAddr is string and you are trying access parameters of this variable. To access .methods.getTotalSupply().call() you need to create contract instance using the following code: async function myContractAddress() { var myContAddr = '0x552F3AfaA0394632f4aEfa9E923fA3e2bbDAF5FE'; var myContractAbiDefenition =...


0

If you are using Web3@0.2x.x, you can look at API Documentation how to create a contract object and initiate it on an address.


0

For web v0.20 creating a reference to an existing instance should be done in two steps // Create contract object var MyContract = web3.eth.contract(abiArray); // Reference instance var contractInstance = MyContract.at(address);


0

I believe that you're actually on web3 v1.x, in which case, you should indeed be using new web3.eth.Contract, but with a capital C. In order to verify which version of web3 you're on, run npm ls web3 from a command line or console.log(web3.version) from your JS code.


0

why here we are not used our private Key for signing during deployment of contract Because your code assumes that account1 is unlocked on the node that you're communicating with (whatever you've initialized your web3 instance to connect to). If account1 is not unlocked on that node, then your code will fail to complete. I'm assuming that account1 is a ...


1

You should not think of Ethereum transactions in the same sense as regular messaging / transactions / background runs in the "traditional" world. Information like exact timestamps is really irrelevant in Ethereum. A miner picks up transactions for his block and the miner decides in which order the transactions will be executed inside the block. All that ...


0

The result of the contract call will be available only inside the init function. In order to make it available to other functions, you can return the result. const contractAddress1 = '0xc1847e91e386e11e4df447b3e333f1b18abd1aca' const contractABI = [{"constant":true,"inputs":[],"................]; var contract1 = new web3.eth.Contract(contractABI, ...


0

This is more of a javascript question rather than related to ethereum. The reason why your variable ot hasn't changed is because method contract1.methods.getTotalSupply() needs some time to query the blockchain for the result. This works on the same principle like Ajax request. What you could do is use async/ await or just place the variable inside the query ...


0

You are printing ot before call result was stored to it. Try this code: var ot="raw"; contract1.methods.getTotalSupply().call().then(function(result){ console.log(result) ot = result; console.log("ot : ", ot); }); Explanation: You are calling contract asynchronously, which means that result is not available immediately, but rather after some time. ...


1

About 1. for creating fresh addresses you can use keythereum or ethers.js. Take a look on both libraries and pick the one you prefer. About 2. and 3. To track the payments I see 2 options: You will be using nodejs so you can setup nodejs cronjob and check in block range ({fromBlock: X, toBlock: 'latest'}) the new transactions that sent ethers to your main ...


0

1st lets clear a few things for you. Past events are not stored in contract. There are no built in functions like getPastEvents() and events.allEvents() to get all events. Events are fired only where you emit them. Here is an example contract pragma solidity ^0.5.11; contract SillyOwner { address owner; constructor() public { owner = msg....


Top 50 recent answers are included