New answers tagged

0

From what I see this statement import web3 from './getWeb3'; it is wrong, you are assigning getWeb3() nop web3js object, and it fails because new web3.eth.Contract is invalid as it does not have property eth. IMO in storehash.js you should have import getWeb3 from './getWeb3'; .... export default () => { return getWeb3().then(web3 => new web3.eth....


2

Regarding how you can wait until the tx receipt is ready bellow I wrote an example of how: const balance = contractInstance.methods.balanceOf(walletAddress).call(function(err, result) { ... web3.eth.getTransactionCount(fromAddress) .then((count) => { let rawTransaction = { 'from': fromAddress, 'gasPrice': web3.utils.toHex(10 * 1e9), ...


0

You need to clearly identify what you are trying to achieve. A proper indentation will help people here to help you. function(item,i), perhaps function(recipient,i) would be more informative. It is clunky to mix callbacks and promises. If you want to use only promises, my advice, then do: const balance = await contractInstance.methods.balanceOf(item).call()...


1

Transaction was failing because of fixed gasLimit : 37000. Gas depends on what the function is doing. For example, it is more expensive to set a zero-value storage value to non-zero, than it is to set a non-zero storage value to another non-zero storage value. In my case it was because of SSTORE opcode as it takes 20000 when storage value is set to non-...


0

In my case, the answer was that I called the API incorrectly 🤦🏻‍♂️ recoverTypedSignature({ data: createPayload(message), sig: signature }) is correct. I accidentally called it with sign (note the extra "n").


0

Do I need to convert the 132 characters to 65 somehow? No, the line sig = exports.toBuffer(sig) in function fromRpcSig does this for you. However, in order for it to return a buffer of 65 bytes, toBuffer needs to receive an input string of 130 hexadecimal characters, because each character (0-9; A-F) represents 1/2 byte (4 bits). So your 132-character ...


0

Try this: web3.eth.getTransactionCount(addressFrom).then(txCount => { const newNonce = web3.utils.toHex(txCount) const transaction = new Tx({ ...txData, nonce: newNonce }, { chain: 'mainnet' }) transaction.sign(privateKey) const serializedTx = transaction.serialize().toString('hex') web3.eth.sendSignedTransaction('0x' + serializedTx) ...


0

You are using: gas = 41000 price = 20 * 1e9 value = result As you might understand at this point, the error-message "insufficient funds for gas * price + value" indicates that the ether balance of walletAddress is smaller than 41000 * 20 * 1e9 + result. One way to solve it is simply by sending some ether to walletAddress. Another way you can try is ...


0

It is possible to do this with an ethersjs read-only transaction. prototype.call(transaction) => Promise<hex>


0

Error: Returned error: nonce too low A nonce is basically the number of transactions that have been performed from a particular account address. In order to fix the above error: const accountNonce = '0x' + (web3.eth.getTransactionCount(ethereum_account_address) + 1).toString(16) Replace the nonce value in the rawTx with the above one. var rawTx = { ...


0

The problem is that i is already equal to addresses.length when your timeout callbacks are being executed. Should be: for(i=0; i<addresses.length; i++){ const index = i; // This will not change! setTimeout(function() { $.getJSON('https://api.etherscan.io/api?module=contract&action=getsourcecode&address='+addresses[index]+'&apikey=...


1

Ethers.js has a function that checks the validity of a seed phrase, HDNode.isValidMnemonic: https://docs.ethers.io/ethers.js/html/api-advanced.html#static-methods For example: import { utils } from 'ethers.js'; utils.HDNode.isValidMnemonic("action glow era all liquid critic achieve lawsuit era anger loud slight"); // returns true If you're using Ethers....


1

Following my comments above, try this: async function test() { var contractObject = web3.eth.contract(...); var submittedContract = await contractObject.new(...); var totalSupply = await contractObject.at(...).totalSupply(); console.log(totalSupply); } test();


2

As the error says 'count is not defined' ... you set the nonce to 'count' but did not define that. So you need to do something like this: var count = web3.eth.getTransactionCount();


0

Requires c capital of contract(Here: web3.eth.Contract), So it should be var contractAbi = new web3.eth.Contract(abi) look that is C and not c in: web3.eth.Contract


0

Try to regenerate the JSON file by deleting the old JSON file and re-compiling .sol file. It worked for me.


0

Since web3.eth.compile.solidity has been deprecated, thus, we need to deploy our smart contracts outside of geth. This can be achieved by using solc. Deploying contract using solc: npm i solc Create a file for deploying: deploy_Hello_World.js const fs = require('fs'); const solc = require('solc'); const Web3 = require('web3'); const web3 = new Web3(new ...


0

$ refers to jQuery, and the Etherscan link you shared also notes that. Check out their docs here. I would recommend downloading their list of addresses, and then iterating over it like so: var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider()); var version = web3.version.api; let addresses = []; // TODO: Read in CSV data for (...


1

Blockchains won't most likely ever replace stuff like regular servers. Blockchains are deterministic and they are not suited for stuff like hosting websites. The decentralization of blockchain is about the data they contain. So if you upload a smart contract which for example calculates numbers together everyone can access the same contract and it's not ...


0

As @Ismael said, the problem seems to have been the fact that I was missing 3 forks: petersburg constantinople byzantium After adding these at block 0 it started working.


0

Your Bytecode isn't a hex number. Prepend a 0x. For example 0x606060405260018054600160a060020a031916... EDIT: Nevermind you already did that. Here is another try. Convert the string to hex. parseInt("0x6060604...", 16) Take note of the radix 16. Leave this value unchanged.


0

Ok. With this code the parts were errors might occur are very limited. Make sure providerUrl has the correct value. I hope you filled contractAddress correctly. Abi is the bigger problem. Do a console.log of it. I would suggest a JSON.parse on the abi. This might fix the problem. EDIT: What is your web3 version? Make sure not to use an outdated one.


0

This is not a built-in feature of ERC-721, you will need to use an extension. Xcert, the contract for 0xcert has this feature. https://github.com/0xcert/framework/blob/master/packages/0xcert-ethereum-xcert-contracts/src/contracts/xcert.sol Here is the relevant code /** * @dev Creates a new Xcert. * @param _to The address that will own the created ...


0

While you can try a web automation tool, this will be slow and often brittle. A better approach would be use npm and a small script which loads web3js and the text file. Then you can parse the text file and submit the transactions via methods of web3js The code under "Usage" should get you started: https://github.com/ethereum/web3.js/


0

I would first try sudo chmod 777 ~/.node_modules If this doesnt work, try it with installing it with the unsafe perm option sudo npm install -g --unsafe-perm If this doesnt work try to rebuild node gyp sudo node-gyp rebuild -g --unsafe-perm


0

This has been answered in the following github issue. I suppose it is still up to date. Quoting the aswer: After calling Contract.events.EventName you get a subscription in a response. It has unsubscribe method. However, at this time, it was not fully working. When you test it out, please edit my post to put the correct information.


0

The transaction is confirmed right away on the node you are connected to. It may be possible that somewhere else, another group of nodes has generated a chain that is different than the node you are connected to. This other chain, when synced with your node, may be considered as the correct chain (likely because it has a higher block number). So, in order ...


0

You could look into a service which does this for you, for example Cindercloud. Disclaimer: I'm the owner of Cindercloud. There are other services that do this out there, and this is just an example of a service that offers this.


0

The ethereum network is a decentral network that has to periodically agree on a common state of the network (a common blockchain). To achieve this, every node (participant) agrees on common consensus rules (for validating blocks and transactions) and a consensus mechanism (to decide who may publish the next block candidate). If at least one node in the ...


1

The callback function is executed when the Node sends the transaction hash back to your process. This typically happens almost immediately, and as such, it does not indicate that the transaction has been mined; you still need to take the transaction hash and use it in order to obtain the receipt; furthermore, you still need to take that receipt and wait for ...


0

Pass large number as string adding single or double quotes that fixes the issue var tx = await nft.mintUniqueTokenTo( receipientAddress, '122164239941406260', // <- tokenId tokenURI, { from: coinbase } );


0

Try this: const crypto = require("crypto"); const util = require("ethereumjs-util"); const privateKey = "0x" + crypto.randomBytes(32).toString("hex"); const publicAddr = "0x" + util.privateToAddress(privateKey).toString("hex");


0

One mistake that I can spot: You should use the nonce of the account from which you send the transaction. In your case, you are sending from account1 but using the nonce of account2.


0

For creating a flat file I like truffle-flattener. Just npm install truffle-flattener Run locally node node-modules/.bin/truffle-flattener ./contracts/your_contract.sol > contract_flat.sol


2

web3.eth.getBalance makes an RPC (remote procedure call) to the Ethereum Node process which the given web3 instance is connected to (https://mainnet.infura.io in your case). This process will send a response, while your process can continue running and wait for that response elsewhere in your code. So web3.eth.getBalance returns Promise object, which you ...


2

An asynchronous function returns a promise, web3.eth.getBalance(...) is such a function. You have to await the result, there are two ways to do this: async function myAsyncFunction() { // your code console.log(await balance1) } alternatively use the old style: // your code balance1.then((balance) => { console.log(balance); }); Promise: https://...


0

Where you have var tx = new Tx(txObject) you need const tx = new Tx(txObject, {chain:'ropsten', hardfork: 'petersburg'}) h/t https://community.infura.io/t/sendsignedtransaction-invalid-sender-error/832 Full Code This code is working locally. Replace your infura url and private key. web3 1.2.4 ethereumjs-tx 2.1.1 (installed with separate npm install ...


0

https://www.npmjs.com/package/web3-eth // install using yarn or npm npm install web3 yarn add web3 // in node.js var Web3Eth = require('web3-eth'), eth = new Web3Eth('ws://localhost:8546');


1

A string can consist of an integer in any basis, that's the reason you have to include the basis, so the integer within is interpreted properly. Examples: '01' Basis 2, or 'binary' '01234567' Basis 8, or 'octal', '0123456789' Basis 10, or 'decimal', '0123456789ABCDEF' Basis 16, or 'hexadecimal' Example that shows why it is important to specify the ...


1

Serialization means that the message is packed in a byte stream, which properties (like encoding, byte ordering, etc.) are defined by a common protocol. This way you can ensure everybody can pack (serialize) the object into a byte-stream and send it to any participant who knows the protocol, whereupon the participant is able to properly unpack (deserialize) ...


0

You can reference the web3.js docs around sending a transaction here: https://web3js.readthedocs.io/en/v1.2.4/web3-eth.html#sendtransaction the example looks like: // using the promise web3.eth.sendTransaction({ from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', value: '1000000000000000' }) ....


0

In your crCode variable, after Contract Creation Code, you need to append Constructor Arguments. Both pieces of byte-code are available to you at the URL which you have linked in your question. Alternatively, since the Contract Source Code is also available at that link, you can compile it and then deploy it in the "standard way" (using web3.js deploy ...


0

I cannot assign more gas above gas limit of ganache... is it possible to increase this limit.... ? Yes, start Ganache with --gasLimit=someHigherValue. That being said, note that 6721975 is already by itself a pretty high value for a single transaction, so your deployment most likely fails for a different reason ("out of gas" is unfortunately quite a ...


0

With getterFunctionsNameObject[key][j].input, you are passing a single array as input parameter. Use ...getterFunctionsNameObject[key][j].input instead. BTW, I believe that you can use this also for functions which take no input parameters. In other words, the if (funcParmLength == 0) / else part is redundant. Just do res = await myContractInstance....


0

But the functions which can change the status of state variables are not running. In order to execute a state-changing function you should use send instead of call. Is it necessary to send every transaction with signature (even on local ganache)? You can skip that part if you unlock your account on the node that you're communicating with. In Ganache, ...


0

I changed the path and it worked locate geth.ipc /opt/project/ethereum/geth.ipc


0

You can try these... Just by changing last line. function approve() external { require(msg.sender == approver); address(this).balance; } }


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 }))));


0

You are trying to pass Javascript object as Ethereum address, while it should be Javascript string. The problem is most probably in the following line: from: this.contract It should be something like this: from: this.contract.address to avoid the error. However, there is another, even more serious problem with your approach: in order to send ...


1

The comment-section indicates that your problem is solved. Nevertheless, note that 1000000000000000000 is larger than Number.MAX_SAFE_INTEGER. So the expression (0.1*maxBids) * 1000000000000000000 may yield an inaccurate value. Therefore, assuming that the type of maxBids is Number, I recommend that you change it to: `${maxBids}e17` If maxBids == 12.34, ...


Top 50 recent answers are included