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

1,258 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
1answer
134 views

Cannot connect to private testnet with web3.js

I have setup a local private test net and now I want to connect from Node.js to a node in the testned using IPC. I started a node with this command: ./geth --identity "5" --datadir /home/davide/...
0
votes
0answers
57 views

Automatically deploy a contract with generated Web3js code

I want a command line tool which having only contract source would automatically not only compile it but also automatically create the JS code which can deploy the contract through Web3.js (using user ...
0
votes
1answer
193 views

Solidity | How to throw “string” argument using Send() function?

I have a function which get a parameter as String and compare it like below. function freezeAccount(string _value) onlyOwner public { if (keccak256(_value) == keccak256("true")){ isFrozen = "true"...
0
votes
1answer
967 views

Web3 | TransferFrom() transactions always Failed

I'm trying to send Custom ERC20 Token to Owner Wallet Address using transferFrom() function using Web3.js However all the Transactions are failed. Which is the same problem occur on Remix IDE. Some ...
0
votes
1answer
62 views

How to use web3js to call a function with “payable” and transfer some ether to contract?

My code is like this : gameInstance.initGame.sendTransaction({from: webInstance.eth.coinbase, to: contractAddress, value: webInstance.toWei(person_num, "ether")}); Of course, it doesn't work very ...
0
votes
1answer
310 views

Getting web3 0.20.3 (Same as MetaMask)

When creating a site with MetaMask, you also want that other users who do not have MetaMask can use this site. To do this, you want to use the same library MetaMask uses - which is 0.20.3 currently. ...
0
votes
1answer
75 views

working with balance management in a game

I'm working in a online game project, Where users will deposit ETH into their account for playing game. My problem is, Once a user deposit some ETH into his wallet. Example 0.10 ETH So how we can ...
0
votes
2answers
72 views

How many functions allowed per contract? + solidity

I deployed a contract to ropsten and tried to call a method from frontend, but was getting TypeError: Cannot read property 'call' of undefined So I checked my instance via this.Test.deployed()....
0
votes
1answer
223 views

two issue about install web3.js through and invoke web3.eth.methods

First, I install type to the code like npm install web3 in the terminal while the first issue occurs (Environment1).Second, I change the version of node 、npm (like Envirnment 1=> Environment2) and ...
0
votes
0answers
30 views

'm trying to return the value of the variables in this contract but I get the error:“Uncaught TypeError: web3.eth.watch is not a function”

if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider); } else { web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); } web3.eth....
0
votes
2answers
58 views

I'm trying to create an app that allows people to exchange ether between themselves but I have the error: “web3.eth.transact is not a function”

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <center> <title>dEnergy</title> </head> <body> <label for="name" ...
0
votes
0answers
189 views

Connecting to ethereum network using web3 fails

I'm trying to connect to rinkeby using the following code: const HDWalletProvider = require('truffle-hdwallet-provider') const Web3 = require('web3') const secrets = require("./secret.json"); const ...
0
votes
1answer
328 views

How to prevent callback event occur twice?

