Questions tagged [web3js]

-1

votes
0

answer
23

Views

Why does this function never run even if it did before?

I'm using React.js & Web3.js to create a dapp. I believe this question is more related to react.js and javascript and that's why I'm not posting in in Ethereum Stackexchange. Consider the following code: allowAddress = async() => { let approvedAddress = this.state.approvedAddress; let approvedValue...
Sophie259
1

votes
1

answer
466

Views

Metamask chrome extension gives error. How do I fix this?

I got this error from metamask. It was working fine couple of hours ago. I have tried reinstalling/ disable and re-enabling again but nothing worked. Also, My smart contract is fully functional (Tested in Remix Browser based IDE) and no other errors or logs are present anywhere. I also restarted Ga...
Pramesh Bajracharya
1

votes
0

answer
847

Views

Sending a signed transaction to deploy a contract (Ethereum)

My goal is to send a signed transaction to create a smart contract, however, I am facing an issue I have not been able to solve for few days: When I send the transaction (on a private chain), there are two different ending: - 1 Web3js tells me it worked, I can see the transaction on the block. Howe...
Andromelus
1

votes
0

answer
785

Views

Ethereum Error: Transaction was not mined within 50 blocks

info: Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined! at /opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-method/src/index.js:375:45 at tryCatcher (/opt/bkzcoin_project/bkzcoin-backend/node_mod...
Elisabeth Shevtsova
1

votes
0

answer
456

Views

Error when using 'import' and Node.js 8.9.4

I'm trying to get a simple node project off the ground but have run into issues using the import keyword. I'm attempting to import a few functions from some modules from the 0x.js and @0xproject/connect packages but when I try to run my main.js I get the following error: (function (exports, require,...
jawknee530
1

votes
0

answer
391

Views

web3.eth.getAccounts returns only limited addresses

In my website, there are more than 4700+ addresses currently. When I try to get all accounts using 'web3.eth.getAccounts' it only returns 3360 addresses. I don't know why this happens. For the remaining addresses which are not listed in getAccounts, I have tried 'getBalance' to check if address is v...
Deepak M
1

votes
1

answer
169

Views

Data duplication between internal database and Solidity

There is a flow I want to achieve in my dapp, and I would appreciate some opinion. Flow: User sees a list of products and picks one to buy it. The user has their metamask unlocked and has enough balance. Setup: Rails on the backend, React on the frontend, ganache-cli, truffle, metamask (web3js). Dat...
Maximus S
1

votes
0

answer
245

Views

Not able to get Metamask popup to appear

I have managed to write the following code. The idea is to be able to get a pop up asking how much ETH I want to send. But I am not able to get the pop-up. I have spent hours to fix this and not able to reach a conclusion. I am able to get the popup sometimes but only when I refresh the page. MetaM...
AddyTiger
1

votes
0

answer
113

Views

Elliptic Curve Cryptography in Web3 and Smart Contract

I have been trying to sign the data in Smart Contract by using the web3 library. I gave it a try on the truffle develop console, and I tried to retrieve back the address by using erecover in Solidity.Unfortunately, I couldn't get back the signed address.I did the test on Ganache. Is there any erro...
DavidB
1

votes
1

answer
388

Views

Web3.js Ethereum - Is it possible to call 2 functions in one transaction?

Perhaps it's a silly question. But I'd like to know if it's possible to put 2 (or more) smart contract methods calls in one single transaction in Ethereum. The part of my code for one function call in a single transaction: var data = self.MyContract.MyFunc1.getData( param1); const options = { gasPri...
Alsofter
1

votes
2

answer
145

Views

Solidity contract not working

I'm having trouble running my first solidity contract in remix ethereum and through web3 so I'm guessing something is wrong with my contract code: pragma solidity ^0.4.0; contract cntrct { uint public aaa; function() payable public { create(msg.value); } function create(uint _value) internal { req...
1

votes
2

answer
319

Views

Why `npm install -g` does not work for web3?

When I run npm install web3, then I can run the following nodejs file correctly. $ cat main.js #!/usr/bin/env node // vim: set noexpandtab tabstop=2: const web3 = require('web3'); console.log(web3.utils.asciiToHex('I have 100!')); If I run npm install -g web3 instead, I got the following error. Doe...
user1424739
1

votes
0

answer
270

Views

index.html:114 Uncaught TypeError: Cannot read property 'address' of undefined

I' m working with the ethereum blockchain, I wrote the contract in solidity and now I' m on the Front-End part of the application. I copyed the code for 'WEB3DEPLOY'... var dapp = dappContract.new( _acconto, _saldo, _technician, _Time, { from: web3.eth.accounts[0], data: '0x6060604052600060036014610...
Tommaso Giubilei
1

votes
1

answer
282

Views

ERC20 token. Cannot get variable nor use methods with deployed contract

I have deployed a ERC20 token contract via Metamask on the Ropsten network. The issue is that I am trying to interact with it via web3. I have followed the answers provided in SO and SE, related to token transfer and method calling. As you will see, I am not transferring tokens here, but I am using...
user3708847
1

votes
0

answer
125

Views

Solidity - Sell function not working

I have my contract and people can buy my tokens via web3 and MetaMask. Now when I try to execute sell() function throw an exception and always Etherscan says Failed. I set to sell and buy prices on my contract. Here is my sell function: /// @notice Sell `amount` tokens to contract /// @param amount...
Francisco
1

votes
0

answer
96

Views

ethereumjs - signature security issue

Im new to smart contracts world. I have a doubt about the digital signature security. I wanted to know if an attacker can reuse my same signed message and send it several times to another address? client code example: var msg = 'hello'; var sh3 = web3.sha3(msg); web3.eth.sign(account, sh3, (error, r...
Diagonal Think
1

votes
0

answer
516

Views

Web3: Wait all async calls within a loop are completed

I am using Web3 to get a list of smart contract and then iterate (loop) through each of them to get multiple variables of the smart contracts. Unfortunately, I am not able to execute a function once all the async calls within my loop are done. Logic: Get the number of Games For i = 0 until i < Games...
Mike
1

votes
1

answer
144

Views

Can't update global variables from promise in NodeJS

I'm new to Nodejs, and I've been writing a Web3 handler for my contract, everything works good but the global variables don't update during the promise execution, they have no value even when I console.log after the Then. ... var cityDb = {}; function gettingBalance() { return new Promise ( (resolve...
M. Mez
1

votes
0

answer
442

Views

HTTP Basic Authentication in Web3js

I have geth running in remote server and is protected using HTTP Basic Auth. I tried the below two methods. both don't work: let web3 = new Web3( new Web3.providers.HttpProvider( 'http://' + 'username' + ':' + 'password' + '@'+ '52.43.83.54/iimigdmb' + ':' + '31988' ) ) As per official docs: web3 =...
Narayan Prusty
1

votes
3

answer
201

Views

Can not access quorum's contract from webpage *CORS*

I am getting following error on browser's console while accessing contracts. Failed to load http://localhost:22000/: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is theref...
Mr_Hmp
1

votes
0

answer
55

Views

web3 contract method isn't being called

I have the following fragment of code that calls a contract method using web3 and for some reason when Metamask opens up and I click confirm to send the transaction, nothing happens. Metamask just keeps loading and says transaction approved. Also, the callback function isn't being executed. Why is t...
ninesalt
1

votes
1

answer
121

Views

Can't pass multiple variables via metamask - async error

I am getting an error in metamask 'the MetaMask Web3 object does not support synchronous methods like eth_sendTransaction without a callback parameter'. I am trying to pass three parameters to a solidity function, but the callbacks I've tried to insert don't seem to work? Below is the js code, just...
David
1

votes
1

answer
63

Views

With solidity and Web3, when I attempt to do myEvent.get() all I get is myEvent: undefined

Here is the part of my JS script where I get the event: EthProj.Message({}, { fromBlock: 0, toBlock: 'latest' }).get((error, eventResult) => { if (error) console.log('Error in setEvent event handler: ' + error); else console.log('setEvent: ' + JSON.stringify(eventResult.args)); }); } And here is my...
Cal W
1

votes
1

answer
731

Views

Right way to get ethereum ERC-20 tokens information

Can somebody tell me the right way to get info (decimals count, name and symbol) of the ERC-20 token from the Ethereum blockchain? I supposed that it could be done through the calls of the appropriate functions decimals(), name(), symbol() to the contract address of the exact token via ABI construct...
Alsofter
1

votes
0

answer
258

Views

Web3js interact with local truffle without metamask

I have my dapp that runs correctly on ganache using metamask to sign transactions. However, I want to stop using metamask and have transactions sign themselves. I would like to keep using ganache as this is only for a demo presentation. However, I am not sure how to connect with the smart contract w...
Dorian Graey
1

votes
0

answer
320

Views

Pass more than 2 parameters to a Solidity Contract constructor using web3

I need to pass 3+ parameters to a Solidity contract constructor using web3 to deploy it. From the documentation of web3 v0.2x.x it looks like that it only accepts up to two. Can I pass a javascript object from web3 to the constructor and how will the contract interpret it? If it is not possible what...
Radostin Slavov
1

votes
1

answer
102

Views

Handling UI when a transaction is in pending (MetaMask)

I have a Metamask payment that works fine. It's triggered by an onClick of a button. I want to show something to the user during the pending of the transaction, but I can't figure out how since the promise returned is already the mined transaction. This is the code: web3js.eth.sendTransaction({ to:...
milonite
1

votes
0

answer
311

Views

Sending erc20 tokens using Web3js

I have tried to send erc20 (Bela) from one address to another got tx id in a result, but this transaction is not appearing in any tx check services and no funds sent from my address. code at the moment looks like this: web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/PKEY')...
1

votes
0

answer
987

Views

Ethereum Web3.js : Intrinsic Gas too low

I have been trying to send a transaction on the Ethereum testnet Rinkeby for the past few days and keep getting this error no matter how much I increase the gas and gwei to. 'Unhandled rejection Error: Returned error: intrinsic gas too low' The data I am sending is:- '0x7b22416e7377657273223a5b7b2...
Chad Blanchard
1

votes
0

answer
210

Views

How to handle a Solidity uint array with web3

I am facing some problems when accessing elements of an array of uints, returned by a Solidity function, with web3 resp. Javascript. The signature of my Solidity function looks like this function getSomeIds() public view returns (uint[]) Now after I created some elements within my contract, and run...
Sebastian Dine
1

votes
1

answer
1.1k

Views

Is it possible to get uint256 value from Solidity using web3.js

So the question is pretty simple. I am calling contract method that returns uint256 value. Is it possible to get that value in JavaScript at all? As far as I understand JavaScript can't work with big numbers and the solution would be to make new contract that returns data as string? Right now I am g...
1

votes
0

answer
106

Views

Smart contracts fallback as a catch all delegatecall

I am practicing some vulnerabilities in smart contracts for my lecture in the university. The contracts that I am practicing on are; contract Company is CompanyInterface { address public ceo; ... function setCeo(address newCeo){ ceo = newCeo; } ... } contract MainCompany is CompanyInterface { addres...
yuzır
1

votes
0

answer
125

Views

Node.JS Smart Contract ERC-20 approve + transferfrom function not working

I tried to do approve + transferFrom function in ERC-20 with web3js I got error focus find below function at contract.methods.approve // File ctest.js var Tx = require('ethereumjs-tx'); var fs = require('fs'); var path = require('path'); var CONWeb3 = require('web3'); var config = require('../...
1

votes
0

answer
348

Views

How to get list transaction detail with web3?

i want to ask about get transaction list with web3js. i used private network, and already got some transaction before. When i check my transaction count, the result is 13 transactions. now i want to get the transactions detail and put to my transaction history table. getTransactionList(){ let web3 =...
1

votes
0

answer
219

Views

web3js call fails on missing contract address

To deploy a contract on my local set up I use truffle. The development network is running by Ganache. Also sending data on to the network from app A is no problem (using truffle/truffle-contract packages). I start this app in the same working directory as I compile and migrate the contracts However...
Crittje
1

votes
0

answer
221

Views

Web3 Async/Await Problems

I'm working on a simple Ethereum project, but since I'm not certain whether the issue I'm having is to do with Web3 or Async/Await, I decided to post this question to both Stackoverflow and Ethereum Stackexchange. I'm using javascript with Web3 for this project. Essentially, I'm running with three a...
Eoin Moloney
1

votes
1

answer
314

Views

Web3.js sendSignedTransaction gives “Error: Failed to check for transaction receipt”

I am using web3js v1.0.0-beta.34 to send signed transactions to a geth node Geth/v1.8.13-unstable-2e0391ea/linux-amd64/go1.10.3 in a loop. Problem: In the initial iterations of the loop, Node.js prints the transaction hash to console. But when the loop has been running for more than a handful of sec...
Nyxynyx
1

votes
0

answer
68

Views

Dart Project with RequireJS

I am trying to include web3.js into my Dart project. I am trying to do this via requirejs I've created a requirejs config, which appears to load a valid web3 instance except, now my dart code never initializes! It appears that the requirejs main.js prevents my main.dart from executing. Could really...
Simon Rubin
1

votes
0

answer
49

Views

Function call creates contract?

I am using a NodeJS backend to call a payable smart contract function. The simple function, however, are running out of gas on Rinkeby when I give the max possible. It should be calling a function, but instead it is creating a contract. Why is this? Main code: var privateKey = '..' var nodeWalletAdd...
Ryan Cocuzzo
1

votes
0

answer
227

Views

TruffleHDWalletProvider Alternative That works with Websockets

I'm currently working on a dapp that requires a backend, and event-listening. I've setup web3js with a infura websocket on the rinkeby network but I'm having a hard time setting up my accounts(using a mnemonic) into web3js. So right now the event listening works but I can't sign transactions with m...
Luis Osta

View additional questions