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
8 votes
2 answers
11k views

Calling public array of structs using web3

Good day. I've got an array of structs such as: User[] public users; struct User{ uint idNum; string name; address userAddress; } And I'm trying to get the array of users with web3.js ...
shultz's user avatar
  • 1,091
4 votes
1 answer
2k views

Specifying gas amount for contract call from JavaScript

I'm making this call from JavaScript to the contract function. contracts['CrowdFunder'].contract.contribute({value: web3.toWei(0.000000000000000005, 'ether')}); The function is called, but the error ...
Bogdan's user avatar
  • 397
7 votes
1 answer
3k views

Passing ether with call to Solidity function

I have deployed a contract to testnet which appears to function. I have a function named contribute which gets the ether from the msg.value. The function is below and doesn't take any arguments. I ...
Bogdan's user avatar
  • 397
3 votes
2 answers
977 views

How do we manage accounts for users

I understand there are accounts and we unlock them in geth/eth. If we are providing a service to a user community what is the design pattern envisaged to enable users to perform transactions under ...
Interition's user avatar
9 votes
1 answer
2k views

Does Solidity's constant keyword do anything?

It seems that the purpose of function foo() constant {} is to indicate that a function does not change the contract's state. And yet, as it states here, the compiler doesn't actually enforce this. So ...
redsquirrel's user avatar
5 votes
2 answers
5k views

can I monitor contract events in python?

If I understand correctly, in web3.js the allevents method enables a contract event to be monitored. is there an equivalent in python ?
euri10's user avatar
  • 4,640
4 votes
1 answer
759 views

Exposing Geth to Hybrid mobile app

I'm making a Hybrid mobile app and planning to use web3.js to access Geth. What's the best way to expose Geth to the hybrid mobile app? I will be running Geth on ubuntu 14.04 on Aws
Anderson Tess's user avatar
8 votes
2 answers
3k views

How do I know if a submitted block became an uncle?

We need to detect that the submitted work became an uncle. How would I do this with geth api? I thought of checking the submitted block number later for any uncles that match my block's hash. Is there ...
bolaum's user avatar
  • 123
14 votes
1 answer
2k views

How can I reliably induce a blockchain fork for testing purposes?

