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
6
votes
3answers
889 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
996 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
514 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 ...
29
votes
4answers
4k 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
4k 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
663 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
3k 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
487 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
747 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
280 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
762 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 ...
19
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
751 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
254 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
11k 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 ...
143
votes
2answers
27k 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
262 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
333 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. ...
18
votes
2answers
6k 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
6answers
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?
26
votes
3answers
12k views

What are the limitations to estimateGas and when would its estimate be considerably wrong?

web3.eth.estimateGas and JSON-RPC estimateGas can be used to see how much gas should be specified for a transaction, before crafting the transaction. Since it is an estimate, are there any ...
10
votes
2answers
600 views

Is there a tool that creates a basic HTML interface from an ABI?

I am looking for a tool that builds a basic interface for a contract so that I can use this generated HTML as a starting point to build the front end. I am aware that Mist, https://chriseth.github.io/...