Stack Exchange Network

Stack Exchange network consists of 174 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
808 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
637 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]++; } } ...
12
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
493 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
591 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 (...
6
votes
1answer
1k 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
128 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
786 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
237 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
447 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
719 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
185 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
831 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
964 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 ...
5
votes
1answer
2k views

Making web3.js work from node server code

I'm running a geth node on the testnet and trying to run web3.js method from my node server code. var coinbase = web3.eth.coinbase; console.log(coinbase); However, I'm getting a provider not set or ...
2
votes
2answers
489 views

How can I program my DApp to tell my user that their action/transaction has been confirmed?

Take an example of a voting DApp. A user clicks on a vote button, then behind the scenes the transaction containing the vote gets mined on the blockchain. The DApp then wants to alert('You have ...
26
votes
4answers
3k views

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

Take an example of a voting DApp. A user clicks on a vote button, then behind the scenes a transaction gets mined on the blockchain, and finally the DApp tells the user their vote has been recorded. ...
14
votes
5answers
3k views

How do I know when I've run out of gas programmatically?

This keeps coming up on the gitter forums so I thought I'd ask and answer this question: How do you know when you've run out of gas?
7
votes
1answer
2k views

How can Hooked-Web3-Provider and Lightwallet work together?

Does anyone know some good working examples of the Eth-Lightwallet and the Hooked-Web3-Provider working together? I was trying to get https://github.com/ConsenSys/eth-lightwallet/blob/master/example/...
10
votes
1answer
615 views

Given a contract address, can I determine when the contract was deployed?

Ideally the solution would use web3, but other solutions are acceptable. Motivation: Event lookups can be passed fromBlock field. If I know the block a contract was created, I can more accurately do ...
14
votes
3answers
2k views

Accessing past values of Smart Contract variables

I would like to know if is possible to inquiry variable values using older blocks. For example I have contract Simple { string32 message public; function Simple() { message = msg....
5
votes
1answer
443 views

How to interact with the blinded auction contract from web3.js

My question is about the blind auction contract in the solidity examples. What is the right way to interact with the contract from web3.js? I tried this, but it does not give the right result. var ...
2
votes
1answer
651 views

Uncaught Error: could not decode, json: cannot unmarshal array into Go value of type string(…)

I'm trying to use my already deployed contract using web3.js from my console but i'm having issues. I get my compiled contract from browser-solidity then do: var web3 = new Web3(new Web3.providers....
2
votes
2answers
270 views

Is it possible to access Ethereum API via the browser?

How do you access the api's of ethereum via the browser? Say I wanted to make a one page app that updates every 1 minute with the block number. And where can I get a list of all the API variables?
12
votes
2answers
734 views

What is the way to make Ethereum available to users for free?

As the web is mostly free today (I mean the old web, the one < 3), most people won't agree in beeing asked for fuel to run sites, apps, even if the gain in terms of safety and trust are so much ...
18
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 ...
2
votes
1answer
732 views

How to use contracts deployed by embark on the server side of a meteor app?

I have created my example using embark meteor_demo and then changed my configuration on embark.yml to output the contract on the server folder instead of the client. From that point i started getting ...
4
votes
1answer
240 views

Is it possible to check which RPC APIs are available?

Is it possible for a decentralized application to get details about the offered JSON-RPC APIs from the local ethereum node? I want to check the following specs in the following order using web3.js: ...
18
votes
4answers
10k views

Does Web3.js have the functionality to create new accounts and unlock an account for a period of time for a series of transactions?

I want to create new accounts through my Dapp web interface and unlock a specific account so that transactions can be processed. I didn't see it in the web3.js documentation so wonder if that's on the ...
7
votes
2answers
1k views

web3.sha3 dealing with hex in both geth and web3.js

in both geth and web3.js, when we call > web3.sha3("0x536f6d6520415343494920737472696e6720746f20626520686173686564") we get: requirement of using web3.fromAscii before sha3 is deprecated new ...
131
votes
2answers
23k views

What is the difference between a transaction and a call?

What is the difference between a transaction and a call? In some interfaces, I can interact with contracts via calls or via transactions. What is the difference between the two, and can contracts also ...
4
votes
1answer
255 views

What is the web3 filter.watch() scope?

If I create a nested filter.watch filter_a.watch( filter_b.watch(); ); If I call filter_a.stopWatching(); does filter_b.watch() go out of scope for web3.js? Does geth keeps sending filter_b....
6
votes
2answers
3k 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, ...
9
votes
2answers
331 views

Why do I get serialization errors in calling events?

I have put some events in my contracts like this event TokenTransfer(address indexed sender,address indexed receiver,uint32 indexed num_tokens); event ExceptionEvent(uint16 indexed retcode,address ...
2
votes
2answers
2k views

Attaching an address for a contract to call another contract

I am writing code where I want to call other contracts within my current contract. Bank.sol contract Bank { address owner; mapping (address => uint) balances; function init() ...
9
votes
2answers
4k views

How to connect a web site to a geth node?

Before the DApp-browser Mist was available, this web3 library seems the way to go on building a bridge from contract to a frontend (web site). But, I cannot get the very basic examples to work. ...
17
votes
2answers
5k views

Why aren't Solidity sha3 hashes not matching what other sha3 libraries produce?

Solidity has a function named sha3 and I tested it with an empty string input. It is not matching what other sha3 libraries produce. I see contracts written by others using the same sha3 function ...
2
votes
3answers
5k views

Are there any blockchain/transaction APIs for the Ethereum network?

In the Bitcoin world there are a number of APIs such as: blockchain.info blockr.io blockcypher.com etc. which allow a web application to access block and transaction data from the blockchain, as ...
5
votes
1answer
3k views

What is the 0x I see around Ethereum? For example I see addresses that start with 0x

I see a number of things in Ethereum start with 0x, for example addresses. Other examples are in the Geth console, JSON-RPC, web3.js. What is the 0x and what is its purpose?