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
1
vote
1answer
24 views

Node version upgrade for contract deployment throws error

I wrote a solidity contract using version 0.4.24 using OpenZeppline-solidity version 1.12.0. This used to deploy using the Nodejs version 8.12. The Nodejs version 8 is no longer being maintained from ...
0
votes
0answers
11 views

Subscribing to new blocks doesn´t work [ROPSTEN]

I'm trying to subscribe to newBlockHeaders on the ropsten network, but it does not seem to work. The following code works for mainnet but not ropsten. Any ideas? const Web3 = require('web3') const ...
0
votes
1answer
20 views

How to send erc20 token with web3 without smart contract abi?

I created a token in the Ropsten network. It wants abi.json when transferring with Web3. But the token I created did not give it. My token etherscan link https://ropsten.etherscan.io/address/...
0
votes
0answers
15 views

Prevent opening metamask on ethereum.enable/creating new web3 instance [closed]

How can I prevent initializing Metamsk on window.ethereum.enable() or on creating a new instance of Web3?
0
votes
1answer
21 views

Cannot read data from smart Contract with web3 js

Im having trouble reading data from a smart contract I have following js script right here: (bcc-js.js) var contract_address = "0x88e304D8638c31DaC3336917bbE4A152927198D8"; var contract_abi =...
0
votes
0answers
7 views

I've got a problem with the id search function and it displays the following error “Error: hex data is odd-length ”

