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
5
votes
1answer
1k views

Can you add input data with a token transfer?

I was successfully able to send eth with some message here: 0x4ea3d0ae060aeb08f41fb8ff3e468b7e44092a251ccef118b386136fe6427a64 (little tackier though). I did this from MEW, but saw that it is not ...
4
votes
1answer
586 views

Reading a uint from a mapping keeps returning a random address

I am new to Solidity. I am facing an issue in a simple operation of storing and retrieving data from mapping (uint=> address). I have defined a simple contract: contract test { mapping (uint =&...
4
votes
1answer
700 views

How to get the transaction hash once it is mined?

In JavaScript (web3.js), how do I get the transaction-hash corresponding to a function executed in my smart contract?
3
votes
3answers
3k views

Are there ropsten ERC20 testnet tokens?

I am trying to write an application using web3.js and I want to integrate some ERC20 functionality. But rather than muddy up the mainnet, I'd like to try things on the Testnet first. I see that https:/...
3
votes
2answers
246 views

How to invoke a contract function in the future (under 10 blocks)

This is not a duplicate question, as the alarm contract only allows function calls to be made in the future, over a period of at least 10+ blocks... The current thinking is to just use the alarm ...
2
votes
2answers
643 views

solidity ecrecovery and ethereumjs ecsign return different address

I have a code as follow using web3 0.2 and ethereumjs-util to interact with smart contract. What exactly am i doing it wrong? is it incompatible between ecsign of ehtereumjs with smart contract ...
2
votes
1answer
86 views

Sending a transaction - can I assume that when the 'data' field is missing, the 'gas' field should always be 21000?

I have implemented a function for transferring ETH from my account to another account: async function transfer(to, value) { let options = { from : PUBLIC_ADDRESS, to : to, ...
2
votes
2answers
207 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....
2
votes
3answers
331 views

Event firing before data is actually set

Let's say this is my smartcontract: event NewUser( address userAddress, uint amount ); function addUser() public payable{ require(msg.value <= maxValue && msg.value > ...
2
votes
1answer
469 views

Cannot connect to any ethereum networks using API key

I followed a tutorial about how to connect web3 with ethereum networks. I registered in infura.io and get all the urls. But when I try to connect to any network it is not connecting.When I print web3 ...
2
votes
0answers
732 views

What can I do about an “Invalid sender” contract deployment error?

When deploying a smart contract, I get this message: "Error: invalid sender undefined." See details below. Why is this happening? What do I need to do differently? I wrote the smart contract below ...
1
vote
0answers
252 views

Error: CONNECTION ERROR: Couldn't connect to node (RPC & web3.js)

I am trying to access my Geth node through RPC from my UI (using web3.js) My Geth command is: geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8501 --...
1
vote
2answers
1k views

How to catch JSON RPC exception in front end web3

I have a transaction in contract which "requires" only owner can call. In front end when I call this with accounts other than owner of the contract I want to display an error. Code below doesn't work....
1
vote
2answers
510 views

Following web3.js docs raises TypeError: .once is not a function

I deployed a contract which has a function recordData(bizname, id) function. I have a expressjs api layer. I want to make sure that when the function is called from this api layer using web3 the ...
1
vote
1answer
376 views

How to bundle own web3 version and using Metamask

I am a bit of a javascript noob and have some questions about using web3js and Metamask. My objective (for now) is to display the ether balance as displayed on my Metamask (where I am logged in). ...
1
vote
1answer
595 views

Transaction receipt contains all log entries, but only the last two are decoded by web3

I have a flow which yields 4 events. When I obtain the transaction hash via web3.js, I can see that all 4 events are included in the receipt logs, but only the last 2 events are in the decoded logs (...
1
vote
5answers
1k views

How to invoke functions of Smart Contract from Android phone?

I deployed a smart contract with solidity along with a GUI by Javascript and HTML. This project works well on my computer. Now I want to invoke functions of Smart Contract from Android phone. Is ...
1
vote
1answer
1k views

Web3.js enabled mobile browsers and wallets

What mobile browsers or wallets there exist with proper web3.js support?
1
vote
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/...
1
vote
1answer
743 views

getting error web3.toWei is not a function when testing

i have installed web3 latest version 1.0.0-beta.36. i am using helper libraries which i used from openzeppelin when i am running the test cases using truffle test it shows error as TypeError: web3....
1
vote
1answer
2k views

How to connect web3js to mainnet or testnet?

It might be a very basic question. But here's what I want to achieve: I want to make a web app which interacts with a contract on testnet/mainnet. I can see in the documentation that you have to ...
1
vote
2answers
930 views

How to call my contract's function using sendRawTransaction?

I am trying to call my contract's method using sendRawTransaction. I have a function in my contract updateReading(address consumerAddress, uint32 consumerMeterId, uint64 ...
0
votes
3answers
378 views

Dapp not conecting (through web3) when called from browser which dont have node running on it

trying to connect dapp through browser,when doing the same through the browser on machine which has running geth node is getting connect through public ip (eg :http175.xxx.xxx.xx:xxxxlogin) but the ...
0
votes
0answers
80 views

Are there any libraries/tools for encoding input for data field of web3.eth.call method? [duplicate]

You can call contract functions using web3.eth.call method. Information on which function to call and what arguments to pass to this function is encoded according to the rules that can be found here. ...
0
votes
1answer
425 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
1answer
525 views

“Updated :” How to see “output” of “web3.personal.sign” in “browser”? (“Method personal_sign not supported”)

Note: I updated the html / JavaScript code according to the answer and I used THIS META MASK sample code for web3 provider. However, I receive the same error. I eventually did not understand that do I ...
0
votes
2answers
2k views

Unable to connect to metamask using web3

I have tried everything but just can't get the web3.currentProvider to work. I have metamask installed and working and somehow want to connect the website on the test network. Has there been some ...
0
votes
1answer
309 views

Fetching single account from web3.eth

I'm trying to fetch the first account using web3.eth.accounts[0] using Truffle, but couldn't seem to make it work. I'm using version 0.5.0. I read that the command is deprecated and have to use web3....
21
votes
2answers
2k views

What are best practices for serving a DApp over HTTPS, connecting to an Ethereum node using JSON RPC / web3.js, which by default uses HTTP?

Summary: we're serving an Ethereum DApp from a webserver through HTTPS. The DApp connects to an Ethereum node through JSON RPC using web3.js, which uses HTTP (not HTTPS). How to deal with this in a ...
16
votes
2answers
9k views

Connecting to hosted web3 provider from NodeJS backend

I'm using these instructions from etherchain. Here's a similar question(seems like duplicate, but it's not). The solution provided there doesn't work for me, because I don't have a local ethereum ...
11
votes
1answer
5k views

Error: personal_unlockAccount method not implemented

Using web3 under nodejs I suddenly want to unlock my account before calling a DAO contract function: var Web3 = require('./node_modules/web3/lib/web3'); // dont override global variable if (typeof ...
11
votes
2answers
6k views

trying to use web3-utils but not working

Trying to use web3-utils. I installed the package via NPM , however, I am getting the error that sha3 is undefined.. TypeError: Cannot read property 'sha3' of undefined at C:\block2\deliver.js:...
7
votes
2answers
4k views

How to manipulate data in a Solidity smart contract?

I have a smart contract with some members which should get modified on certain events. For simplicity, let's imagine we have a greeter contract. If I call greeter.greet() in the JavaScript console, ...
5
votes
5answers
2k views

How many concurrent requests can an Ethereum node handle?

This is a fairly simple question which (I suspect) has a more complex answer. I would like to find out that answer now rather than the hard way down the line. How many concurrent requests can an ...
15
votes
3answers
7k views

Using web3 to sign a transaction without connecting to geth

Is it possible to use the web3.js library in a client's browser to let them generate an address and sign a transaction without them connecting to an ethereum node?
9
votes
1answer
2k views

How to check if a transaction is still in the blockchain?

Say we want to confirm that a value transaction tx has reached certain finality, which we define as waiting for 12 block confirmations. We do this to drop the probability of tx getting lost due a fork ...
8
votes
2answers
2k views

Call an arbitrary JSON-RPC method with web3

I want to use web3 to call evm_snapshot (only available on testrpc). This is not in web3's list of methods, but I don't want to have to make an actual http call.
7
votes
3answers
8k views

What is the correct way to access public variable from contract in Truffle: then or standard callback?

There are some similar posts to this but none seem to be able to solve my problem. I have a contract deployed with Truffle running with testrpc. I want to access the value of a public uint variable ...
7
votes
1answer
4k views

Executing custom JavaScript Snippets through Non-Interactive console (geth --exec)

I have a JavaScript snippet to get the latest transaction to/from an account. After starting the geth instance, I did this in the interactive JS console: jsFunction is a function in filename.js &...
7
votes
2answers
2k views

Unhandled rejection Error: Couldn't decode uint256 from ABI

I am working on using a sample Contract using NodeJS, Web3, and Solc but I encountered some error that the given address in the Contract that I've created couldn't decode. Am I doing something wrong? ...
7
votes
2answers
6k views

How can I connect to public chain using web3?

I have used web3 to interact with my private chain by using : web3.setProvider(new web3.providers.HttpProvider("http://localhost:8012")); But How can I connect to Public Network using web3? I am ...
5
votes
2answers
6k views

Send transaction using MetaMask injected web 3

Metamasks injected web3 gives an error when using web3.eth.sendTransaction() web3.eth.sendTransaction({from:web3.eth.accounts[0], to:'', data: // hash to interact with contraact, gas:85000}); What ...
5
votes
2answers
2k views

how to parse the Ethereum Blockchain and save the output to a file? geth console isn't node, right?

I'm trying to parse the Blockchain and extract to a txt file part of the transactions and Addresses to a specific contract (theDAO) for later analysis. I'd like to save the output to a file (.txt) in ...
4
votes
2answers
2k views

Unlocking accounts for a back office app

I'm writing a "back office" app and need a way to unlock an account in an automated fashion. Yes, I know security of nodejs is questionable, but there are ways of solving this. blocking web3 from ...
3
votes
0answers
1k views

web3 filter option not working

var filter = web3.eth.filter({fromBlock: 350000, toBlock: 'latest',address:"0x075da4ebae466b80d451b0627296d5d38b3e99c1"}); var myResults1 = filter.watch(function (error, log) { console.log(error);...
3
votes
1answer
7k views

geth transactions stuck in pending, resend fails

I sent 115 transactions with geth, and they are stuck in pending for over an hour. Etherscan doesn't recognize them. I try to resend, and get a confusing error. Some details from geth console: > ...
2
votes
1answer
1k views

Node script to sweep accounts

I have a rather large list of accounts (HD wallets) I want to sweep into one. They've all been imported into geth, and all have the same password. I wrote a script to do this in node but get this ...
1
vote
2answers
3k views

encode data input of the raw transaction to update an contract function? [duplicate]

I need to update a contract by calling one of their function but I cant use web3.js so I need to send a raw transaction. example of function to be call on the contract: test(address buyer, uint256 ...
1
vote
1answer
7k views

How to make transactions using private key in web3? [duplicate]

I have account private key, contract address and abi and I need to call contract function with this account. Is it possible?
1
vote
1answer
3k views

How to map a web3 to a react.js state

How would you map a changing variable from web3 to react.js component? Example: class App extends Component { constructor(props){ super(props); this.state = { blockNumber: web3.eth....

1 2 3 4 5 9