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
0answers
19 views

Contract call: data out of bounds

I'm working on a nextjs/react project in which i want to fetch the health factor of an address on AAVE. This can be done by calling getUserAcountData(address) on the lending pool contract. I can ...
0
votes
2answers
25 views

Infura returns strange error: `query returned more than 10000 results`

The purpose of the function below is to track USDT that is transferred to and from Yearn and Fulcrum. When I call search_liquidity(_toBlock), I get an error that says Returned error: query returned ...
0
votes
3answers
147 views

i am trying to send ether to a list of addresses from backend

Below are few lines from the contract in which I am basically trying to send some ether to an array of addresses. Now, when can run this code in remix solidity by replacing "value" to "msg.value". But ...
1
vote
1answer
38 views

Getting an error when (attempting to) using Web3js

I'm trying to connect a smart contract to a very simply front end that has html/css/js. I keep getting an error when trying to use web3 to connect - I have the code below but the terminal is giving ...
0
votes
1answer
766 views

Proper way of using allEvents()

I'm trying to get all events for a contract: let events = token.allEvents({fromBlock: creationBlock, toBlock: 'latest'}, (err, res) => { try { let result = events.get(); ...
25
votes
5answers
32k views

How to send ERC20 token using Web3 API?

I created some custom token in Ropsten testnet using this guide: https://steemit.com/ethereum/@maxnachamkin/how-to-create-your-own-ethereum-token-in-an-hour-erc20-verified I can send it to other ...
0
votes
1answer
18 views

Ethereum is not transferred on Ropsten network

Here's my code for signing nd sending a transaction on Ropsten testnet which is working properly. However, the value that is set to '1' eth is not transferred to the target address. var Tx = require('...
6
votes
2answers
2k views

Getting Tx is not a constructor when executing this program

