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

2
votes
1answer
331 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 ...
11
votes
1answer
5k 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") "...
9
votes
1answer
223 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 ...
3
votes
1answer
321 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 ...
6
votes
1answer
573 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,...
4
votes
1answer
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 ...
4
votes
1answer
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 ...
10
votes
2answers
1k 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 ...
19
votes
2answers
9k 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 ...
3
votes
1answer
460 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 ...
12
votes
2answers
5k 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?
5
votes
1answer
2k 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 ...
6
votes
1answer
2k 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[...
3
votes
3answers
1k 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" ...
3
votes
1answer
456 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 ...
10
votes
1answer
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 ...
19
votes
2answers
9k 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 ...
6
votes
1answer
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 ...
5
votes
1answer
307 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?
3
votes
1answer
452 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 ...
8
votes
2answers
2k 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 ...
8
votes
1answer
13k 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 ...
4
votes
1answer
799 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-...
3
votes
1answer
717 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 ...
27
votes
5answers
16k 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); ...
2
votes
1answer
816 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,...
5
votes
2answers
653 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 ...
8
votes
4answers
2k 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]++; } } ...
13
votes
2answers
3k 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!
7
votes
1answer
500 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 ...
3
votes
1answer
594 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 (...
8
votes
1answer
2k 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 ...
15
votes
3answers
10k 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 ...
6
votes
3answers
3k 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 ...
5
votes
1answer
2k 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/...
3
votes
0answers
130 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 {....} ...
4
votes
2answers
798 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 ...
3
votes
2answers
240 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 ...
9
votes
3answers
5k 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?
3
votes
1answer
450 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 ...
6
votes
3answers
3k views

Is there any API for sending and receiving Ethers?

Is there any API for send and receive Ethers? If not, i am trying to use web3.js in my own server; What are the technical implications? Major security concerns? Can I use the same API for creating ...
5
votes
1answer
722 views

Can you input decimals number in smart contract?

I'm having an issue where send 0.1 or 1.1 is saved as 0 and 1 in my contract's storage. Does anyone knows how to properly pass decimals ?
2
votes
1answer
188 views

Option to give passphrase via web interface

I am trying to run the sample web3.js code from here https://github.com/ethereum/web3.js/blob/master/example/event_inc.html I am running the geth node on testnet. However, when I try to create the ...
29
votes
6answers
12k views

How do I parse the transaction receipt log with web3.js?

The event parser in web3 provides a nice parsing functionality for events, and I use it for logging all events to a file, but it's very difficult to use for looking at individual events for a ...
6
votes
3answers
844 views

What is the difference between “eth.accounts” and “web3.eth.accounts”?

The instructions for creating a new account on the Geth console state: Tip: If you are using Geth then you can just use eth instead of web3.eth command. Meaning accounts can be referenced by ...
21
votes
1answer
2k views

What are effective techniques to encrypt/decrypt data stored in a smart contract?

Rather than sending and storing plain text in a smart contract, the use case objective is to encrypt first and then subsequently access the data and decrypt at the point of use. What is the most ...
7
votes
1answer
968 views

What is the best way to send multiple transactions without running out of gas for seeding?

I'm having an issue where sending a single transaction work but sending multiple doesn't. I'm attempting to Seed my contract with data using using web3.js and it works fine. mycontractinstance....
8
votes
1answer
3k views

How do I access member variables of a contract from web3.eth?

For example: enum Stages { AcceptingBookings, StopAcceptingBookings, Finished } Stages public stage = Stages.AcceptingBookings; function rand ( uint256 param) atStage(Stages....
6
votes
3answers
3k views

web3 methods not implemented

I'm running a geth node on the testnet and trying to run web3.js method from my node server code. Here's my code var Web3 = require("web3"); var web3 = new Web3(new Web3.providers.HttpProvider('http:...
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 ...