Stack Exchange Network

Stack Exchange network consists of 175 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

0
votes
0answers
13 views

How to pass the function of a parsed ABI to MetaMask?

I am developing a dApp that is parsing an ABI and then it shows the functions of it and fields that is for every function's variable and i want to send the function with its variables to MetaMask to ...
1
vote
1answer
42 views

Why is it impossible to get return values of state-changing calls? [duplicate]

From reading I have surmised that it is impossible to get the return value of state changing calls. Consider this example.sol: contract F { function createChildContract() public returns (address ...
0
votes
0answers
43 views

Running out of Gas while deploying contract via web3.js

// contract is storing ABI var instance = contract.new( "0x12", // bytes32 "0x12", // bytes32 [], // array of addresses 11, // uint 11, // uint "...
1
vote
1answer
50 views

web3 is not defined problem

This is my simple html source code for my website. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewpoint" content="width=device-width, ...
1
vote
2answers
81 views

Unable to get abi and bytecode when compiling using solc

I am new to solidity and am following a tutorial that uses solidity compiler version 0.4.25. In the tutorial, solc.compile is used in a compile.js file followed by extract abi and bytecode and ...
2
votes
1answer
36 views

Event Watching Web3 v1 in Truffle test

I want to test off chain data input in truffle testing. So basically I kick off a test and then need to wait for another program to do something. In the old web3, this worked great: function ...
1
vote
1answer
18 views

Issue with Contract function return value data type

I am using a simple contract Contract code contract Bank { address public owner; mapping(address => uint) private customerBalance; event fallbackCalled(address, uint256); event ...
0
votes
2answers
119 views

How to install web3 latest version manually in windows10?

I used npm install web3 which would install (as of now) v1.0.0-beta.41 But it gave me the following error: E:\sheep\node_modules\sha3>if not defined npm_config_node_gyp (node "C:\Program Files\...
0
votes
2answers
26 views

Keep private data in contract and manage access

Is it possible to keep data in a contract, in a similar way that we can create wallet contract? Wondering if it would be possible to keep that and then manage the access to this 'hidden' data ...
1
vote
0answers
92 views

using events in private blockchain raises leveldb not found error

i'm getting { [Error: Node error: {"code":-32000,"message":"leveldb: not found"}] when trying to use events on a private eth blockhain. What might be the problem? (I've installed Leveldb with brew) ...
0
votes
1answer
52 views

Get value by calling a function from External Smart contract

There are 2 smart contract contract A { function abc(string _a) public returns (address) { return new B(_a); } } contract B { function xyz(string _a) { A a = A(contact address); // ...
0
votes
1answer
36 views

To handle emitted events from solidity in javascript in truffle suite

The function I am accessing will emit events i need to use that event but the function is a transaction when i am accessing the event it turns as promise pending . So suggest me some methods. thanks! ...
1
vote
1answer
65 views

Cannot connect to ganache-cli with web3 and nodejs

from package.json: "ganache-cli": "^6.3.0", "web3": "^1.0.0-beta.41", in my createContract.js const Web3 = require("web3"); const ganache = require("ganache-cli"); console.log('ganache.provider :', ...
0
votes
1answer
19 views

Access to providers in a cluster with web3 does not work

I have a blockchain deployed in a cluster. I have a geth instance running in a cluster-node and another one in another cluster-node, making a blockchain. I want to run an script which needs to access ...
0
votes
1answer
14 views

Confusion With Etherscans representation of an Address

I'm trying to get a list of unique addresses that have interacted with a contract. As well as some data included in the events of each transaction. In order to do this, I use the action=getLogs query ...
0
votes
1answer
26 views

Execution gas cost

I use web3 and truffle to get info about my testnet transactions. There are few fields about gas used per transaction, such as: gasPrice, gas, gasUsed. But how to get field 'execution cost'?
1
vote
1answer
41 views

Decoding parameters with inline assembly in Solidity

I Would like to know if there is a solidity equivalent to this web3: web3.eth.abi.decodeParameter() I'm currently looking at something like Seriality, but wondering if there was a supported ...
0
votes
1answer
14 views

What is the cheapest way to send ERC20 to multiple Addresses? [duplicate]

Let's say I got 100 tokens of any ERC20, and I want to send one of each to 100 differents addresses. What would be the cheapest in term of gas between 1) creating a smart contract which takes in ...
0
votes
2answers
88 views

How can I select a single account in Ganache? [duplicate]

Ganache (v1.2.3) provides a list of 10 accounts. They can be easily selected by selecting web3.eth.getAccounts();. However web3.eth.accounts[0] returns undefined as shown below. Not sure how to ...
1
vote
1answer
34 views

Sign message twice with web3

a quick beginner's question... is it possible to sign a message twice with web3? For example Alice creates a message and signs it. Then it is sent to Bob. Can Bob sign the message before he executes ...
0
votes
0answers
16 views

How do I solve this error involving web3 and webpack in my truflle-react box based project?

The project is a truffle-react trufflebox, a bounties creating and solving application. It uses Truffle v5.0.1. This is the home page. Below is the page that displays when you click on the 'Become a ...
2
votes
0answers
36 views

web3: getPastEvents works in Truffle on instance, not in web3 script on page

I am looking to collect the previously logged events of a certain type using getPastEvents. It does not seem to work in my web3 script on my site but it does work in truffle console on a deployed ...
0
votes
1answer
45 views

Remix error: “Expected token LBrace got 'View' function get() public view returns (uint)”

I have this error during the compiling of the code below on Remix. Someone could help me ? pragma solidity 0.4.4; contract SimpleStorage{ uint storeddata; function set(uint x) ...
1
vote
1answer
31 views

Getting address from struct mapping

I have a struct in a library: // lib struct Data { int256 count; mapping(address => int256) indices; mapping(int256 => address) items; } // Also append function in lib function ...
0
votes
0answers
25 views

source.setEngine is not a function

So everything worked fine in truffle 4.1.14, but when I upgraded to 5.0.0 I got this error: TypeError: source.setEngine is not a function at Web3ProviderEngine.addProvider (node_modules/web3-...
0
votes
1answer
25 views

Calling Protected Function From Another Contract

I am trying to call a function in another contract, that is protected with an openzepellin Role library. I am calling availableFunction on the javascript side, which in turn calls protectedFunction. ...
1
vote
0answers
59 views

Error deploying smart contract with web3.js and Truffle HD wallet provider

My web3 version is 1.0.0-beta.41, node version is 10.15.1 solc compiler is 0.4.25 compile.js is successfully compiled with interface and bytecode exports. My deploy.js file const HDWalletProvider ...
0
votes
1answer
57 views

abi.decoder in solidity

Im trying to decode a bytes memory _data parameter directly in a smart contract. Im currently running: var data = await abi.encode("120000000000000000000", user2, OCcontract1.address, "...
0
votes
2answers
95 views

How to get events emitted by a transaction with web3.js

I'm writing a user interface in Javascript and I'm using the web3.js library. I have the transaction hash of a confirmed transaction. I would like to get an array of all events emitted by that ...
0
votes
2answers
42 views

Ethereum Enterprise Blockchain

I am starting a project that I need to build a solution to track products (ex: from farm until it gets to the supermarket) Basically, I need to set up a blockchain structure for my company(private) ...
1
vote
0answers
47 views

Why can't I fetch my Metamask account address with Next.js's getInitialProps?

I'm using Next.js to implement server-side rendering in my Ethereum app, however I can't fetch my Metamask address to display it in the top-right corner of the navigation bar in my index.js file. ...
0
votes
1answer
53 views

Geth - Check balance on --light mode

I am running a lightmode geth daemon, and I want to check the balance of my daemon. I read this answer, which says that I cannot use the command that I am currently using, as it requires support for ...
0
votes
1answer
111 views

How to use sendTransaction to send ERC20 tokens through Metamask?

I have a custom ERC20 token and I want to enable metamask support. By this I mean: 1) The user clicks a "Pay using metamask" button 2) The Metamask payment window pops up and with "Pay 100 ABC ...
1
vote
1answer
97 views

Metamask transaction confirmed but “Internal JSON RPC error”

I am using getWeb3() to instantiate a contract and make calls with, the transaction says that is confirmed but when I open up developer tools there is the following error MetaMask - RPC Error: ...
1
vote
1answer
45 views

Mocha and web3.js without await [closed]

Awaiting the resolution of calls to a node works for me, like this example: describe('some contract', async function () { ... it('data should be written correctly', async function () { ...
0
votes
1answer
37 views

Storing User data on blockchain

I am currently using the structure and mapping to store the user data in the blockchain. In the mapping I am using user's address (msg.sender) for mapping it with structure so every user can only ...
0
votes
0answers
15 views

how to compute smart contract address in native JS or web3.js [duplicate]

I am newbie in Solidity. I've read that the address for an Ethereum contract is deterministically computed from the address of its creator (sender) and how many transactions the creator has sent (...
0
votes
0answers
19 views

How would I use Web3.js to fetch a user's ERC721 tokens?

How would I use Web3.js to see which ERC721 tokens a user has in their wallet and what the ID or index for those tokens is?
0
votes
0answers
29 views

Simple Payment Channel contract is not signing payments and returns false

I have deployed the smart contract of Payment channel and every thing is working fine but at the time of closing the channel signature is not being validate. I think passing the arguments in a wrong ...
2
votes
2answers
259 views

Undefined results for “web3.eth.accounts” in truffle console

truffle(development)> web3.eth.accounts[0] gives output as "undefined" truffle(development)> web3.eth.accounts instead of showing all accounts details gives the below output Accounts { ...
2
votes
1answer
18 views

What's the difference between two params of web3.eth.filter?

I read official manual What the difference between this web3.eth.filter({'fromBlock': 'pending', 'toBlock': 'latest'}) and this? web3.eth.filter('latest')
1
vote
0answers
23 views

Replaying the Bad Parity Hack

On a locally hosted instance of Ethererum I am trying to replay and understand the Bad Parity hack. I have a Wallet and a Wallet Library Contract. Wallet.sol constructor(address lib) public payable {...
1
vote
1answer
25 views

Calling a write function of a contract will deploy a new contract

I'm calling a function that will write information to contract, and MetaMask will list it as a 'Contract Deployment'. It is on the Rinkeby testnet. But if I run it locally using Truffle/Ganache, it ...
0
votes
0answers
22 views

Web3js cannot use payable send from sender to destination

Send transaction no error but not working .Also test with remix and Ethereum wallet working fine only web3js has problems . Sender balance still . Receiver nothing come SmartContract.sol ...
0
votes
1answer
29 views

Calling a contract's function with input parameters and passing ether from Geth/Web3

I have deployed a smart contract which basically splits the incoming funds to the specified addresses based on the entered ratio parameter. Please find the code below: pragma solidity ^0.4.23; ...
0
votes
1answer
49 views

Intergrating metamask in DAPP

I am trying to integrate MetaMask version 5.3.1 in my Dapp. I am unable to call web3 functions like getBalance with the given instance, also I am unable to post a transaction. Is there any ...
1
vote
0answers
23 views

Transaction created by non-miner node is not mined in private blockchain

I create a private chain, and setup two node, one is miner and the other one is not. Block sync between two nodes is fine and send transaction through sendTransaction method is also fine. But ...
1
vote
1answer
25 views

Can I modify a struct property and send it back to the contract?

we are experiencing an issue dealing with structs. We expect to modify a struct property after getting it from an event in web3js, but, it seems that the modify does not apply. Any ideas? Contract ...
1
vote
0answers
50 views

web3 - promise doesn't work as expected

I'm trying to write a code that reads variable, adds 1, sends update call, waits until the transaction is done and then reads the variable again. Console shows that the transaction is complete, but ...
0
votes
1answer
29 views

How to get the same SHA3 hash as soliditySHA3(ethereumjs-abi) returns using web3.sha3 in js?

I'm trying to hash a message as shown here: function constructPaymentMessage(contractAddress, amount) { return ethereumjs.ABI.soliditySHA3( ["address", "uint256"], [contractAddress, amount],...