$("#searchBtn").click(function () { patienttdetailsContract.methods.readPatient(parseInt($("#p_search").val())).call(function (err, result) { console.log(...
0
votes
0answers
8 views

Unable to connect to Geth/web3 from outside AWS using public IP with Websocket

I tried RPC api to connect to Geth/web3 hosted in AWS EC2 using the public IP. But developers have disabled web3 in RPC(HTTP) Web3 api for non local connection. It means that you can only make a web3 ...
0
votes
1answer
25 views

solc-js error: “before each” hook for “deploys a contract”: SyntaxError: Unexpected token u in JSON at position 0

The issue is probably here: const { interface, bytecode } = require('../compile');. interface in the test file is undefined. inbox/contracts/Inbox.sol: pragma solidity ^0.7.0; contract Inbox { ...
0
votes
0answers
18 views

Listening to broadcasted transactions using geth --syncmode light

Since my attempts of using Web3.py to get pending txpool content rely on methods unsupported by Infura (and other) endpoints, I am trying to run a lightweight geth peer. I am using the following ...
0
votes
1answer
21 views

Is there a way to retrieve private key of ganache account with web3?

web3.eth.getAccounts() returns list of accounts. Is there a way around to get the private key of one of the account from the list returned from the above code?
-2
votes
0answers
7 views

ALERT: Transaction Error. Exception thrown in contract code [closed]

Please help!! https://github.com/Mahdi321/DCensus/issues/2 it happens when add a member using form
0
votes
0answers
9 views

Events stop triggering after a while

I created a script that subscribes to PairCreated event on Uniswap using Web3 and Infura API. The event works for a few minutes but stops working after a while (timeouts?). How can I make it watch the ...
0
votes
0answers
24 views

Error: Returned error: gas required exceeds allowance (12487794) or always failing transaction

I am trying to use a script which uses web3.js to transfer a specific amount of ERC20 tokens .I have made this script in such a way that if account doesnt has ether value it will try again and again ...
0
votes
0answers
13 views

the best way to monitor my own account transactions in openethereum

Please I want to know if I subscribe to pendingTransactions with web3 will it monitor and send notifications of accounts pending Transactions only or all pending transactions on Ethereum network. my ...
0
votes
0answers
8 views

All requests routed to submodule when changing its provider in web3js

Using web3.js 1.2.11, I expect the last part of the following code to route requests from the web3.eth.personal module to the IPC socket, and requests on web3.eth to TCP port 7545. let Web3 = require('...
0
votes
0answers
6 views

Rerendering causes results to display twice (possibly caused by async event emission)

This may seem like a web developer problem at first but i think it pertains to how function calls are done in solidity. So basically i have a voting application which triggers an event every time a ...
0
votes
2answers
26 views

Offline creation of signed contract transactions with web3js v1.2.11

I'm attempting to sign a contract transaction offline using web3js v1.2.11. signingAddr = //my eth address signingPk = //my private key // docs: The options object for the contract instance. from, ...
0
votes
1answer
15 views

web3.utils.toWei(web3.utils.fromWei(…))

Is it warranted that web3.utils.toWei(web3.utils.fromWei(x)) is equal in numeric value to x (provided that x is a 256 bit number represented as a string)? If it is not warranted, how to obtain a value ...
0
votes
0answers
33 views

Query returned more than 10000 results with getPastEvents

I am writing a function to sync all transactions on a particular contract from a particular account in my local database to build a dashboard for account owners. I need to fetch all the past transfer ...
0
votes
2answers
14 views

Web3 works on mainnet, not on Ropsten

I have an identical contract on the Mainnet and Ropsten. Both work fine in Remix. Using a python program on my Windows machine, I find that I get an error accessing the Ropsten contract, but not the ...
0
votes
1answer
30 views

MetaMask displaying wrong value when making RPC sendTransaction call

I have been trying to send a transaction using an RPC call with MetaMask's window.ethereum.request injected method. I have successfully sent a transaction before, by using the web3js method web3.eth....
1
vote
1answer
30 views

geth mining not working without --allow-insecure-unlock (geth 1.9.16-stable-ea3b00ad)

I am running a private ethereum blockchain with POA geth --port 3000 --networkid 42 --datadir=./blkchain --maxpeers=5 --rpc --rpcport 8543 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi &...
-1
votes
0answers
17 views

How can I make an API that can receive a transaction hash and return the transaction result?

I have a simple gaming contract where users play dice and bet on the result giving the range (1-100) in which the two dice rolls might result to. It has a payable function called call_bet( ) which ...
0
votes
0answers
12 views

Signing text with special UTF8 characters browser vs node web3js

I am attempting to get consistent signatures / recovery for text containing special characters. For example, the bitcoin symbol U+20BF, ₿ Junk address and private key: ...
1
vote
0answers
15 views

Filter past events with condition

Is it possible to filter past events with a boolean condition? For example I have the following event: event ExampleEvent(uint256 exampleNumber); In my js code I can filter these events with the == ...
0
votes
2answers
47 views

Why do blockchain networks like Ethereum utilize JSON RPC calls and not REST APIs or graphQL?

I'm sorry. This might be a silly question but I am very much new to backends and networking protocols. I can write decent smart contracts but I don't know much about the backend. So... I wanted to ...
0
votes
1answer
24 views

call a contract function which creates a new contract in web3.js makes an error VM Exception while processing transaction: revert

At first I'm developing with truffle v5.1.34, Node v10.16.0, Web3 v1.2.4 To make it simple, I have a Two contracts, DApp and User What i'm doing is call a DApp contract function which creates a new ...
0
votes
1answer
11 views

How to check the current MetaMask network?

How to check the current MetaMask network? For example, if the current network is Rinkeby, I need the string "rinkeby".
0
votes
1answer
22 views

How to make this interact with metamask

I've been trying to make my contract be callable by metamask (so a popup will occur telling the user to confirm) but it does not seem to work, heres what I have come up with so far. Can anyone give me ...
0
votes
0answers
14 views

unable to see the first address using web3.eth.getAddress()

I tried to see all address using web3.eth.getAccounts() It's run perfectly. Next I tried to see the first address using web3.eth.getAccounts().then(function(accounts) {return accounts[0]}) It's also ...
0
votes
0answers
9 views

Trouble making an affiliate program with Ethereum

Is it possible to make an affiliate program with Ethereum without requiring a new user to register before he starts to earn or spend money? (but instead using his Ethereum wallet address as his ...
0
votes
1answer
28 views

ipfs.add is not working

I am trying to upload my file to IPFS and save its hash to my Ethereum contract but neither ipfs.add nor ipfs.files.add is working for me... I have tried usin for loop i.e. for await (const result of ...
0
votes
1answer
36 views

How to set values for Solidity contract state variables from JavaScript front-end?

I am trying to set values to the following contract public state variables from a frontend javascript code. But it seems not working. Contract public state variables: // Current state of the auction. ...
0
votes
1answer
14 views

Web3js events and their callback functions are not aware of component state?

I have problem with web3js 1.2.9 Events triggering works fine and data is alright but I cannot figure out how to use component state in this functions that are triggered by event. I cannot access ...
0
votes
1answer
23 views

WEB3.JS problem

I am trying to use the library “ethereumjs-tx” but it does not work. I get this error message: “TypeError: Tx is not a constructor” on the code “const tx = new Tx(txObject)”. Here is my code: const Tx ...
0
votes
1answer
31 views

Use web3.js without MetaMask

I have <script src="https://cdnjs.cloudflare.com/ajax/libs/web3/1.2.9/web3.min.js"></script> How to use this web3.js on browsers without MetaMask (for read-only Ethereum queries)...
0
votes
1answer
27 views

How to use erc20 token in integer, not decimal

I want to use number as normal integer, not in decimal. For example, when I use uniswap function IUniswapV2Router02Instance.methods.swapETHForExactTokens(1, , , ).send() in my project, an argument ...
1
vote
0answers
17 views

How to get event from geth ethereum node using web3.js

I have created a simple contract where I am trying to write a value to a state variable in solidity smart contract, and emit that written value. I am using Truffle v5.1.28 (core: 5.1.28) Solidity - 0....
1
vote
0answers
15 views

Getting name/decemals of unstandardized token on Ethereum blockchain with web3.js

I understand how to call methods of name/symbol or decemals on ERC-20 tokens but what about tokens that do not have such.. for example this token here https://etherscan.io/token/...
0
votes
1answer
28 views

Warning! Error encountered during contract execution [Reverted] web3

When calling from Remix IDE, it executes successfully. But when calling from web3 v1.2.9, it gives the above error. Here is the contract : https://ropsten.etherscan.io/address/...
0
votes
1answer
27 views

Get current metamask account method not working anymore

I was using the following method to access the selected account on metamask through web3 v1: //metamask method that refresh the active account in the web this.web3.currentProvider....
0
votes
0answers
17 views

Web3 IPC provider connect?

I am using Infura web3 provider to connect etherum but I want to use IPC provider(more secure), How to use IPC provider in ethereum web3.
0
votes
0answers
34 views

Disabling nonce check for go-ethereum for a private test net when using web3js batch requests to send tx

I am using web3js batch.add and batch.execute to send tx for an ethereum private testnet that I have created. I send tx using batch.add and batch.execute (don't prefer to use promises since they ...
0
votes
0answers
19 views

Why does my smart contract method fail when called via Web3.js with more than one argument?

Observation(s): When calling a compiled smart contract method via Web3.js, my contract method createOrder succeeds when the method only accepts (1) argument. Upon updating and re-compiling the smart ...
0
votes
0answers
27 views

Insufficient funds for gas * price + value in Ropsten

I write API for smart contract but its shown error "Insufficient funds for gas * price + value"? My try I have increased my address balance but it's showing the same error. I have changed my ...
0
votes
0answers
8 views

web3.eth.accounts.wallet.create() works on desktop Chrome but not on mobile

The following lines of code work (a generator function of redux-saga in my React app) on desktop Chrome. However, it does not work on desktop Safari, iOS, and mobile Chrome (on Android). Did not works ...
0
votes
1answer
27 views

Which method is efficient to log data in blockchain? Send an event via smart contract or send data in a transaction without value?

I want to log data in Ethereum block-chain. It is obvious that we can create a smart contract that emits events and retrieve data from it. But is sending a transaction with data but no ETH value (just ...
0
votes
1answer
23 views

Error when retrieving the instance of a deployed contract

I have developed a EnergyExchange DApp in the Ganache local network with React that consist of one main contract "EnergyExchange". This main contract has a function to deploy new Agent ...
0
votes
1answer
13 views

Error when calling a get function from a deployed contract instance

I have developed a EnergyExchange DApp in the Ganache local network with React that consist of one main contract "EnergyExchange". This main contract has a function to deploy new Agent ...
0
votes
0answers
19 views

How to connect local private geth nodes to the web page without using metamask or mist?

I'm developing a web wallet similar to meta mask that can make transactions or can create accounts from UI. Frontend is developed using React. Blockchain is implemented in geth.I'm using truffle react ...

1
2 3 4 5
79