Here is my code. I am trying to send ether from one account to another. var Tx = require('ethereumjs-tx') const Web3 = require('web3') const web3 = new Web3('https://ropsten.infura.io/v3/...
21
votes
4answers
27k views

Unlocking accounts and making transactions in web3.js

This question is related to this one and this one. It also has a partial answer here and here. In the third link the account is being unlocked for a period of time using web3.js: web3.personal....
0
votes
1answer
728 views

TypeError: _getWeb3__WEBPACK_IMPORTED_MODULE_0__.default.eth is undefined

I'm not familiar with webpack, but after reading this error all I know that I import one module that is undefined by webpack. However, I don't know why export default new web3.eth.Contract(abi, ...
1
vote
1answer
692 views

ERC20 tokens transactions' history from Ethereum node

I have a parity node. I developed a web3.js interface on top of it. I have APIs whose job is to fetch addresses' balances and transactions. Example response of transaction API: { tx_hash: '...
0
votes
1answer
23 views

Receiving 'undefined' when using getBalance from web3

I am trying to fetch the balance of an address by web3 and node from Ropsten network with the commands below: var Test = require('web3') var url = 'https://ropsten.infura.io/v3/...' var web3 = new ...
2
votes
3answers
2k views

Accessing web3 object in Chrome terminal using React

I am receiving a "not defined" error when trying to access the web3 object in Chrome terminal. My current setup: running testrpc web3 object successfully instantiated in App.js built app using React ...
0
votes
0answers
14 views

why are transactions per block so small using web3.js?

When utilizing web3.js and calling on the "getBlock" using "latest" as a parameter, there are only several hundreds transactions.. but when I look at the average transactions per ...
1
vote
2answers
72 views

update balance into database [logic help]

If a user deposit money to his Ethereum address that is generated for user after signup. So how to get amount transferred by the user to update that amount into database field? I'm using web3 with ...
0
votes
1answer
59 views

How to act as another wallet when using Truffle exec scripts?

I am writing a seed to add data on the smart contract after I deploy it. I'm using ropsten network, setted up like this in truffle-config: ropsten: { provider: function () { return new ...
0
votes
1answer
25 views

ethereumjs-tx Returned error: invalid sender

When i am trying to send signed transaction via ethereumjs-tx. I get this Returned error: invalid sender web3Http.eth.getTransactionCount(myAddress,"pending").then(function(blockcount){ ...
1
vote
1answer
192 views

Both web3.eth.accounts.create() and web3.eth.personal.newAccount() not working

I'm making a dApp on reactjs. I wanted to create a new account and have done it trying 2 methods this.web3.eth.personal.newAccount() this.web3.eth.accounts.create() I have attached the code below(...
1
vote
2answers
640 views

Out of gas when calling smart contract function from web3/Meteor Dapp

The following smart contract function works when called in the Remix-Solidity IDE and connected to testrpc. function submitAsset(string ownerName, string assetName, string assetDesc, string barcode, ...
0
votes
1answer
114 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
30 views

sendTransaction returns Invalid JSON RPC response

I am trying to send a transaction to a Besu node that I have running locally. However, from the following code, when I run npx ts-node myFile.ts, I get Error: Invalid JSON RPC response: const Web3 = ...
0
votes
1answer
54 views

web3js later versions. Bundle, how?

I'm trying to build the frontend of a dApp, but the web3js makes my head hurt. I need to include it in my project, but the latest web3.min.js i can find is this. I want to use 1.2.1, and i understand ...
2
votes
1answer
285 views

Error on transaction submission: insufficient funds for gas * price + value - web3 v1+

I am trying to submit a transaction via web3 and getting the following error: Error: Returned error: insufficient funds for gas * price + value. Here is my code: console.dir(txParams); const tx = ...
1
vote
2answers
297 views

Compile error when trying to import web3.swift

I am trying to import web3swift into one of my Swift files, but get the compiler error "No such module 'web3swift'". The import statements look like this: "Import Geth" "Import web3swift" In my pod ...
0
votes
1answer
29 views

Write eth address to file

I need to generate several hundred addresses with eth keys and write them to a file, but only iteration numbers are written to the file, what's the problem? for(var i = 0; i < amount; i++) { fs....
8
votes
2answers
11k views

Metamask error: “Transaction Error. Exception thrown in contract code.” (plain HTML + JS front)

I successfully implemented a smart contract using remix in the Rinkeby testnet, and can interact with it from remix. Now I'm building a simple frontend for it but although I have been able to obtain ...
0
votes
1answer
239 views

Trouble running node to test Web3

I'm trying to test basic web3 with node. I have testrpc running and I have the following in a javascript file: var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider("http://...
4
votes
3answers
475 views

USD Coin Balance Check By Web3

Now I am getting trouble on checking the USDC balance in my wallet address using web3. USDC is also said that it is ERC20 token, but when I checked the token contract ...
1
vote
1answer
805 views

Web3 Solidity events do not work any more in Chrome?

Ok, it seems like this issue is only present in chrome browser I am working with Version 64.0.3282.140 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit) Actually I had some ...
0
votes
0answers
16 views

How to catch bad web3 eth node endpoint

In the project I am working on (next.js + react) users will enter their own Infura endpoint to connect on-chain. Now is there a way to validate the endpoint they supplied (in this case their input is ...
0
votes
0answers
17 views

why the below error is thrown when doing transaction with metamask to the truffle

the error is thrown is shown in the below picture.While doing the transaction an error stating ethjs-rpc with payload["id:761..,Jsonrpc:"2.0","params":"0xf8..]
2
votes
2answers
372 views

Difference between eth.newAccount and personel.newAccount

Can anyone explain the difference between `eth.accounts.create()` and `eth.personal.newAccount()` and which one we should use and why? As I am new to ethereum so its very confusing for me. Thanks
3
votes
1answer
785 views

ERC223 Token Fallback Function Usage

I'm currently writing the "Trade" smart contract which is similar to "Crowdsale" smart contract. The only function that I want to add is "sell" function. In general Crowdsale smart contract is used ...
1
vote
1answer
961 views

“couldn't decode uint8 from ABI: 0x” when returning a large fixed array with web3

I'm trying to return a fixed size array. It works fine with a uint8 array of up to 360000 or so. I've only tested on the rinkeby testnet so far. I've tried increasing the gas limit for my call but ...
0
votes
0answers
20 views

Can't call balancer from web3?

I'm trying to call the exchange proxy 2 in truffle console with web3.js and i get a VM Exception while processing transaction: revert. My truffle console is pointing to a ganache-cli mainnet fork ...
2
votes
2answers
534 views

Deploying a contract that calls a contract

What is best practice on deploying a contract called within another contract with web3.js? I have previously gone under the assumption that the contracts must be mined separately, and the caller must ...
1
vote
1answer
168 views

verifying code deployed with web3.js

I am deploying my smart contracts using web3.js and compiling the code using solc. The contracts are deployed successfully with no issues however I am having a bit of a problem in verifying my ...
2
votes
1answer
415 views

How to change block generation period?in POA private ethereum blockchain

my genesis.json like that: "config": { "chainId": 333, "homesteadBlock": 1, "eip150Block": 2, "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "...
1
vote
1answer
200 views

Can't call function from contract using web3.js due to gas issue

I'm building a smart contract and dapp using ganache and web3.js. In my smart contract I have a function (named "add_pilot") which gets 4 parameters and add them to a mapping. It looks like this: ...
1
vote
1answer
150 views

Cannot deploy contract

I'm having difficulty deploying a solc-compiled contract to ganache test network using web3. package.json { "name": "smartinvoice", "version": "1.0.0", "description": "", "main": "index.js", ...
1
vote
0answers
6 views

Get number of logs in block

Given logs are streamed to a client via the eth_subscribe(“logs”) rpc method with a logIndex, is there a way to tell the number of total logs in a block from its header?
0
votes
1answer
13 views

Serialize a transaction

Do you know what is the purpose to serialize a transaction? Here is an example: const serializedTransaction = tx.serialize() Thank you Take care Pierre
0
votes
1answer
2k views

CONNECTION ERROR: Couldn't connect to node http://localhost:8545

I have started geth using below: geth --rpc --rpccorsdomain * --rpcport 8545 --rpcapi personal,web3,eth,net and this is my web3.js code: <script src="/bower_components/web3/dist/web3.min.js">&...
0
votes
1answer
181 views

How to unlock account to deploy contract without using personal.unlockAccount()?

When I have account keystore file on geth node http://192.168.43.201:8545 , I can deploy a contract like below: const web3 = new Web3('http://192.168.43.201:8545'); ... const contract = new web3.eth....
0
votes
2answers
43 views

Script For Emptying Address

Does anyone have a script that can be used to transfer all ether found in an address to another address? The script will constantly check for any incoming ether and make an automatic transaction, ...
1
vote
1answer
35 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 ...
1
vote
1answer
45 views

How to print the value of encoded getter functions of contract

UPDATED: Sorry for Inconvenience, I have updated all my question and accept my apology , being naive user. I have encoded getter functions of my contract i.e. ...
1
vote
1answer
223 views

Calling onlyowner functions using owner's private key

I need to call a function with onlyOwner modifier in my smart contract via web3.js. I want a user of my site to be able to send their information to a white list, but it sends the transaction from ...
2
votes
1answer
272 views

Why would Ganache behave differently depending on geth, web3j, web3js and web3.py?

I have a smart contract token deployed in a Ganache instance. My dapp written with React and web3.js shows the same 10 accounts for eth.accounts as running the same command in the geth console. If I ...
0
votes
1answer
196 views

Cannot Find Module Error for Truffle-contract

Error:- Uncaught Error: Cannot find module './truffle-contract.min.js' at c (web3.min.js:1) at c (web3.min.js:1) at index.html:27 <!DOCTYPE html> <html lang="en"> <head&...

1
2 3 4 5
80