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
1answer
394 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
0answers
742 views

web3.js Error: the method personal_listAccounts does not exist/is not available [duplicate]

Code: var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); var sender = web3.eth.accounts[0]; console.log('Sender: ' + sender); web3.personal....
1
vote
2answers
3k views

Unable to npm install web3 on Windows 10

I followed every thing on this page : https://medium.com/@PrateeshNanada/steps-to-install-testrpc-in-windows-10-96989a6cd594 Except step number 5 where my Node.js version is 8.10.0 instead of 8.10.2 ...
1
vote
3answers
806 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
1answer
430 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
336 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
949 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
1answer
345 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
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
2answers
291 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
3answers
4k views

Send payment from wallet using web3

How can i send payments from my ubuntu ethereum node to any address? Is there any working example, that may help me to get this done? CODE EDITED var Web3 = require('web3'); var Tx = 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
0answers
94 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
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
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
1answer
109 views

Bundling web3js does not seem to work (Metamask app)

(This is a follow-up question from here.) From the Metamask developers faq it is stated to "bundle the version of web3 that is used during development". So I downloaded a web3.min.js version 0.20.6 ...
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
246 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
115 views

Insufficient funds when using 'signTransaction' but not when using 'unlockAccount'

I am trying to execute a transaction on a private network, using my account. The general flow: Web3.js --> Parity node --> Private network The transaction: Invoke a method in a contract ...
1
vote
1answer
242 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 ...
0
votes
2answers
391 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. ...
0
votes
1answer
25 views

Deposit event is not call while contract get token

My contract pragma solidity ^0.5.0; contract Transfereventaction { event Deposit( address indexed _from, bytes32 indexed _id, uint _value ); function deposit(...
0
votes
1answer
50 views

How Do You Parse Web3 Retuned JSON Objects of Events?

I am using Web3 1.0 to listen to events from a contract like this: tokenContract.events.AddressList({ fromBlock: 6020474, toBlock: 'latest' }, (error, events) => { ...
0
votes
1answer
80 views

How does Ethereum Smart Contract work on Mobile Client

I want to deploy a smart contract on server and interact with it using mobile client. I'm not familiar with how does that work but after some research, I found something like below: If we compare ...
0
votes
0answers
46 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
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
1answer
85 views

How to connect with Metamask and Smart contract?

I am ready with my frontend design. I have only 3 files HTML, CSS, and JAVASCRIPT. So, I didn't create any project or DAPP to have other files. Now next step is to connect with metamask and smart ...
0
votes
0answers
193 views

Cannot sign a message with web3js (invalid from address)

So I am trying to create a signature of a string, but I cannot do that, as I always get error stating MetaMask - RPC Error: Error: WalletMiddleware - Invalid "from" address. (code: -32603). I am ...
0
votes
0answers
62 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
2answers
716 views

truffle/web3 event listeners returns nothing

We have an event being triggered in a contract and our listeners on the client cant receive the return value. https://gist.github.com/stupeters187/9529b54fe0d48ee606ad06ced6b16031 Update: metamask ...
0
votes
0answers
148 views

Error: The data field must be HEX encoded data

I am trying to make a simple dApp by using a tutorial. I am using the following command ; npm install ganache-cli web3 so that we can use web3 to get fake ethereum nodes/accounts by connecting it ...
0
votes
2answers
71 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
1answer
105 views

Problem with meteor server side call to Ethereum node

I try to interact with Ethereum node via web3 lib. (meteor add ethereum:web3) Meteor 1.5.4.1 lib.js if (typeof web3 === ‘undefined’){ web3 = new Web3(new Web3.providers.HttpProvider(‘http://127.0.0....
0
votes
1answer
113 views

How to deploy Smart Contracts With Web3 Using Async/Await?

This is my Javascript code. I keep getting an error that states Error: No privateKey given to the TransactionSigner. at TransactionSigner._callee$ (/Users/payton/WebstormProjects/Esgro_DAPP/...
0
votes
2answers
506 views

Why is string getter returning an empty response?

This is a sequence of another question I asked. I have the following contract contract User { string publicKey; function setPublicKey(string _publicKey) onlyOwner { ...
0
votes
1answer
482 views

Proper way of using allEvents()

I'm trying to get all events for a contract: let events = token.allEvents({fromBlock: creationBlock, toBlock: 'latest'}, (err, res) => { try { let result = events.get(); ...
0
votes
1answer
698 views

Unlock remote account

I have smart contract deployed that accepts funds (via fallback function function() payable { ... }). Also I have frontend using web3 to send funds. When I tested it with local node (and JSON wallets ...
0
votes
2answers
2k views

Web3.js browser version only

I want to create a simple page to interact with my deployed contract. I don't want to use Node.js. I want to use html + web3.js browser version. I got a link: https://github.com/ethereum/web3.js/tree/...
0
votes
2answers
520 views

using abi generated by truffle in DApp

I use truffle to deploy contract to ganache network. I like to use the json file generated by the truffle in the DApp rather writing messy ABI into it. I tried the below piece of code and it gives ...
0
votes
0answers
953 views

passing address as a function parameter in web3

I've this contract that gets 'address' type variable as input parameter to function and sets it to a variable. This works fine in Remix. I'm trying to call this using web3js and am getting an Uncaught ...
0
votes
3answers
2k views

calling smart contract functions from app.js

I deployed a smart contract to ganache network using truffle from account1. The code of smart contract is as follows. pragma solidity ^0.4.0; import "./strings.sol"; import "./safemath.sol"; ...
0
votes
2answers
591 views

How to send transaction/call function from server-side?

After an event emits from my smart contract and I hear it server-side, I want to call a certain function in the smart contract and pass it some information to use. I'm wondering how you place a ...
0
votes
2answers
986 views

Error: Invalid JSON RPC response: “” using infura

My code: const contract = require('truffle-contract'); const fs = require('fs'); const HDWalletProvider = require('truffle-hdwallet-provider'); const Web3 = require('web3'); const fileContents = fs....
0
votes
1answer
125 views

truffle-contract: cannot test method before real consume ether method

I am using truffle-contract for connecting between frontend and smart contract. Currently, I can call method on smart contract and can consume ether successfully. const result = await instance....
0
votes
2answers
402 views

web3 detect/listen to events if someone send ether to addresses

I need to constantly keep running some code to detect if someone has in the past minute sent some ether/token to a lot of addresses, is there better way to do than https://ethereum.stackexchange.com/a/...
0
votes
1answer
550 views

Cannot connect to testrpc

I have a testrpc running on a virtual machine (Ubuntu 16.04) and it works properly when I interact with it using the truffle console. My only goal is to call a smart contract that simply sends ether ...
0
votes
1answer
42 views

how to get the real balance of ETH by eth_getbalance

as I know, the transaction should be confirmed by 11 times then it will be done. but when i use eth_getbalance to get the balance ,it will return some fake balance without confirmed. so How can I get ...
0
votes
2answers
313 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
467 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
1answer
353 views

“instance.at(addr) is not a function” in truffle console (access to non-migrated contracts)

I have a setup with one contract that is a singleton and is migrated to e.g. a testnet through the truffle console. This contract "creates" new contracts, which I want to access in the truffle console....