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
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
8k 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
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....
19
votes
4answers
11k views

'Error: base fee exceeds gas limit' When creating new contract instance (Using Truffle, Web3Js and testrpc)

I have the following code in app.js file of my truffle project. import { default as Web3} from 'web3'; import { default as contract } from 'truffle-contract' import conferrence_artifacts from '../../...
18
votes
4answers
21k views

Invalid JSON RPC response: undefined, when running web3.eth.accounts (Node)

I'm very new Ethereum and trying to follow this tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 But when I run: web3.eth.accounts I ...
13
votes
3answers
14k views

Smart Contract Error: Returned values aren't valid, did it run Out of Gas?

Deployed a contract using Remix IDE to Rinkeby testnet. Etherscan contract address and code is here. contract SimpleCounter { int counter; constructor() public { counter = 0; } ...
10
votes
2answers
1k views

Programmatically saving the contract address of a submitted contract

I understand how the below web3js code block works, adapted from here: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract But how does one save the contract address ...
10
votes
2answers
651 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/...
9
votes
3answers
3k views

Deploy contract on EthereumJS TestRPC

Following https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 I've tried to create an instance of a contract using: VotingContract = web3.eth....
9
votes
1answer
2k views

Is it safe to publicly host a parity node?

In the normal use case, Parity runs on localhost. However, I'm building a demo web site that uses Web3JS to connect to a public parity node running on port 8545. I am publicly serving a Node/VueJS ...
8
votes
1answer
10k views

How to get string from hex on Smart Contracts results [duplicate]

On a Smart Contract called "mem" there is a function called "get()" that returns a bytes32 that is supposed to be a string. How can I decode the string? The result is an hex value. I have tried ...
8
votes
1answer
19k views

Using web3.eth.estimateGas cause “gas required exceeds allowance or always failing transaction”

In solidity code I have function addPhase and it works well. The code below also works well for (let j = 0; j < companies[i].phases.length; j++) { transactions.push( this.contract....
8
votes
2answers
2k 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 ...
7
votes
2answers
4k views

Do I have to unlock my account in geth to call a web3.eth.sign() in JavaScript?

I have: A geth account Access to web3 API I want to: Invoke the function, web3.eth.sign(coinbase, sha) If I put this in a javascript file sign.js, and I call node.js, will it sign my message? Or ...
6
votes
3answers
4k 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 ...
6
votes
3answers
4k views

What is the MetaMask workaround if Web3 is deprecated

While using MetaMask, adding Web3 to a Javascript program displays the following message in the Chrome console: "MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider" ...
5
votes
1answer
3k views

Solidity/Web3.js Cannot send value to non-payable constructor

I have a simple contract that I built a small webapplication with. The contract is as follows: contract MyContract { address public creator; function MyContract() { creator = msg....
5
votes
2answers
5k views

How does MetaMask inject Web3?

I'm just getting started with Solidity and Truffle, and I'm quite confused regarding this example code: App = { web3Provider: null, contracts: {}, ... initWeb3: function() { // Is there an ...
5
votes
1answer
989 views

What's the difference in the ways of calling a contract function?

After I get an instance of a contract, there are 3 ways to call the contract function below: 1.testInstance.testfunc({from:eth.accounts[0]}) 2.testInstance.testfunc.sendTransaction({from:eth.accounts[...
4
votes
1answer
2k views

get address of new contract from contract factory

i need to deploy a rental contract at runtime whenever user want's to start the contract. for this purpose i have acontract factory. here is the actual code for facotry pragma solidity ^0.4.8; import ...
4
votes
4answers
514 views

Truffle Drizzle-box fails with TypeError: (0 , _drizzle.generateContractsInitialState) is not a function

Right after unboxing Drizzle-box I'm getting a TypeError: (0 , _drizzle.generateContractsInitialState) is not a function. Ganache is running on localhost:8545, contracts are deployed, Metamask ...
4
votes
1answer
5k views

Web3 - Uncaught TypeError: contract.abi.filter is not a function

I have compiled and deployed a simple Hello World contract using truffle: pragma solidity ^0.4.4; contract Greeter { function Greeter() { } function sayHello() returns(string) { ...
4
votes
1answer
718 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
4
votes
2answers
1k 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 ...
3
votes
1answer
3k views

Get history of transactions to specific account [duplicate]

I am using web3.js and geth to do my coding. I have an Ether Account (Not a Wallet Contract) that will be receiving funds from clients. The clients will be writing a number in the DATA field (that you ...
3
votes
1answer
2k views

Is it possible to use web3.js API methods to interact with a contract deployed on Rinkeby?

I have deployed a simple HelloWorld Solidity contract on one of the Ethereum Testnet called Rinkeby with MyEtherWallet and of-course I can interact with it. Now I want to interact with that contract ...
2
votes
2answers
6k views

Send wei to payable function with web3 async

I want to send 100wei to a payable function in my deployed contract. But i don't want to sign the transaction because of to much effort to get this going. I just want to submit the transaction with ...
2
votes
1answer
817 views

Error: invalid argument 0: json: cannot unmarshal object into Go value of type string

I have followed following solution. When I try to do shh.getPrivateKey(kId).then(console.log) I have received following error, please note that this line works under web3.py: ...
2
votes
1answer
1k views

Ethereum Web3 Asynchronous Calls/Promises/Callbacks [closed]

I'm a newcomer to Ethereum, working on a project that requires a certain piece of data from a contract, in order to populate a list in my HTML frontend. However, as you might expect, the calls to the ...
2
votes
2answers
2k views

Retrieve data from smart contract using sendTransaction

Lets take a very basic smart contract that has one function in which you send a number and it will return the square. It has another function that returns a fixed string. contract MyContract { uint ...
1
vote
2answers
1k views

web3: TypeError: 'toBytes' is not a function

The way I install web3: npm install -g web3 The way I connect into web3: Web3 = require("web3"); web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); if(!web3.isConnected()){ ...
0
votes
2answers
183 views

Intracting with dapp using frontend truffle petbox

App = { web3Provider: null, contracts: {}, account: '0x0', init: function() { // Load pets. return App.initWeb3(); }, initWeb3: function() { if (typeof web3 !== 'undefined') {...
0
votes
1answer
439 views

How to send ERC20 Token?

I try to send Token based on Erc20. and I can send Ether and something function but i dont know how to use transfer function in javascript like that. function transfer(address _to, uint256 _value) ...
13
votes
5answers
8k views

Getting Uncaught Error: new BigNumber() not a number: [object Object]

I am quite new to this. Please help me out. I am trying to build a dapp using meteor. I am having a little trouble with calling a function of the contract using web3. Here's the code snippet that's ...
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
2answers
1k views

Fallback function in web3

I find answer how to make upgradable contract here How to call function from currentVersion with fallback function on web3? contract Relay { address public currentVersion; address ...
8
votes
1answer
613 views

Is there a recommended / secure way to unlock an account through Web3 interface / HTML page securely?

This question was asked on Reddit: Is there a secure/recommended solution to unlock an account and send a tx through the Web3 interface (from a Html page)? One of the alternatives that I have in mind ...
7
votes
2answers
2k views

getData() is not working

I want to call a function of the contract, something like this - module.exports.transfer = function(to,value,){ return token.methods.transfer.getData(to, value); } But I am facing the error ...
7
votes
2answers
7k views

How to obtain all transaction of a contract?

I'm trying to obtain all the transactions of a contract, but in all cases I only obtained [] or undefined. I'm following this posts: Common useful JavaScript snippets for geth web3 filter option not ...
7
votes
2answers
4k views

Getting Go-Ethereum current network id

How can I know the network id, with web3 or command line, so I know to which network my geth has attached?
6
votes
1answer
4k views

Provided address is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted

Here is my transaction from ethereum. transaction is shown as followed { blockNumber:12, contractAddress:null, cumulativeGasUsed:22977, gasUsed:22977, status:1, ...
6
votes
2answers
2k views

How to access all accounts across multiple nodes? JS/Web3.js/API

I'm running a private ethereum development network with 3 nodes connected to each other. Before asking my question, something about my setup. This is how I start those nodes: geth --networkid 2345 --...
6
votes
5answers
12k views

How to get value of a contract public property using web3.eth

using web3 javascript library how do you get the current value of a public property. e.g. contract MyContract { address public owner; ... } Here's a snippet of the abi: [{ "constant": ...
6
votes
1answer
586 views

Gas estimation for mapping updating with web3js

The gas estimation for contract deploying with web3js will look like: var res = web3.eth.estimateGas({ from: web3.eth.defaultAccount, data: contractByteCode }); For example, I have the ...
5
votes
1answer
954 views

How to decrypt an encrypted message using metamask?

I have a message encrypted with the public key. Metamask has its corresponding private key (account). How can I decrypt it with the metamask? Does metamask provide such feature? What I meant is just ...
5
votes
1answer
909 views

Transaction w/ invalid nonce

Web3.js throws an error "Transaction w/ invalid nonce." when I try to call contract methods from JavaScript console. The same methods from the same contracts work fine from Mist, or, what is strange ...
5
votes
1answer
2k views

Manually set web3 version in truffle?

The version of web3 in Truffle v4.0.5 is v0.20.3. Is it possible to manually upgrade the web3 version? Similar to this question about web3 in geth. (It's hardcoded.) Somewhat relevant to this issue.

1
3 4
5
6 7
9