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
0
votes
1answer
47 views

Solidity event not showing up from Web3.js

I'm trying to set up an event in Solidity and listen to it from Web3 but I keep getting a null response. Here's my code: The relevant part of the contract: event NewUser(string userid); function ...
0
votes
1answer
109 views

How do I create a MetaMask Connect request to auth a wallet with MetaMask

I am looking for how to authenticate completely in the browser with MetaMask, presumably by having it sign with some private keys and prove that the user owns a wallet that lists the corresponding ...
0
votes
1answer
69 views

Calling signature functions in web3.js 1.0 reports invalid address and cannot read address property

I am doing a project with inserted Metamask to achieve on-click blockchain account login. When I am calling the signature function web3.eth.sign("Hello world", "...
0
votes
1answer
40 views

Where Do I Find web3.min.js for Beta 55?

There is this issue on github (among several other duplicate complaints): https://github.com/ethereum/web3.js/issues/2623. There is also this stack question: How can the web3 library be imported in ...
1
vote
2answers
50 views

Can anybody Point out the Difference between Web3.eth.sendTransaction and web3.eth.signTransaction?

Do we need to sign the transaction by web3.eth.signTransaction after initiating transaction via web3.eth.sendTransaction. for example: when I do: web3.eth.sendTransaction({ from: accs[0], ...
-1
votes
1answer
63 views

MetaMask - RPC Error: The method personal_newAccount does not exist/is not available

When I execute following code then it show me: MetaMask - RPC Error: The method personal_newAccount does not exist/is not available if(typeof window.web3 !== "undefined" && typeof window....
4
votes
1answer
145 views

signed message different on opera and metamask

I am using the following code to sign a message: web3.currentProvider.sendAsync( { jsonrpc: '2.0', id: 1, method: 'personal_sign', params: [ `My account is ${this.accounts[0]}`...
0
votes
0answers
11 views

Can web3js accurately estimate a transaction that includes an external call?

Can web3js accurately estimate a transaction that includes an external call? For example, will it be accurate in estimating: (bool _success, bytes memory _response) = _to.call.value(_value)(_data); ...
1
vote
1answer
47 views

How to get timestamp of an event log in emitted event from smart contract

I want to get the timestamp of an event. How can I get time of event fired, if the event data does not contain any time value?
0
votes
0answers
28 views

web3 error: private key length is invalid

I was trying to create my own wallet on etherum test network Rinkeby. When I successfully created wallet: const newAccount = await web3.eth.accounts.create() and got wallet address ...
0
votes
0answers
16 views

How to obtain data from a private PoA Ethereum Network?

I want to fetch data from a private PoA ethereum network running on a local computer. The data will be used for anomaly detection. I need contract interaction data (function calls etc.), to observe ...
0
votes
0answers
10 views

Prompt Metamask to send eth with Web3

I understand this as the pattern to send a transaction with web3: web3.eth.sendTransaction({ from: myaddress, to: toaddress, data: web3.eth.abi.encodeFunctionSignature('whitdrawETH()') ...
2
votes
0answers
22 views

What is the difference between signing a document, signing a transaction and signing a message? (very basic)

As per my limited knowledge in Ethereum, user can sign the object(doc, Tx, msg) for the security purpose and with the public key other user can get that object. But not understand the difference ...
0
votes
1answer
64 views

Why Web3 event callback fires multiple times same as the number of the solidity smart contract emitted that event in past?

I am just learning, solidity with react and web3 and I am facing the issue on page load the callback event of web3 called multiple time the number is same as I called a solidity function and that emit ...
0
votes
0answers
32 views

Cannot access myContract.events in web3.js version 0.20.7 [duplicate]

It seems that I do not have access to certain tools in web3js that allow me to subscribe to events. When I tried to use contractInstance.once('allEvents', callback) after instantiating a contract, I ...
0
votes
1answer
31 views

Call approve function() doesn't work

myContractInstance.methods.approve('0x...', 300).call(function(error, approve){ if(error){console.log(error)}; if(approve){console.log("allowance for this address :"+ approve)}; ...
0
votes
2answers
39 views

Store/retrieve data doesn't work using node

i trying something simple, store and retrieve a data in a smart contract, but when i want to retrieve the data, nothing is returned. solc version is 0.4.24 web3 version is 1.2 Solidity code: pragma ...
0
votes
1answer
36 views

Is there a web3 api written in golang to interact with Eth nodes?

I'm looking for a library that can easily interact with Ethereum nodes that is similar to Web3.js. go-ethereum is written entirely in go so I would of thought I could write scripts pretty easily.
0
votes
1answer
41 views

How does .on work in Web3 1.0, and why do I get duplicate results?

I don't understand what .on event handler does in Web3. Take this example for signing a transaction: web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex')) .on('...
1
vote
1answer
38 views

How do I asynchronously wait for Contract.events.MyEvent data to be returned in Web3 1.0?

The documentation is sparse, and the examples all mix async, arrow callbacks, and promises. One problem I've run into is while subscribing to an event, I can't seem use asynchronous syntax within or ...
0
votes
1answer
44 views

Sending value to a solidity contract method from web3 results in `Invalid Tuple Value` error

I'm sending values to a solidity 0.5.1 method using web3 and keep getting an invalid Tuple value error. Here's the relevant contract code: struct mystruct { bytes32 id; string str; } ...
1
vote
1answer
162 views

Solidity and Web3js codes are not working inside the private Ethereum(geth) network but same codes are working in public ethereum

geth version : 1.9.0-stable-52f24617, node version : v10.16.3, npm version : 6.9.0, web3 version : -- web3@1.0.0-beta.36. genesis.json: { "config": { "chainId": 9663080, "homesteadBlock": 0, "...
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
1answer
39 views

How to find the value of erc20 token sent out using transaction hash

How can i find the value of erc20 token in a transaction using the hash generated? I can't seem to find answers anywhere. Edit:I found that it is possible to use w.eth.getTransactionReceipt('...
0
votes
1answer
66 views

Using vanilla javascript with web3 and metamask

I have searched severally on how to use web3 with metamask without nodejs without any success. I want to be able to get an instance of a user's metamask account through web3 and vanilla javascript ...
0
votes
0answers
17 views

Is there a way to broadcast/send transaction using web3js using token that is not ethereum?

My question is: I am trying to send a transaction using a cryptocurrency very similar to ethereum, in fact their code is almost copy pasted from ethereumjs: https://github.com/CSEPlatform/cse-tx/blob/...
2
votes
1answer
49 views

Uncaught (in promise) Error while opening and doing transaction on private ethereum blockchain using web3 and go-ethereum

I am trying to integrate a react app with go-ethereum using web3js. an event Onsubmit will do the following: 1. Create an account. 2. Open the account. 3. Approve a smart contract with the created ...
0
votes
1answer
49 views

Web3 0.20 contract deployment

environment: Web3 0.20.7,Infura,node.js(backend) Deploy contract with Web3 0.20.7 pragma solidity ^0.5.1; contract Bang{ address holder; address proxy; constructor (address _holder, ...
0
votes
1answer
21 views

Listen to transactions on EOA addresses

Haven't seen any documentation that shows that this is possible. Could someone direct me to something that would allow me to listen to transactions on non-contract addresses.
0
votes
0answers
41 views

call an api GET method in dapp - blocked by CORS policy

I am trying to create a dapp(web3js - truffle) where an API - GET method has to be implemented by setting 'x-api-key' on header.(OS - Linux) Here is the code : app.js //1st method var XMLHttpRequest ...
0
votes
0answers
32 views

invalid jump destination error in a contract execution

I am trying to swap dai to eth in Rinkeby testnet using the Uniswap smart contracts. I get the invalid jump destination error and the transaction fails. I do have enough ether in my account. Any ...
0
votes
1answer
49 views

Subscribe to wallet address

I'm stuck on how to subscribe to events to non-contract addresses. Is this possible? All I'm seeing is subscription to eth contracts only.
0
votes
1answer
38 views

Deploy contract didnt resolve the promise

im facing a problem deploying a simple smart contract. When i use ganacha-cli, the program enter in a loop of confimation event, counting from 1. Thats the first problem. Output: Account: ...
0
votes
1answer
23 views

Can Dapps set cookies

Is it possible for a Dapp that uses the metamask/chrome to set up a browser cookie? or can a cookie set by another website like facebook, read some information or at least know that a dapp has been ...
0
votes
0answers
16 views

How to integrate a serial port into web3 in order to deploy Transactions?

i use a virtual serial port that sends data from a python script to node js serialport. Everytime i send data from my python script i want to create a Transaction in web3. parser.on('data', function ...
0
votes
1answer
39 views

i'm creating new account and when i get the balance for that account it returns 0 and cant do any transaction saying dont have enough funds

How to load funds/ether into newly created account. I'm using Ganache and Web3js var web3 = new Web3("HTTP://localhost:7545"); var privateAccount = await web3.Personal....
0
votes
1answer
95 views

'ALERT: Trying to call a function on a non-contract address' Why Do I Keeping This Error?

This is the error from metamask directly: This is the error I get once after I submit the information to IPFS: My Smart Contract: pragma solidity 0.5.3; //Imports for safe math operations import "...
3
votes
2answers
76 views

What happened to the official documentation of web3.js v1.0?

It should be at https://web3js.readthedocs.io/en/1.0/, but now I'm getting this: Does anybody happen to know why this wonderful tool has been taken off line?
0
votes
0answers
36 views

Why am I getting an out of gas error on transactions that should instead revert due to a require statement?

I've thoroughly tested a contract using Ganache, and when calling a method with a value that would trigger one of its require statements, it reverted as expected and returned the error message I ...
0
votes
0answers
24 views

Web3.js doesn't fire event callbacks anymore

I have a small dapp that uses web3.js to interact with a contract. I have one event listener: let activateEvent = nexusContract.events.Activate({ _member: defaultAccount }) activateEvent.watch((...
0
votes
1answer
26 views

Deposit event is not call while contract get token

My contract pragma solidity ^0.5.0; contract Transfereventaction { event Deposit( address indexed _from, bytes32 indexed _id, uint _value ); function deposit(...
0
votes
0answers
37 views

Can I use a truffle-contract instance in the data field of web3.eth.sendSignedTransaction?

I use truffle-contract for contract abstraction. const myContract = TruffleContract(MyContractArtifact); myContract.setProvider(web3.currentProvider); I'm using Infura as the web3 provider so need ...
1
vote
1answer
53 views

Request to http://localhost:8545 from https website

I am building a website that should interact (from the browser, not back-end) with custom Ethereum nodes, including local, something like MyEtherWallet. I can connect to ganache http://localhost:8545 ...
0
votes
0answers
8 views

console.log(App.ticTacToeInstance.events); in createNewgame function getting undefined

import Web3 from "web3"; import { default as contract } from 'truffle-contract' import ticTacToeArtifact from "../../build/contracts/TicTacToe.json"; import $ from "jquery"; let TicTacToe = ...
0
votes
1answer
32 views

Why txHash in sendSignedTransaction giving Undefined value on sending on rinkeby testnet

let Tx= require('ethereumjs-tx').Transaction; const Web3= require('web3'); const url='https://rinkeby.infura.io/v3/d4dbc79ea192404fb42689cc55ce2fc0'; const web3 =new Web3(url); const account1= '...
0
votes
0answers
12 views

Getting error when importing, no error when using code in single file: Failed to execute 'postMessage' on 'Window'

I am trying to access the web3 object injected into my browser by Metamask. I am using custom rpc (). I can see my accounts and correct balances in Metamask. I have the following code: //web3.js ...
0
votes
1answer
193 views

html:82 Uncaught ReferenceError: App is not defined at HTMLButtonElement.onclick (html:82)

It's showing me uncaught reference error in my index.html file <div id="candidate-box"></div> <button class="btn btn-primary" onclick="App.vote()">Vote</button> ...
0
votes
0answers
13 views

Error send token

let minABI = [ // transfer { "constant": false, "inputs": [ { "name": "_to", "type": "address" ...
0
votes
1answer
57 views

How Do You Parse Web3 Retuned JSON Objects of Events?

I am using Web3 1.0 to listen to events from a contract like this: tokenContract.events.AddressList({ fromBlock: 6020474, toBlock: 'latest' }, (error, events) => { ...
0
votes
1answer
39 views

Problem: Values from a transaction(web3) are not stored in datastucture defined by Solidity

First of all i use Truffle and Ganache. I made a smart contract with solidity defining the following structures: struct TimestampproTeil { uint Fahrwerk; uint Chaussy; uint Kabine; ...