I would like to reliably induce a fork on a private testnet so that I can test the behavior of off-blockchain code that interacts with contracts. (see related questions as to why I would want to do ...
Paul S's user avatar
  • 4,271
4 votes
2 answers
2k views

Watching for changes in web3.isConnected()

I am using Meteor & Web3 to talk to a Geth node, and would like to have an event fire in web3 when the Geth node goes down. Web3 has the ability to add callbacks to web3.eth.isSyncing to detect ...
billett's user avatar
  • 1,255
2 votes
1 answer
375 views

sendTransaction from iPhone app

How do I call sendTransaction from within an iPhone app? I was thinking of running a web to Geth proxy where the iPhone app would call the Api exposed by the proxy which in turn calls my self hosted ...
Anderson Tess's user avatar
20 votes
2 answers
16k views

How can I verify a signature with the web3 javascript API?

Using the javascript web3 API I can create a signature like this: > web3.eth.sign(eth.coinbase, "0xdeadbeef") "...
J-B's user avatar
  • 8,911
9 votes
1 answer
456 views

Why is web3 being proposed as a global variable in Mist? What's the reasoning?

I have heard that web3 is supposed to have global scope, something similar to document or window. What is the reasoning behind this architectural choice? Is this still an underlying assumption? In ...
Karl Floersch's user avatar
3 votes
1 answer
389 views

web3.js and require.js - unexpected identifiyer issue

I'm testing the web3 api, but it seems to be an error when I try require('web3'). Require.js indicates that there is an error inside web3.js, but I have the latest release of web3. Maybe I have a ...
Clovis's user avatar
  • 881
6 votes
1 answer
686 views

Event.watch gets fired infinitely many times

I am trying out truffle + web3 + ethereumjs-testrpc. In the app I have the following code: window.onload = function() { var meta = MetaCoin.deployed(); var event = meta.Transfer({}, {fromBlock: 0,...
leitasat's user avatar
  • 161
4 votes
1 answer
1k views

MIX dapp IDE - how to run your dapp after deployment, error web3 is not defined

I managed to run a personal test chain. I deploy the Sample contract and everything is ok. Transactions included. Now how can I run the dapp? I go to the local package folder inside www I open the ...
Max's user avatar
  • 71
4 votes
1 answer
1k views

How can I connect to ethereum with only a web browser to monitor a contract

AFAICT it requires a node such as geth to connect to ethereum to get or change contract state. I only need to get state, not change state, but I want to do it only from a web browser. I don't want ...
Paul S's user avatar
  • 4,271
10 votes
2 answers
3k views

How can I trigger a PHP script when a transaction is received?

My goal is to have a PHP script be invoked whenever a transaction is received by a given address. I know Javascript but this is my first sally into Node.js. I think the right approach is to run a ...
spraff's user avatar
  • 645
35 votes
5 answers
43k views

Is there a way to find an account's current transaction nonce?

I need to know my transaction nonce because I am doing fancy stuff with contract addresses (which are the keccak hash of my address + my transaction nonce). Is there a way to find this through the ...
Broseph's user avatar
  • 695
3 votes
1 answer
557 views

What are the options that the web3.js solidity compiler passes to solc?

I've been using the following command to compile my contracts from CLI: solc ballot.sol --combined-json abi,asm,bin,interface > ballot.json However, the ballot.json file has a completely ...
Henrique Barcelos's user avatar
13 votes
2 answers
7k views

Convert with JS a Solidity bytes32 to a Solidity string

I have functions which are forced to return a bytes32 object, but then in my webapp I need to reconvert them to a classic string. How can I do that?
arodriguezdonaire's user avatar
6 votes
1 answer
4k views

Getting a contract by address only (without ABI definition)

Is it possible to get a contract only by its address without the ABI definition? I'm experimenting with ethereum in a private network through the web3.js client console. The problem is that any ...
Henrique Barcelos's user avatar
7 votes
1 answer
3k views

Call contract from another account using web3.js

I have a contract with which 2 accounts should interact. The accounts are in the same node in web3.eth.accounts. The contract was created by accounts[0]. How can I call that contract from accounts[...
Henrique Barcelos's user avatar
5 votes
5 answers
4k views

Ethereum blockchain webhook API

I am looking for an API service that allows my web app to generate Ethereum a deposit address, detect and notify a callback URL when a user sends ether to that address, and forward the funds to "cold" ...
Alste's user avatar
  • 151
2 votes
1 answer
499 views

Connecting a contract in a testchain to a front-end

I'm new using Ethereum. I set up a testchain to play around and have deployed some contracts there. My goal now would be to do something simple, like getting the balance of some of my testchain ...
punddalinni's user avatar
11 votes
1 answer
3k views

Can I unlock an account using JSON-RPC?

The only way I can work with ETH is through --rpc mode. Normally I would prefer to use the Python interface. But I found myself in a situation where the RPC is very limited. For example, I can't ...
yanik's user avatar
  • 463
28 votes
2 answers
26k views

Get a peer list for my geth node

How can I use Geth (or any other client) to get a list of my peer nodes on the Ethereum network. I see there's a function to get the number of nodes using the web3 api, but I need a list of node IDs ...
firescar96's user avatar
6 votes
1 answer
1k views

How can i setup a web3 webservice that listens for events from my smart contract?

I have a smart contract that broadcasts events to web3 clients, upon each event being broadcast, the listening client makes a tx call to my contract. I would like to set up an 'always on' event ...
Jay Bee's user avatar
  • 131
5 votes
1 answer
326 views

How do you access return statements in the Mist UI

If I have a contract and its interface added to Mist and I call a function, how do I access its return statement?
Jared Pereira's user avatar
3 votes
1 answer
474 views

How do I make my DAPP compatible with MIST?

I have created a small DAPP and it works fine with a geth rpc node running. However - I want to make it also compatible with the current MIST version (the November developer release) It seems like ...
governmental's user avatar
8 votes
2 answers
3k views

contract event not firing in web3 node console

It appears my events are not being fired in my node application when I transact the contract in the ethereum wallet gui. I deployed a custom contract via ethereum-wallet I have fired up geth attach ...
James B's user avatar
  • 483
8 votes
1 answer
14k views

Error: Invalid JSON RPC response: undefined from node web3.js app

I'm getting Error: Invalid JSON RPC response: undefined from my node.js application when it tries to execute a function. My steps: ethereum wallet 0.5.1 to deploy a contract to the testnet. start the ...
James B's user avatar
  • 483
4 votes
1 answer
948 views

Why does web3.js throw anonymous errors and swallow errors?

web3.js throws a lot of errors with no stack trace, making it hard to debug. for example: ./node_modules/web3/lib/web3/formatters.js: throw 'invalid address'; ./node_modules/web3/dist/web3-...
Paul S's user avatar
  • 4,271
3 votes
1 answer
1k views

How to read responses from calls to contract methods made using web3.js?

I have built a contract which provides a simple method for storing some data in a property of my contract on the blockchain. I can interface with my contract using web3.js and I have no issue doing ...
Thomas Clowes's user avatar
36 votes
5 answers
33k views

How to access the event log by knowing the contract address (web3)?

How can I access a log stored in one of the tx of the contract via web3? Code example: event newtest(string indexed name, uint indexed idlevel,string indexed multib, string objmulti, uint objnm); ...
b1818762's user avatar
  • 363
2 votes
1 answer
1k views

Possible to make a REST call within geth console?

I want to listen to events on a contract and then send them to a rest endpoint. Is it possible to make a REST call within the geth console? Alternatively, if I have a node application and I load web3,...
James B's user avatar
  • 483
5 votes
2 answers
1k views

web3.eth.getCode executes weirdly

I am trying to get a contract code from javascript. However, when I run this: web3.eth.getCode("0x9bA082240DBa3F9ef90038b9357649Fa569fd763") on my browser console, I get an Invalid address error ...
Loi.Luu's user avatar
  • 2,083
10 votes
5 answers
7k views

web3.eth.getStorageAt for mapping

How can I get contract mapping storage? Considering this simple contract contract Currency{ mapping(address=>uint) public balances; function deposit(){ balances[tx.origin]++; } } ...
0x8000's user avatar
  • 609
29 votes
3 answers
8k views

Can a contract listen to events of another contract?

I read that to listen to events you need to use web3.js. Are there other ways of doing it? Can a contract even somehow listen to events of another contract? Thanks!
uberlaufer's user avatar
7 votes
1 answer
730 views

How can I efficiently get a large amount of data from a contract?

I have a contract that will store a lot of data. Offline solutions really don't apply to the problem I'm trying to solve, short of caching (but then I have a cache invalidation problem I'd have to ...
Paul S's user avatar
  • 4,271
3 votes
1 answer
858 views

returning a fixed size 2D array to web3.js

I would like to return a 2D array from solidity code and look at it with web3.js this is the solidity function: uint8 [10][10][100][100] public blocks; function getBlock(uint x, uint y) returns (...
Paul S's user avatar
  • 4,271
10 votes
1 answer
4k views

Using web3, how can you get the tx cost and data/payload for a given transaction?

Using web3, how can you get the Tx cost and data/payload for a given transaction? getTransaction(tx#) returns everything but those 2 values. This information seems to be available via blockchain ...
dbryson's user avatar
  • 6,363
24 votes
3 answers
17k views

What does the Web3 "BigNumber not a base 16 number Error" mean

Is there a known problem with parsing events containing strings in Truffle/Web3? I'm using truffle with the following simple contract contract Board { string foo; event Shout(); event ...
JackWinters's user avatar
  • 3,403
6 votes
4 answers
5k views

Why does mist throw 'Uncaught invalid address'?

I'm trying to make a web page that gets a message from a simple "hello world" smart contract. Unfortunately, it isn't working. I'm seeing this in the Mist console. Uncaught invalid address v ...
Sinking Point's user avatar
6 votes
1 answer
3k views

How to update the web3 API version in geth?

I spent a couple of hours on upgrading web3 API to v0.15.3 in geth (on Mac OSX) with no effect. I installed the newest geth and it says: web3.version { api: "0.13.0", client: "Geth/v1.3.4/darwin/...
rethsid's user avatar
  • 1,888
3 votes
0 answers
162 views

How to use an accessor for imbricated data types?

I'm looking at information about accessors in solidity/js for more complex data structures than just a public array/mapping. How can i access the array in that code for: struct AnotherStruct {....} ...
user697's user avatar
  • 2,166
4 votes
2 answers
1k views

Transaction monitoring for deposits?

How do I monitor deposits for the account on ethereum? I saw some APIs that do this and I have tried to do the same on js web3 with filter but without any luck. What I would need is to get all the ...
gorgi93's user avatar
  • 141
3 votes
2 answers
312 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 ...
Jay Bee's user avatar
  • 131
18 votes
6 answers
23k views

How can I get the data of the latest 10 blocks via web3.js?

How can I get latest 10 block data by using web3.js like most block explorer does?
Satoshi Nakanishi's user avatar
3 votes
1 answer
541 views

Node.js, Geth & Events

I've been tracking a case where my Node.Js server just stop receiving events, basically for each contract, when I do a contact.allEvents({ fromBlock: startblock }, (error, data) => { ... }); It ...
Xavier Yvez's user avatar