Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
0answers
4 views

how to format contract params expecting bytes32?

I have a contract that expects a bytes32 parameter called "topic" which I pass in like this: web3.utils.hexToBytes(web3.utils.stringToHex("Weather")), I also tried web3.utils.stringToHex("Weather") ...
0
votes
0answers
6 views

How to make ECDSA signature of (value_1, value_2) with web3 on Python?

I want to call function with four parameters. I know how to create two of them, but the last two is the r and s components of ECDSA signature of (param_1, param_2). I tried this (and a lot of ...
3
votes
1answer
322 views

Recover address from signature using web3j

I have signed a data string using the following code snippet in web3js var data = "hello world"; web3.personal.sign(web3.fromUtf8(data), web3.eth.accounts[0], function(error, result) { if (!...
0
votes
1answer
16 views

“web3.eth.accounts” doesn't output account address

I follow the instruction video "Code Your Own Cryptocurrency on Ethereum (Full)" from Dapp University on youtube. What is different when i use web3.eth.account. Here is from tutorial Here was i do ...
1
vote
1answer
1k views

How to pass a parameter to a function in web3?

I have a button that executes a function in a solidity contract like this: <a href="#" onclick="solidityFunction()" class="btn btn-primary btn-block">Execute Function</a> The ...
0
votes
2answers
926 views

vm exception while processing transaction : out of gas

I already read the other topics with the same error, but that didn't solve my problem ... When I try to communicate with test rpc between my web interface with my smart contract I have always error "...
0
votes
1answer
9 views

Is it possible to deploy a contract from python web3 if I have the ABI and bytecode from Remix?

Question says it all. I have a contract that I've written and compiled via Remix. I've dumped the ABI and Bytecode into local files, and I'm reading them into my python application. I'm following the ...
1
vote
2answers
24 views

How do I recover the address from message and signature generated with web3.personal.sign?

Is there any way to do that? To recover address in nodejs server-side from signature and message after it was signed with web3.personal.sign client-side? I tried this: https://ethereum.stackexchange....
0
votes
0answers
14 views

Get RPC URL / IP of Metamask's current provider

Suppose I have multiple copies of the same dapp running on different servers which do not directly communicate with each other, for testing purposes, and can manually interact with different dapp ...
0
votes
1answer
9 views

ganache-cli: how to persist new created accounts

I start my service by: ganache-cli -d --gasPrice 0 -q --db=./db This persists my 10 defaults created accounts, but when I create new accounts using Web3: web3.eth.personal.newAccount('password') ...
2
votes
1answer
194 views

Is the signature generated by “web3.personal.sign” different with “web3.eth.sign”?

Are web3.personal.sign and web3.eth.sign difference in value of generate signature ? Or both of them generate an equal output ? I could test web3.eth.sign using testRPC, however web3.personal.sign ...
0
votes
0answers
8 views

Ethereum testrp connection

I'm using web3 in an android app and I'm to get the provider to be able to call the function within the web3 library to work but fails. This is the error i get Attempt to invoke virtual method'...
1
vote
2answers
74 views

web3py encode method call parameters

I want to encode the parameters needed to call a contract method. In web3js I would use web3.eth.abi.encodeParameters(types, values); I need to do the same in python I found a function called ...
0
votes
1answer
15 views

Metamask not returning current account address with web3js and ganache

How to return the address of my current account from Metamask? I have tried with web3.eth.getCoinbase() but this and metamask has two different address. web3.eth.getCoinbase() returns me the first ...
1
vote
3answers
299 views

Calling functions in MultiSigWallet with onlyWallet modifier

I've deployed a MultiSigWallet from ConsenSys. How can I call functions with onlyWallet modifier? modifier onlyWallet() { if (msg.sender != address(this)) revert(); _; } Does the ...
0
votes
0answers
21 views

How long does a smart contract typically take to complete?

I have been developing an application using a smart contract, the application is similar to this one: https://www.ethereum.org/crowdsale I went ahead and initiated a request, below is the codebase ...
0
votes
1answer
14 views

This contract object doesn't have address set yet, please set an address first

I am in the final stages of developing an application that is similar to https://www.ethereum.org/crowdsale, however, when I click on the create button, my Metamask modal is not popping up to ask me ...
1
vote
0answers
8 views

During gas-free transaction get an error “No relay responded! 4 attempted, 4 pinged”

I did all modification related to this instruction https://github.com/tabookey/tabookey-gasless However, when I'm trying to write some tests it fails and provides me the following error Error:...
1
vote
1answer
489 views

How do you change a contract value using ConciseContract in web3.py?

In my contract, I expect that my_contract.a() will not make any updates to values in the blockchain, but my_contract.change_value(new_val) should. However, change_value() is not making the change I ...
0
votes
1answer
14 views

How does the MetaMask work with gas?

I have some web application based on Ethereum. This is how I call some function from a contract: contract.doSomething.sendTransaction(data, {gasPrice: web3.toWei(10, 'Gwei')}, callback...); This ...
0
votes
2answers
882 views

how to get the token transaction history via web3.js (0.20.6)

set up node.js + web3.js (0.20.6 version) + and using infura for the httpProvider I've figured out and successfully sent erc20 tokens using the web3.js, (after a lot of googling... complete noobie ...
1
vote
2answers
1k views

Out of gas when executing contract via web3 js

I am having a trouble invoking contract via web 3 js in browser. I am using truffle develop and have migrated and run tests successfully. I am also getting the info when I console.log the contract....
0
votes
1answer
925 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
3answers
410 views

How to call a state changing function with web3.js (browser) and remote node?

Solidity Contract: contract MyContract { bytes32 public product; uint public amount; function setOrder(bytes32 _product, uint _reorderAmount,) public returns (bool success); } ...
1
vote
1answer
750 views

Calling event.watch() and event.get() prevents truffle JS tests to terminate

My contract is contract SimpleContract { uint storedData; event SimpleEvent(uint p); // EVENT function set(uint x) public { storedData = x; SimpleEvent(x); // TRIGGER ...
1
vote
0answers
13 views

Transaction sent from web3 cannot reached all transaction to network node

I used one node endpoint to interact with the network. While sending a transaction from web3.js 0.20 to ethereum network, transaction per second (TPS) I achieved is only 28 TPS. I have configured the ...
4
votes
1answer
617 views

Call write function, which doesn't change contract value

I'm new in smart contracts and faced with one problem. After deploying contract to my test local blockchain network, i try to set new value via setter, after that I call get method of contract and it ...
0
votes
1answer
14 views

why do i see input data in the transaction details when i didn't pass it as a data parameter

When I create a transaction like below App.contracts.Soccer.deployed().then(function(instance) { return instance.purchaseShoes(name, age, { from: accounts[0], value: value}); }).then(...
3
votes
1answer
26 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(...) ...
1
vote
1answer
228 views

How to confirm request in Parity

enter link description hereI send a transaction with contract. I use unlock account to account it. It can skip the first confirm. Which is asked to confirm deploy. But it can't skip the second confirm,...
1
vote
0answers
7 views

Ocasional connection refused initializing web3

I have an ethereum web application using web3js 1.0.0-beta.34 on a private network. Most of the times everything works fine. Sometimes the connection to the node through a websocket provider fails ...
0
votes
2answers
1k views

Accessing web3 object in Chrome terminal using React

I am receiving a "not defined" error when trying to access the web3 object in Chrome terminal. My current setup: running testrpc web3 object successfully instantiated in App.js built app using React ...
1
vote
1answer
573 views

Interact with MetaMask via PHP

I can easily interact with metamask via web3 js like this (JS): web3 = new Web3(web3.currentProvider); Is it possible to interact with metamask via php? For example (PHP): $ethereum = new Ethereum('...
2
votes
2answers
418 views

Deploying to rinkeby doesn't work

It seems I have a bit of trouble deploying a contract to testnet through infura this is my code: var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby....
6
votes
3answers
1k views

Can't get Metamask account in javascript

The command: web3.eth.accounts Returns an empty array despite Metamask having one account, how should I be retrieving the accounts in a way that will work with Mist and Metamask?
1
vote
1answer
60 views

Promise not resolved for web3eth.sendSignedTransaction

I am testing whether transactions that I'm signing offline are accepted by the Ropsten network. I'm submitting the transactions using Web3.js (web3@1.0.0-beta.51) as follows: I connect to an INFURA ...
0
votes
3answers
276 views

Sending Signed Transaction returns pending and event:undefined

I am trying to send a signed transaction using web3 1.0 and Infura.io through the browser. When I run it I dont get any errors but the transaction never hits the blockchain so I am confused on whats ...
0
votes
1answer
14 views

How to send ERC20 Token?

I try to send Token based on Erc20. and I can send Ether and something function but i dont know how to use transfer function in javascript like that. function transfer(address _to, uint256 _value) ...
2
votes
2answers
376 views

Cannot read property 'getBlock' of undefined

I'm having an issue with running truffle test on a Javascript test. I get the error TypeError: Cannot read property 'getBlock' of undefined. I am trying to get the time of the latest block by using a ...
0
votes
2answers
30 views

i am trying to send ether to a list of addresses from backend

Below are few lines from the contract in which I am basically trying to send some ether to an array of addresses. Now, when can run this code in remix solidity by replacing "value" to "msg.value". But ...
2
votes
1answer
245 views

How can I use solc solidity compiler on truffle webpack?

When I try to import solc, it raises an error which says: ERROR in ./~/require-from-string/index.js Module not found: Error: Can't resolve 'module' in 'C:\users\bisrat\Desktop\webpacksample\...
0
votes
2answers
23 views

eth.sendTransaction successful or not?

I sent 1 ETH on a private chain from node1 to node2. >eth.sendTransaction({ from: "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b", gasPrice: "5000000000", gas: "21000", to: '...
0
votes
1answer
457 views

web3.eth.sendTransaction sending to random address

I've been trying since near 2 weeks to make my users able to deposit and send ethereum on site. I use geth mostly, and more recently web3.js. I face a very weird issue. All seems well, transaction ...
0
votes
1answer
432 views

Solidity - Ballot Example

I have this following Ballot contract: pragma solidity ^0.4.11; /// @title Voting with delegation. contract Ballot { // This declares a new complex type which will // be used for variables later. // ...
6
votes
1answer
1k views

Adding Wallet using web3.eth.accounts.wallet.add

On web3 0.20.1, I am using Infura to deploy a contract to Rinkeby. This probably requires me to add a wallet to web3.accounts to provide the gas needed. When I ran the following nodejs code, Web3 = ...
1
vote
1answer
30 views

eth-crypto: How can I use the library in the browser?

Has anyone manage to use eth-crypto in the browser? I tried to use browserify but I failed. Any hints, what to do? EDIT: This is what I did (node:10.15.1/npm:6.4.1) 1) Installed eth-crypto (v1.3.2))...
0
votes
1answer
251 views

Deploy contract that requires an ERC20 object in constructor

I am starting an ICO and basing my contract on OpenZeppelin. I am trying to deploy the contract using web3.js and my problem is that in the constructor I need to pass the ERC20 object of my token. I ...
0
votes
1answer
114 views

Difference between window.ethereum and window.web3?

If I log the two functions, I get two objects, that both contain for example selectedAddress, but the structure of the objects seem different. I couldn't find a comparison in the documentation. I ...
0
votes
1answer
25 views

Infura Web Sockets doesn't work on Infura

I have a problem with connecting via Websockets to Infura. I am listening on some events from my smart contract, so when some event is dispatched by calling some method from smart contract, I should ...
0
votes
1answer
261 views

Javascript to display multiple records from a struct

I am trying to build some Javascript using Web3js to list out nested structs. Specifically, I have designed a customer struct through a mapping. I have nested in the customer struct two additional ...