Hi this is my web3 code events.watch(function (error,result){ if (error) { console.log('Error:'+JSON.stringify(error)); res.send({'status':0,'message':...
0
votes
0answers
48 views

Does Removing Something From an ABI Render It Non-Functional?

If remove a single feature from the ABI, will it work with other contracts that have that feature still? Does the order of functions matter in the ABI? Use Case: For simplicity, I want to build a ...
0
votes
0answers
314 views

Consequences of 'VM Exception while processing transaction: invalid opcode'

The question Hello everyone, could anyone explain to me the consequences of: VM Exception while processing transaction: invalid opcode. The context I'm passing in an integer in web3js that is not ...
0
votes
3answers
307 views

Remixd fails to run, cannot find web3-requestmanager

I have installed remixd using NPM. If I run it, it gives me the following error: Error: Cannot find module 'web3-requestManager' at Function.Module._resolveFilename (module.js:555:15) at ...
0
votes
1answer
185 views

Why does the transaction stay in queue from more than 240 second

I am running quorum nodes via the Quorum-maker script, and when trying to call functions from my already deployed smart contract, I get this error : Transaction ...
0
votes
0answers
462 views

web3.eth.call() to find token balance

data = web3.utils.sha3('balanceOf(address1)').slice(0,10) + randomstring.generate({ length:24, charset:'0'}) + address1.substring(2); web3.eth.call({to : config.ContractAddress, data : data}).then((...
0
votes
0answers
954 views

Web3.js is not installing correctly with commands “npm install web3”, npm install web3 -latest“ and npm install ethereal/web3.js -save”

192-168-1-109:~ connor$ npm install web3@^1.0.0 npm ERR! code ETARGET npm ERR! notarget No matching version found for web3@^1.0.0 npm ERR! notarget In most cases you or one of your dependencies are ...
0
votes
2answers
516 views

How to destroy a token or list of token from a another contract?

[Edit 14-03-2018] I want to create a contract A that can generate a random number of Token A and another contract B that receive and destroy one or many of this token to generate a new Token B. It's ...
0
votes
1answer
150 views

How blocks are verified in a private blockchain?

I have created a private blockchain in my machine and deployed a smart contract in the same. Then I have created a UI using web3. I could add peers to that network and all the peers could get the data ...
0
votes
1answer
108 views

Unable to return string using Oraclize

I'm trying to do a simple coin flip using WolframAlpha and Oraclize, this is my smart contract pragma solidity ^0.4.18; import './usingOraclize.sol'; contract CoinFlipOracle is usingOraclize { ...
0
votes
1answer
210 views

web3js API - web3.eth.contract.new - Fallback not called after successful deployment

I'm deploying a contract with web3js successfully, but the fallback function does not get called a second time after finishing the deployment. I read that this was an on-going issue (people not ...
0
votes
1answer
407 views

How to list all recipts in a block using web3js?

I'm trying to list all transactions and their receipts from given block. Transactions get be included in the result of GetBlockByNumber function but I have found no option to include receipts. I can ...
0
votes
1answer
78 views

Send total ether balance using geth/web3js

I installed a full node and synced to rinkeby testnet. I created 3 accounts using eth.personal.newAccount Assumed the balances of 3 accounts Account A: 1 eth (this is coinbase account) Account B: 1 ...
0
votes
0answers
499 views

Contract has not been deployed to detected network when deploying to main net

I'm trying to deploy a smart contract to the main Ethereum network, and I'm having trouble actually getting my front-end to work. I'm using Truffle, Geth, Infura, and web3js. var HDWalletProvider = ...
0
votes
1answer
182 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
175 views

BlockCypher Account nonce too far behind transaction

I'm currently working on a DApp that involves sending transactions. I'm using BlockCypher to send the transactions since the API is fairly straight forward. One issue I'm finding is that when I run my ...
0
votes
1answer
254 views

Error: The contract code couldn't be stored, please check your gas amount during deploy

I know this issue was discussed before several times, but I cant get the solution to my problem. I'm trying to deploy a contract with Truffle on Ganache. During the deployment in 2_deploy_contracts....
0
votes
1answer
833 views

How can I obtain my public key (using web3)

I know my Ethereum address, my Metamask wallet will give it to me, and I can run : web3.eth.coinbase But I want to know what my public key is. Is there any way I can find that ? (the reason I want ...
0
votes
1answer
167 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.
0
votes
2answers
187 views

How to write data or change varibles in smart contract on Rinkeby from web3.js

I have a smart contract which have a function to allow/disallow user to send ether to my contract. By default all ETH address are allow to send ether to smart contract. But, if I want to disallow ...
0
votes
0answers
85 views

Best practices to calling owner only functions from a website

I am following the web3 documentation and I found that its possible to sign a contract and do a transaction directly from web3. I want to call an onlyOwner function in my contract directly from a ...
0
votes
0answers
1k views

Ganache-Cli - getBalance() via web3

I am running a local ganache-cli as ganache-cli -p 8545. Furthermore, I created a frontend script using web3: <html lang="en"> <head> <meta charset="utf-8"> <meta http-...
0
votes
0answers
150 views

eth.isSyncing command not working

I am running geth with this command : geth --syncmode "fast" --cache 2048 --rpc --datadir /media/username/2TB_HDD and then in new terminal I typed : geth attach ipc://media/username/2TB_HDD/geth.ipc ...
0
votes
2answers
261 views

web3 (then property) in ethereum node

Would you please help: When I run the below command in my nodejs console I get the below error: (I am using web3 0.20.0) on Windows 10 web3.eth.getAccounts().then(list => {accts = list}) ...
0
votes
1answer
140 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 ----------------------------- ...
0
votes
0answers
209 views

Signed message offline does not match public key

I'm trying to sign message with private key offline to prove private key ownership. The issue is that when validating signed object public key from private address does not match output from recover ...
0
votes
1answer
116 views

Problem with meteor server side call to Ethereum node

I try to interact with Ethereum node via web3 lib. (meteor add ethereum:web3) Meteor 1.5.4.1 lib.js if (typeof web3 === ‘undefined’){ web3 = new Web3(new Web3.providers.HttpProvider(‘http://127.0.0....
0
votes
0answers
987 views

Passing a bytes32 as a parameter from web3, returns invalid opcode

When I deploy the solidity contract and make the tests with mocha, the result of a function that receives a bytes32 parameter works fine. But, when I make the same with web3 in order to make the ...
0
votes
1answer
505 views

Why is the units of gasUsed in the transaction receipt 10^11 Wei?

I'm checking the balance of an account after a payable transaction in a Truffle test. Below is my code: // amount is the value supplied to the txn assert.equal(Number(String(currentBalance)), ...
0
votes
1answer
141 views

unable to write transactions on rinkeby from javascript file

I have written a contract which read and write data into blockchain using truffle. when i deployed that contract on rinkeby and called functions using web3.js the read functions works fine. but write ...
0
votes
1answer
315 views

Factory Contract Function is not creating New Contract using testrpc and web3

I am new to DApp development. I have deployed a TokenFactory contract and that Factory contract has a function "Create New Token" that generates a new token contract. The function "Create New Token" ...
0
votes
0answers
42 views

Couldn't interact with a “complex” Smart Contract in a private network through Web3.js, however, could interact with Remix

I've developed a UI in Visual Studio. The UI is a simple HTML with some CSS and also, Javascript code. To interact with my Ethereum Private Network, I've included the web3.min.js. Firts of all, I've ...
0
votes
0answers
1k views

.new isn't a function when deploying contract (web3)

I'm trying to deploy contracts using Ganache but I'm getting the following error. I have my ABI and contract address defined, all other functions with respect to interacting with the contract work, ...
0
votes
0answers
18 views

Contracts, Total Sold, Total sold in US

I need to find out how to: Connect web3 to the smart contract that contains the TOKEN token via a ethereum node URL running parity, and use getter function on this contract to obtain the 'total sold' ...
0
votes
1answer
665 views

Fetching all the accounts from Genache

I'm using Ganache to generate dummy accounts but every time I try to access the list of accounts using web3.eth.accounts or the web3.eth.getAccounts method, I only get access to the first account in ...
0
votes
1answer
389 views

web3 contract TypeError: 'apply' is not a function

I'm Trying to call the apply function on the contract ABI but I'm getting: TypeError: 'apply' is not a function at :1:1 > myContract { abi: [{ constant: false, inputs: [{...}], ...
0
votes
2answers
3k views

Contract method: Error: Provider not set or invalid

I'm building a Dapp using MetaMask. However, I'm getting an error when I try to call a method on my contract. Here's the simplified code: var web3 = new Web3(web3.currentProvider); var contract = ...
0
votes
0answers
37 views

Contract call not returning?

For some reason all my functions are able to return my calls except this one particular function. I call it using Truffle. async function asdf() { let contractInstance = await MyContract.at('0x...') ...