Questions tagged [web3js]

Javascript API and library for Ethereum To develop applications on Ethereum, you can use the web3 object provided by the web3.js library. Under the hood it communicates to a local node through RPC calls. web3.js works with any Ethereum node, which exposes an RPC layer. https://github.com/ethereum/wiki/wiki/JavaScript-API

1,265 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
70 views

Can't call a function in a contract, returning something from another contract

I use private geth + web3js (in truffle this works good) Here is an example worked as expected: the first contract: pragma solidity ^0.4.24; import "./Second.sol"; contract First { Second ...
2
votes
1answer
174 views

Transmit array as first parameter in web3.js

When I develop in solidity combined with web3.js, I face some problem recently. I create a contract code below //setContractDetail(index,bool isConsentItem,uint8[] detailItems) function ...
2
votes
0answers
80 views

Why is getCode so slow? And is there a better way to find out if an address is a contract?

I've been using Web3's getCode call to find out if an address is a contract, but it significantly slows down my application when I add it, even when I try regular ways to speed up queries (running in ...
2
votes
1answer
237 views

Reliable way of listening to events on frontend

I make a web application, that needs the events from my contract to initialize it's state. I was using infura websocket provider, but it seems to lag a lot and close the connections unexpectedly ...
2
votes
0answers
92 views

Estimated gas is always low

web3.eth.estimateGas is always calculating low gas for the transaction. Here is a reference to a trasaction in ropsten. https://ropsten.etherscan.io/tx/...
2
votes
0answers
298 views

Using Web3 v1.0.0 in a web application: issue with XHR2

I am building a simple Vue-based web application which uses Web3 v1.0.0 (the latest version available). Currently, I'm struggling to make something as simple as the following run: import Web3 from '...
2
votes
0answers
151 views

Initialize Metamask from front-end use of Nodejs

Building a simple ERC-20 Token payment screen for a simple shopping cart. I am having an issue figuring out how to use Metamask to allow others to make secure payments. As we dont have access to other ...
2
votes
0answers
386 views

How to sign transactions using metamask while developing in nodejs?

I am developing an application in nodejs. I need to interact with my smart contract and also want to sign the transaction using metamask as I don't want to manage they keys. I copied the following ...
2
votes
0answers
208 views

miner shows 0x0000000… while getting block details using eth.getBlock()

I have created a private ethereum POA network using a bootnode and 6 nodes , of them 3 are miners .But every time i do a successful transaction over network , the miner returned by the getBlock of eth ...
2
votes
0answers
33 views

Data Scientist wanting to simulate a DAO on private network, unsure of where to begin

My apologies for such a broad question, I couldn't find anything remotely similar to my case and I've got lots of questions - I'll try to narrow the scope down here. Premise: I'm a data science ...
2
votes
1answer
264 views

Exceeds block gas limit error to call view functions

With solidity view function, you can specific the amount of gas to use. My understand is since it is not a state changing transaction, all the gas cost is not charged for, and the client should be ...
2
votes
0answers
279 views

Comparing solidity sha3 with web3 sha3 inside smart-contract

The problem is that sha3 in solidity returns bytes32 and I have a string returned from IPFS by oraclize, and if hash calculated in solidity and returned to web3js (bytes32 got interpreted as a string) ...
2
votes
0answers
235 views

Async/Await problems with web3.eth.getAccounts

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 ...
2
votes
0answers
43 views

Authenticating accounts in Ethereum using web3js

Is a there a way to authenticate accounts in Ethereum using Web3js? Or if there are any other ways to authenticate accounts? We are building an application where users can register in our system. ...
2
votes
0answers
238 views

Truffle deployment with metamask to ganache leads private key error

I'm using Truffle, web3js and Metamask to build a webapp. I'm using ganache for local testing. I'm trying to deploy a contract with import TruffleDeployer from 'truffle-deployer'; import ...
2
votes
2answers
104 views

Deploying contract using web3js fails

I am trying to deploy contract using web3js in nodejs on ganache cli test server, but it fails with error as follows : D:\Thrive\PoC\NodeWebAPI\node_modules\web3\lib\web3\contract.js:149 ...
2
votes
2answers
3k views

How to get transaction failed reason with transaction hash with web3?

I'm trying to get transaction failed reason with transaction hash with web3? I have checked getTransactionReceipt() method { blockHash: '...
2
votes
1answer
311 views

subscription not happen on geth+websocketProvider in web3

I have started geth node (connect to ropsten testnet) on my local OSX system. Command: geth --testnet --fast --bootnodes "enode://...
2
votes
1answer
1k views

How to unpack/decode parameters encoded with web3.eth.abi.encodeParameters in Solidity?

My client app (nodejs) packs some arguments to pass to a smart contracts as bytes _data (similar to ERC223 calls with fallback). I pack the arguments in my JS client like this: const packedArgs = ...
2
votes
1answer
36 views

Automatically determine the use of call or sendTransaction based on the method type

In web3.js version 0.x: The web3 module automatically determines the use of call or sendTransaction based on the method type. So for example, instead of doing: myContractInstance.myMethod.call(...) ...
2
votes
0answers
35 views

Elements disappearing from array

I have a smart contract with the field bytes32[] public listSlas; which contains a list of sha3 hashes. On top of the smart contract, I have a webapp which needs to retrieve the content of that list (...
2
votes
1answer
286 views

Error on transaction submission: insufficient funds for gas * price + value - web3 v1+

I am trying to submit a transaction via web3 and getting the following error: Error: Returned error: insufficient funds for gas * price + value. Here is my code: console.dir(txParams); const tx = ...
2
votes
1answer
338 views

Transfer ERC20 token in mainnet with web3js(succeed in ropsten, failed in mainnet)

I want to transfer some ERC20 tokens in ethereum. I did some preparation work and tried in ropsten, it succeed. Then I changed the used api, wallet address, httpProvicer, contract address, and ran the ...
2
votes
0answers
122 views

How to implement a payment on a web page using MyEtherWallet?

I have seen a few solutions regarding implementing a payment (like donating) on a web page using MetaMask. But I really want to know if we can do that same payment on a web page with MyEtherWallet ...
2
votes
0answers
71 views

Programmatically unlock certain accounts with Parity?

Using geth it is easy to send transactions from multiple accounts but I do not know how to do this with Parity. I do not want all accounts unlocked. I do not want any account unlocked when it is not ...
2
votes
0answers
685 views

web3.eth.sendSignedTransaction - transaction not located

I am using web3.eth.sendSignedTransaction and infura.io on mainnet. I want to call my smart contract's whitelisting function. I have no problems calling this function directly, however, when using ...
2
votes
1answer
391 views

Healtcheck on Websocket

I've looked through the documentation and haven't found that to be helpful. I would like to know the best way to do a healthcheck on my websocket connection to geth (Yesterday, I found out that I did ...
2
votes
1answer
54 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....
2
votes
0answers
312 views

Parity syncing status for smart contract events with warp

So I'm trying to find the fastest way to fully sync a parity node in order to get all smart contract events, not just account states. The problem I've found is that when parity has warp syncing ...
2
votes
0answers
389 views

web3.js or eth.js?

After receiving the warning: MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider I attempted to use eth.js But I am not convinced that it is production ready. ...
2
votes
0answers
210 views

Web3 js events not listening after 5 mins of idle time

My contract is deployed on ropsten infura test-network and that contract has events which gets fired when there is some transaction. contract file function functionName(address from, address ...
2
votes
1answer
428 views

How to change block generation period?in POA private ethereum blockchain

my genesis.json like that: "config": { "chainId": 333, "homesteadBlock": 1, "eip150Block": 2, "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "...
2
votes
1answer
273 views

Why would Ganache behave differently depending on geth, web3j, web3js and web3.py?

I have a smart contract token deployed in a Ganache instance. My dapp written with React and web3.js shows the same 10 accounts for eth.accounts as running the same command in the geth console. If I ...
2
votes
0answers
829 views

OPTIONS http://localhost:8545/ net::ERR_CONNECTION_REFUSED

I'm getting this error in Console OPTIONS http://localhost:8545/ net::ERR_CONNECTION_REFUSED ,Error: Error: Invalid JSON RPC response: "" when trying to execute this piece of code from a webpage on ...
2
votes
0answers
156 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-...
2
votes
0answers
90 views

Can a view function from a funded smart contract execute a send() transaction on an external contract?

I'm creating an open source voting app with a Node.JS front end. I'm hoping I can create a smart contract that can use funds allocated to it at creation time, so that participating voters don't have ...
2
votes
2answers
461 views

How to deploy a smart contract in a server?

I have developed a smart contract and compiled it with solc and bin and abi fils have been generated. Now, I want to deploy this contract using web3js in a linux server. How can I do it?
2
votes
1answer
69 views

How does the large-scale crypto trade platform , just like Binance or Bittrex , track ETH and Token transfer in their every account over time?

I wrote some simple code with web3js to track an address/account's transaction in real-time. It works, but I think it is in poor performance or could consume too much cpu resources. sample code ...
2
votes
0answers
2k views

Web3 - how to send transaction with some data and include Ether at the same time?

Using web3 0.20.3 I want to call function and send some Etherium at the same time. JavaScript Contract = web3.eth.contract(ABI); Instance = Contract.at('0x162b74ea16da6ae9d7f7b349eaeab2fcadf4e835')...
2
votes
0answers
1k views

SOLVED - sendRawTransaction (no) errors, valid tx, not found when scanned

I have a method that is supposed to create a transaction, send some wei and validate. When looking around I red that you can use infura.io. I also checked that you need to use raw transactions because ...
2
votes
2answers
458 views

Using Web3.js, how do I call a function on multiple instances of a contract and then store their results in an array?

Using Web3.js, how do I call a function on multiple instances of a contract and then store their results in an array? I've tried .map and .forEach, but they don't return the objects I expected. I am ...
2
votes
0answers
354 views

ethjs - call function with multiple parameters

In my smart contract i have two functions: function getPawnOfSponsorship(address invitedPerson) public view returns(uint) { return (pawnList[msg.sender][invitedPerson]);} function ...
2
votes
0answers
138 views

(1) Parity: why does syncing fall behind, (2) Why are events missing events because of (1)

Background: I have multiple parity nodes setup on Digital Ocean and AWS and event watchers attached to these nodes. I also have a service to query block numbers and compare versus etherscan's current ...
2
votes
0answers
26 views

How to add contract to a Mist account without GUI?

I'm new to Ethereum. I've followed a tutorial to deploy my contract by using web3.js and solc, then I got the abi and contract address. I'm thinking how I can add the contract to my Mist account ...
2
votes
0answers
98 views

Unable to update contract variables

I have this contract pragma solidity ^0.4.20; contract cntrct { uint public testVal; function runF() payable public { testVal += msg.value; } function reader() public ...
2
votes
0answers
55 views

Does the web3.eth.contract.new error object has a transactionHash?

Does the web3.eth.contract.new error object has a transactionHash? https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract I couldn't find anything about how the error object is ...
2
votes
3answers
264 views

Given transaction hash, how to proof that it was a successful erc-20 token transfer using web3?

I have a transaction hash and an RPC access to fully synced node. How to check if the token was actually moved? The transaction might be old, so there is no point in querying the contract. If I ...
2
votes
2answers
107 views

How does Smart Contract client work?

I don't understand how a client works. I try to explain my doubts. Since a client in the classic client-server paradigm is a lightweight application, I don't understand how this application can use ...
2
votes
0answers
230 views

Arabic letters not read by web3.toUtf8

I am using arab letters in bytes32 data stored in a smart contract, when reading the data and converting to utf-8 with web3.toUtf8() i get errors like unknown utf character or Invalid continuation ...
2
votes
0answers
642 views

web3 1.0.0-beta example for etherscan websocket?

Does anyone have a working JS example for wss://socket.etherscan.io/wshandler? Or any alternative websocket providers, besides Infura? The reason I'm looking for Infura alternatives is it fails for ...

1 2
3
4 5
26