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

Filter by
Sorted by
Tagged with
1
vote
3answers
431 views

When creating a new contract I receive a “contract code couldn't be stored” error but the contract is still created

Sale.new({ from: state.account, value: value, gas: 4000000 }).then((instance) => { // do something with instance }).catch((err) => { alert(err) }) When the above code runs I sometimes ...
1
vote
0answers
76 views

Error: Cross origin null forbidden : ---Problem in downloading Open source contracts from Etherscan.io

UPDATED: I am trying to download source code of open source verified contract from Etherscan.io. Here is my procedure as directed by Ann. 1. Download CSV file of captioned contracts. 2. Write ...
1
vote
0answers
249 views

Catch a “require()” in frontend

I was trying to validate a transaction with some conditions on contract level and was wondering if it was possible in any way to give user feedback in the frontend if a require() fails - aka if it ...
1
vote
0answers
83 views

Ganache is not showing any events

I have a contract method which emits events but ganache seems not to catch any events. I say this because when I deploy my contract on ropsten the events are being caught fine but only in ganache I ...
1
vote
0answers
73 views

error in WebSocket connection

error : browser-sync-client.js?v=2.26.3:15 WebSocket connection to 'ws://localhost:3000/browser-sync/socket.io/?EIO=3&transport=websocket&sid=mW3 please i need help on this. i was getting ...
1
vote
3answers
75 views

Web3.Utils - WeiToEth and EthToWei Conversion choking on decimals

I have the following two helper functions. It was based on a course I'm going through, so I didn't think I would have to debug them. I don't understand why it works with whole numbers, but not with ...
1
vote
1answer
385 views

Accessing/Modifying Options Parameters in Contract

I'm using truffle and metamask to deploy a very simple contract that enables the transfer of ether from one test account to another. How do I use my JavaScript file to access the options parameters ...
1
vote
1answer
1k views

When is a transaction callback called?

Is the callback of a myContractMethod.sendTransaction(/* ... */) called as soon as the the transaction is sent to the network or once it is mined? Related posts Here are some related references I ...
1
vote
0answers
280 views

Mocha timeout, not resolving promise of large array from method.mymethod.call()

I'm trying to test a contract getter method that returns a large array. I am testing using the web3 library in Mocha with ganache-cli provider. My contract deploys alright, but trying to call the ...
1
vote
1answer
487 views

How to scan ether transfer from smart contract to my addresses programmatically?

Correct me if I am wrong, the transaction receipt contains only the log of contract events. So we can only use it to examine the internal transaction that produces a event. How about ether transfer ...
1
vote
1answer
1k views

Synchronous requests are not supported by the IPC provider

I was trying to connect to my node via IPC using web3_ipc. But i got hit by: You tried to send "eth_getBalance" synchronously. Synchronous requests are not supported by the IPC provider. My code is ...
1
vote
2answers
319 views

Invalid Op Code - passing bytes32 array to a contract method called from another method of another contract

I've been banging my head on this one for some hours, I'd appreciate any help :) This is a final edit to clearly state the issue: Is there a proper way to pass a bytes32 array to a method on contract ...
1
vote
1answer
934 views

web3.js error: Cannot read property 'providers' of undefined

What is problem of this simple html / JavaScript / ethreumjs / web3.js code? <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title&...
1
vote
1answer
489 views

Getting 'base fee exceeds gas limit' on a transaction which requires a small amount of gas

I have the following contract: pragma solidity ^0.4.24; contract MyContract { address public owner; bool public unlocked; constructor() public { owner = msg.sender; ...
1
vote
2answers
238 views

How to safely node.js script which uses geth, without risking external actors accessing it with --rpc?

So if I want to write a script which uses geth and web3, the first that comes to mind is starting geth with --rpc enabled. Will this risk the wallet being accessed from outside? Is there a way of ...
1
vote
3answers
3k views

How to build and sign a transaction to deploy a contract

I am trying to generate a transaction to deploy a smart contract on the chain and to sign it with web3js. My problem is that I have no idea how to build the transaction object needed for the ...
1
vote
0answers
371 views

Reading require() error reason in web3.js client [duplicate]

Solidity version 0.4.22 introduced error reasons for require and revert (https://github.com/ethereum/solidity/releases/tag/v0.4.22). I tried using them, but it looks like they only work when I'm ...
1
vote
3answers
894 views

Using ganache-cli provider causes “Error: Provider not set or invalid”

I'm trying to write and run tests for my smart contract and I get this error: "Error: Provider not set or invalid" Smart contract code: const assert = require('assert'); const ganache = require('...
1
vote
4answers
2k views

Connecting to local blockchain using web3 and HttpProvider

I wrote an application to connect to the local blockchain. Here is the code: var Web3 = require('web3'); var contract = require('./PublishService_abi.js'); var PublishServiceContract; var web3 = new ...
1
vote
1answer
271 views

Web3 sending TX times out after 280 seconds because network lag

When I submit a transaction via web3 and metamask, it will await 280 seconds before timing out and returning the transaction receipt. How can I catch this error and handle with it so that my app can ...
1
vote
1answer
346 views

How to return array from struct using drizzle?

So I have been wondering how to return an array from a struct in drizzle, I can make multiple calls using web3, but it is kinda complex and would like a simpler approach. A simplified contract is ...
1
vote
1answer
861 views

Send signed transaction from nodejs to private SmartContract using webjs in Quorum network not working

Context I have a quorum network mounted following the example of 7nodes. In node 1 I have deployed a smart contract privately, putting the public key of this ("BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+...
1
vote
1answer
85 views

Infura - Signing transactions in a multi-user application

I hope this question is not a duplicate. Since I'm using Infura as a full node, I need to send raw transactions by signing them. In a multi-user application how would my application on the server-...
1
vote
2answers
1k views

New web3 method to request account access from dapp browser, no request

Since metamask communicated that they will no longer inject web3 by default (https://medium.com/metamask/https-medium-com-metamask-breaking-change-injecting-web3-7722797916a8) I tried to use their new ...
1
vote
3answers
1k views

authentication needed: password or unlock

We're using Microsoft Azure, and NodeJS on the server. When we address Microsoft Azure via NodeJS, sometimes we get the 'Password or Unlock' error. But when we use Truffle and address the same setter, ...
1
vote
0answers
100 views

Multithreading in web3.js [duplicate]

Is it possible to run concurrent tasks using web3.js and an Ethereum client? For example, say we have the following code to iterate through a number of blocks: var startBlockNumber = 0; var ...
1
vote
2answers
1k views

Cannot find module 'web3' meteor

I am trying to use the web3 API through my project in meteor. I saw an example that included web3 the following way: <script type="text/javascript"> var Web3 = require('web3'); var web3 = new ...
1
vote
3answers
314 views

Sign Message Using private key instead of kesytore

I need to sign data using the private key and not keystore file. I can get data using: var hash = "0x" + ethereumjs.ABI.soliditySHA3( ["address", "uint256", "uint256"], [web3.eth....
1
vote
1answer
252 views

Signing a transaction server-side

I want to sign every transaction server side from the same address/wallet through web3. What's the best way to tackle this? Do I need to: first use web3.eth.sendTransaction Use web3.eth.sign to sign ...
1
vote
1answer
383 views

Account balance does not decrease after send ether

For example here is my example function in smart contract: function adoptCreeptomas(uint256 beastQuantity, address referrer ) public payable whenNotPaused { msg.sender.transfer(50); } And then I ...
1
vote
1answer
4k views

getting error nonce too low , but nonce is proper stuck since one day

I am working with web3.js since sometime now , but now i am stuck with nonce too low error , the nonce is proper also i have checked private key and other addresses , they also seem to proper , ...
1
vote
0answers
185 views

metamask and infura - Managing and signing with private keys

I am using Infura as a node for my DApp so I need to send raw transactions by signing them. These transactions can come from multiple users of an application so each user must sign and send a raw ...
1
vote
1answer
372 views

what happens when require() is false

From what I under stands when the condition in require() is not met solidity performs revert operation. Right? What I want to know is how can we handle this in web3. That is if i have a function in ...
1
vote
2answers
102 views

Can anybody Point out the Difference between Web3.eth.sendTransaction and web3.eth.signTransaction?

Do we need to sign the transaction by web3.eth.signTransaction after initiating transaction via web3.eth.sendTransaction. for example: when I do: web3.eth.sendTransaction({ from: accs[0], ...
1
vote
1answer
366 views

Get a balance of an address at a certain block

We are facing a problem with the web3.eth.getBalance(address [, defaultBlock] [, callback]) ( here the doc ). The function works well for last block, or for a small number of blocks in the past, but ...
1
vote
1answer
1k views

Web3J: TypeError: MyContract is not a constructor

I am simply trying to call my contracts on a private blockchain from a nodeJS app after a call from the browser but I keep getting this error in my node: 2017-03-01T21:07:34.782560+00:00 app[web.1]: ...
1
vote
2answers
2k views

Creating an account using web3js or web3j

I am trying to create account on ethereum private network using web3js from front end. I have written the below lines in my js file. The createAccount() gets called from an HTML page web3 = new Web3(...
1
vote
1answer
91 views

why are return values only True or False

Return values from functions which create transactions, can only be true or false, at least when you check them post transaction (e.g., with web3 through receipt). However, when functions call each ...
0
votes
1answer
489 views

JSON RPC + web3: Subscribe to Solidity events

When using web3 and the JSON RPC, is there a way to subscribe to Solidity events? For instance, I want to subscribe to every event Transfer(address indexed from, address indexed to, uint256 value); ...
0
votes
0answers
94 views

Web3 & Solidity - Automatically read ABI and Create Contract

Is there a way to automatically create a new Solidity Contract - from within a web3 JS file using the .json file created in a project's build folder after each compile? I have already figured out how ...
0
votes
2answers
321 views

Do I have to run geth locally to access Rinkeby via web3.js?

I have used truffle to a migrate some contracts to a local instance of geth that points at Rinkeby. The problem is that I'm behind a firewall, with little hope of getting port 8545 open, so now I can'...
0
votes
1answer
869 views

:Contract has not been deployed to detected network (network/artifact mismatch) tried all the links but did not help

my APP.js code App = { web3Provider: null, contracts: {}, account: 0x0, init: function() { return App.initWeb3(); }, initWeb3: function() { web3.eth.defaultAccount=web3.eth....
0
votes
1answer
68 views

the tx doesn't have the correct nonce. account has nonce of: 12 tx has nonce of: 3 - Ganache

I am trying to run my simple contract with different parameters (in the form of encoded signatures) and intends to put multiple transaction into ONE block. If I set Ganache GUI with automine option, ...
0
votes
0answers
94 views

Web3 Websocket Connection To Infura Rinkeby Ropsten

This is my Javascript code. I keep getting an error that states (node:30062) UnhandledPromiseRejectionWarning: TypeError: privateKey.startsWith is not a function I am using node 12.1.0 & ...
0
votes
0answers
29 views

Cant call solidity function from app.js while sending transaction

Solidity function As i want to call function so that oraclize can send query function betOnTeam(uint team) payable public { update(); emit LogInfo("Oraclize query was NOT sent, ...
0
votes
2answers
27 views

Returning a value from an external function

I have in a contract: function createCourt() external returns (uint256) { uint256 _id = ++nonce; courtOwners[_id] = msg.sender; return _id; } Now, when I try to call ...
0
votes
1answer
1k views

Web3 sendSignedTransaction Transaction cost

I'm new to Ethereum world. I've just manage to create an example that calculates transaction fee and sends a signed transaction without a contract using Web3js library. My issue is that my test ...
0
votes
0answers
41 views

web3.utils.toHex but combined, hex concat?

I'm currently working with bytes in Remix. The goal I wanted to achieve was to put variables into bytes in one function, copy bytes, paste bytes to another function as a parameter and unpack these ...
0
votes
2answers
147 views

how to get contract address after its been mined with web3.js

I have tried to deploy a SmartContract from web3.js node library, I am getting a transaction hash from it but how would I get the contract address after It's been mined by a miner? here is my code ...
0
votes
2answers
403 views

Why is my transaction not performing?

I wrote the following script to send Ether. I can't figure out why the balance is still the same after I send out the Ether. I re run this script multiple times but nothing changes with the balance. ...

1 5 6 7 8 9