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

Web3 create account from mnemonic + passphrase

I'm trying to create an ethereum account using web3-js by providing a mnemonic + passphrase (created with BIP39-js) but can't seem to find an implementation of web3.eth.accounts.create() that accepts ...
0
votes
1answer
23 views

Error: Invalid JSON RPC response: “” from web3

I run: geth --rinkeby --rpc --rpcport=8545 --rpcaddr=192.168.1.37 It works in console: geth attach http://192.168.1.37:8545 > eth.syncing false > eth.accounts ["...
0
votes
1answer
21 views

Invalid sender address, failed to deploy a transaction to the blockchain network

Description I'm trying to deploy a contract to rinkeby network, but everytime I like to deploy the contract it throwing error as invalid sender. Compile code const path = require('path'); const fs =...
0
votes
1answer
15 views

TypeError: market.FileViewed is not a function while trying to watch event

I want to watch for fileViewed event and it throws TypeError: market.FileViewed is not a function in marketplace.FileViewed{ ^ My solidity contract: pragma solidity ^0.5.0; contract ...
0
votes
2answers
24 views

invalid number value for power of 18

Using web3js v1.2.1 const contract = new web3.eth.Contract(abi, '0x29...'); const amount = 1 * 10 ** 18; const data = contract.methods.transfer(recipient, amount).encodeABI(); I get error : invalid ...
1
vote
1answer
162 views

Handling require/assert failure errors correctly from a Node.JS app?

I have a getter function in my smart contract that returns one of the string values in statically defined string array. Upon entry to the function, it does a bounds check on the incoming index using ...
1
vote
3answers
1k views

Estimate Gas Price (not Gas) using Web3

Using Web3, we are able to estimate the amount of gas needed for a transaction let estimatedGas = web3.eth.estimateGas({ to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", data: "...
26
votes
5answers
5k views

How to detect if an address is a contract?

I'm interested in knowing whether any particular address is a contract address or a standard address. There have been similar questions on the topic, but I'm not looking to detect whether an address ...
0
votes
0answers
17 views

getPastEvents undefined(please help)

I had asked this question before. I looked carefully at the exchange section, which I advised, and I think there is no problem with the exchange section. At least in my opinion there is no problem and ...
4
votes
1answer
152 views

Can't debug transactions that fail during the Web3.js estimateGas() call? No Tx Hash

NOTE: I am doing my work with the Ganache v1.2.2 GUI client on a Linux Ubuntu 18.04 station. There are many revert errors that happen during the estimateGas() call that precedes the actual Web3.js ...
2
votes
1answer
195 views

Connecting to blockchain on azure using web3.js and websocket

right now, I am trying to write a service using web3 which will 'subscribe' to all 'perndingtransactions' on blockchain to perform further actions. web3 documentation says that 'Httpprovider' cant be ...
0
votes
1answer
199 views

Transaction stuck in 'Pending' state when using 'sendSignedTransaction'

I am trying to execute a transaction by first signing it with my private key using ethereumjs-tx and then using sendSignedTransaction to send the transaction to the network. But somehow the ...
0
votes
3answers
996 views

How do I get the return value of a solidity function with web3?

The docs mention using MyContract.methods.myFunction().call().then(console.log); but methids methods I get the error then I get the error that the function is undefined. The code below doesn't ...
1
vote
1answer
201 views

Error: Node error: {“code”:-32015,“data”:“Reverted 0x”,“message”:“VM execution error.”}

I deployed my smart contract on Kovan Etherium testnet. After that, I am trying to interact with smart contract methods using web3 1.0.0. Below is my node js code: var Web3 = require('web3'); var api ...
0
votes
2answers
151 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
138 views

read error unexpected EOF

I'm working a evidence application with quorum.I want to store the entire contents of a file on my private blockchain. Although it's not recommended. At first I use a linux command 'split' cut a big ...
0
votes
0answers
13 views

Trying to send ERC20 token with Javascript button without success

I am trying to send an ERC20 token with the following code via web3.js. It was working until a week ago and then it stopped. Am I doing something wrong? Upon clicking it no longer interacts with ...
0
votes
1answer
196 views

How to retrieve data form a smart contract?

Following is the contract that I want to call, and retrieve the string in node.js. But I want have a require that allows only some specific address to have this data. pragma solidity ^ 0.4 .4; ...
1
vote
2answers
2k views

Create an Ethereum wallet with React Native for single token

Many of you might think that this question has already been answered but I don't think that there is a clear answer on the internet for the current Ethereum, Web3.js and React Native versions (for ...
0
votes
1answer
142 views

Deploy bytecode

I have a compiled contract (actually it's just arbitrary data) that I would like to store as an account. It is possible to store this as a new account using web3js? I do NOT have a constructor ...
0
votes
1answer
13 views

Call functions from another account by default in web3

In my truffle tests, I am trying to call a function from an account other than the default account, so not accounts[0] from the below result. web3.eth.defaultAccount doesn't seem to work. web3.eth....
0
votes
1answer
27 views

Verifying if a user actually owns the address

Web3js frontend with Vue, .NET Core with Nethereum at the back. The key target for this functionality is to sign a message at the frontend, send the signature and the address to the backend to ...
1
vote
1answer
19 views

Creating a contract instance

Is it generally better to define a contract instance once, then pass it through your components like... class Parent extends React.Component{ constructor(props){ super(props); ...
0
votes
2answers
990 views

SyntaxError: await is only valid in async functions and async generators in web3js [on hold]

Below is my code snippet. I wish to wait for the transaction hash value so that I can return my Javascript function with the hash value. But I get the error "SyntaxError: await is only valid in ...
0
votes
1answer
77 views

Unhandled promise rejection (rejection id: 1): Error: Transaction has been reverted by the EVM:

I don't know where i'm doing mistake. I have deployed my contract through remix and truffle and it was deployed without any mistake but now i'm deploying it from web3 solc@0.4.24 version and EVM is ...
1
vote
1answer
146 views

Can the Android Metamask Extension be used with DApps?

I've successfully downloaded the Metamask Firefox Add-on, and imported my wallet into it. However I'm failing to see how I can use this add-on from within my DApp like I do on Chrome, using the ...
1
vote
1answer
31 views

Duplication of events in permissioned geth Chain with clique PoA consensus algorithm

I have an Ethereum chain running on my local host via geth and i am using the clique PoA Algorithm. I have 4 authority nodes so the number of Nodes allowed to sign a block should always be 1 because ...
0
votes
1answer
99 views

Unlocking account web3.js 1.0 on AWS Lambda

I'm getting following error message when trying to unlock account on AWS Lambda: Error: Node error: {"code":-32601,"message":"The method personal_unlockAccount does not exist/is not available"} ...
0
votes
1answer
102 views

Web3js can not touch smart contract, always return 0

web3js can not touch smart contract. var id = dragoncore.getGenesNum(); has no error, but always return back 0, never changed. -----------------------------web3js code ----------------------------- ...
2
votes
1answer
263 views

subscription not happen on geth+websocketProvider in web3

I have started geth node (connect to ropsten testnet) on my local OSX system. Command: geth --testnet --fast --bootnodes "enode://...
0
votes
1answer
167 views

Web3js :interact with smart contract

I'm currently struggling to interact with my smart contract, I don't if it comes from the way I call the function or the way I connect to my smart contract. Here is the code const contractAddress = '...
0
votes
0answers
14 views

cloning div container number of deployed child contracts time and put their data inside div container

Sorry for the silly question. I have a div container "product-card" , I want to loop the number of my deployed smart contracts time. every time when I loop I want to clone this div container and ...
0
votes
0answers
8 views

How can I change the text message on connection request window of metamask?

I want to change the message in connection request window using web3js. I have attached screenshot here. kindly check it.
1
vote
2answers
26 views

How do i use .send() to fire methods of my smartcontract?

I have looked alot for information about this and lastly i turn myself to here. I've written a smartcontract and deployed it to Ropsten . I am then using web3.js to interact with my smartcontract, i ...
1
vote
1answer
135 views

Merkle proof for Smart Contract mapping field data

I'm trying to get merkle proof for Ethereum Smart Contract mapping field data. I created test smart contract and deployed to test network. Smart Contract Code like following code: contract ...
0
votes
1answer
132 views

Unable to send ether to account

I am trying to send ehter using this code web3.eth.accounts.wallet.add(privateKey); web3.eth.sendTransaction({ to:someAddress, from:onwer, value:amount*1, ...
0
votes
1answer
409 views

Creating a transaction from a webform - invalid number of args

I have a HTML web page where I am feeding user entries into a smart contract that is designed to "store" the entries in transactions. I have most of the application working, but I'm having trouble ...
0
votes
0answers
36 views

erc20 transfer SafeMath: subtraction overflow?

I am trying to transfer a erc20 token. const data = contract.methods.transfer(recipient, amount).encodeABI(); const rawTx = { from: sender, nonce: '0x' + count.toString(16), ...
1
vote
1answer
148 views

Ropsten rejects my sendSignedTransaction function

This is my code: contractNoEvents.methods.myMethod().call(function(err,foo){ if (foo.length > n) { contractNoEvents.methods.myOtherMethod().call(async function(er, bar)...
0
votes
1answer
159 views

The contract code couldn't be stored, please check your gas amount while deploying contract

I'm trying to deploy 3 contract in 2_deploy_contract (I deploy all 3) but after the first is deployed I get the following error : The contract code couldn't be stored, please check your gas amount.
2
votes
4answers
2k views

How do I install web3@1.0.-beta.26 on Windows 10?

How do I install web3@1.0.-beta.26 on Windows 10? npm install --save web3@1.0.0-beta.26 does not work and creates a page of errors. I've also tried --python=python2.7 Here is what I get. C:\Users\...
0
votes
0answers
19 views

Parity Aura - Error: Transaction has been reverted by the EVM

I run the following code against two private blockchains, parity-aura and geth-clique. Why does the parity transaction revert and why does it use 6,000,000gas when it should actually only use about ...
0
votes
1answer
55 views

metamask and web3: Invalid number of arguments to Solidity function

my function has only one input string description : function createProposal(string description) { Proposal memory p; p.description = description; proposals.push(p); } and ...
0
votes
1answer
199 views

Ganache not working

I am developing on a testnet on ganache and using remix. I am working with web3 and working on the user interface. when trying to fetch a function with web3/ganache, I get the following error: "...
1
vote
1answer
122 views

are truffle tests inconsistent?

Im currently testing my contract and I've written truffle tests in js for the first time. Rarely (1 out of 10 times?) I get unexpected results: This is the code structure I use: var contract = ...
1
vote
1answer
612 views

Error: Returned error: invalid sender

I'm trying to sign transaction and send it to remote node, but I keep getting this error: UnhandledPromiseRejectionWarning: Error: Returned error: invalid sender This is how I perform signing and ...
0
votes
1answer
117 views

Can't connect to localhost:8545 while using ethereumjs-testrpc web3?

I am developing a simple Voting dApp by following a tutorial. In this tutorial we are using npm install ethereumjs-testrpc web3 so that we can get the fake nodes of Ethereum. For that i first ...
0
votes
0answers
16 views

Ethereum payment processor Nodejs

I'm working on a web project where I need to have the ability to accept crypto payments. Implementing bitcoin was fairly easy as there were api's whom allowed me to directly subscribe to a specific ...
1
vote
0answers
54 views

Error while installing web3@1.0.0-beta.26 on Windows 10

I am getting the following error while installing web3@1.0.0-beta.26 on Windows 10. npm ERR! code ETARGET npm ERR! notarget No matching version found for web3-core@1.0.0 npm ERR! notarget In most ...
0
votes
1answer
602 views

Sending ether to a contract

Beginner in solidity and i'm trying to send ether from an address to a contract. I've tried transferring ether using the Remix compiler test accounts. pragma solidity 0.4.25; contract sendether{ ...