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

How to pass array parameter. Drizzle

Is there have a way to pass array parameter from the drizzle to my contract ? I want to pass an array of uint[] i have read a lot about getData() function and encodeABI but how to use it in Drizzle ?
0
votes
0answers
11 views

isListening returns an error when false is expected

I'm attempting to verify the status of the network provided by metamask with web3.js by using web3.eth.net.isListening().then(console.log) The method works when I'm connected. However, console ...
0
votes
0answers
22 views

What is best way of setting and getting string=>uint pairs in Solidity?

I am developing a game smart contract and it has 20 numerical settings. like time, fee, difficulty etc I want to access these values using identifier throughout contract get all these values from ...
0
votes
1answer
34 views

Get past events of a contract without ABI using Web3?

I'm building a simple explorer and I would like to list events emitted by contracts. Since I can't know the ABI of each contract, is it possible to get past events from a contract using Web3? If I ...
0
votes
3answers
84 views

web3.eth.sendSignedTransaction executed successfully but never any ETH transferred actually

as you see in below, i the raw transaction has been set by the gas simplify value, the returned value is an implemented transaction hashcode, but never assumed result by this transaction figure out ...
0
votes
1answer
14 views

How can I pass struct as function parameter with ABIEncoderV2 from outside?

have this code: struct UserScore { address user; uint score; uint time; } function getWithStruct(UserScore _user) public view returns (address, uint, uint) { return (_user.user, _user....
0
votes
1answer
21 views

get Transfer events from 0x0 address for ERC20 token

I am trying to get all the events that originate from zero (0x0) address in order to capture the mint activity for my ERC20 token. Here is my code snippet: var instance = web3.eth.contract(abi).at(...
0
votes
1answer
50 views

What is the difference between create and newAccount in web3js?

There are two ways to create account one is web3.eth.accounts.create() and web3.eth.personal.newAccount(); function, When I use newAccount() function account is created in my local geth client but ...
0
votes
0answers
26 views

How to handle password for unlock Account in web3?

In web3 there is function web3.eth.personal.unlockAccount(address [, callback]) to unlock the account so whenever we call the smart contract function we need to unlock the account in geth client ...
0
votes
0answers
20 views

How to check whether a contract has certain function? [duplicate]

How to check whether a contract has a function with certain name (with web3js)?
0
votes
1answer
95 views

How to deploy Smart Contracts With Web3 Using Async/Await?

This is my Javascript code. I keep getting an error that states Error: No privateKey given to the TransactionSigner. at TransactionSigner._callee$ (/Users/payton/WebstormProjects/Esgro_DAPP/...
0
votes
1answer
41 views

Web3.js to decode encrypted data using my private key

It's very similar to this question: How to decrypt an encrypted message using metamask? who was put one year ago. As user, I would like to store data safely on the blockchain, data that I want to ...
0
votes
0answers
48 views

Web3 Websocket Connection To Infura Rinkeby Ropsten

This is my Javascript code. I keep getting an error that states (node:30062) UnhandledPromiseRejectionWarning: TypeError: privateKey.startsWith is not a function I am using node 12.1.0 & ...
1
vote
1answer
23 views

Web3-eth-debug “Debug is not a constructor”

I use nodejs to execute a javascript that interacts with my local instance of Ganache. I would like to use the web3-eth-debug module to get information about my transactions. However after installing ...
0
votes
0answers
32 views

Can value of a public variable in Solidity be called and returned by web3?

How to get value of a public variable in Solidity be called and returned by web3?
0
votes
1answer
14 views

Cannot call function even though it is present in the jsonInteface

I have a simple contract with a simple test-function: pragma solidity ^0.5.0; contract TestContract{ uint public a; uint public b; constructor(uint _a, uint _b) public { a = _a; b = _b; } ...
0
votes
0answers
63 views

Hoiw to convert string to address with web3

I am getting address value with html input as string value how do we convert the string to address for parsing with truffle-contract. Here's the method I am using: registerAirline : async() => {...
0
votes
0answers
21 views

address.transfer executes but doesn't make the transfer

I'm using Metamask and web3.js to connect with a donation smart contract. Following is my JavaScript function: function withdraw(){ const contractInstance = connectToContract(); var ...
0
votes
1answer
27 views

Code not returning when using websocket provider in web3

Below are two code snippets. I have created a 'ganache-testing.js' file and running it using node ganache-testing.js command Web3 = require("web3"); provider = new Web3.providers.HttpProvider("http:/...
0
votes
1answer
27 views

How to differentiate a smart contract from a common wallet?

Having an Ethereum address, I need to check whether it is a wallet or a token (ERC-20 contract). How to check? (I need to implement it with Web3js.) Ideally, it should also reject contracts which ...
1
vote
1answer
39 views

When do you use ganache-cli and when do you use ganache-core?

I have seen two usages over the internet 1. const ganache = require("ganache-cli"); web3.setProvider(ganache.provider()); 2. const ganache = require("ganache-core"); web3.setProvider(ganache....
1
vote
1answer
43 views

Getting the transaction hash on function call

I am new to Solidity, Web3, and Ethereum. I am trying to build a web application through which users can upload a file to IPFS, then store the IPFS hash in the blockchain. I am using the React truffle ...
0
votes
1answer
29 views

Transaction completion in Ethereum smart contract

How can I calculate the deployment time and completion time of a smart contract transaction using web3.js?
0
votes
0answers
193 views

Web3 Cannot read property 'apply' of undefined

I'm new to dapp and trying to follow iwaldman to build an ipfs-image-dapp. Here is the repo: https://github.com/iwaldman/ipfs-image-dapp. But running yarn start gives the error Cannot read property '...
0
votes
1answer
40 views

Setting array.length to 0 triggers an error on solidity 0.5.0

Why setting array.length to 0 triggers an error ? I have a function that deletes an element from a dynamic array of structs within a mapping as follows: mapping(address => MyStruct[]) public ...
0
votes
2answers
51 views

How to read uint256[] array from a method in a smart contract?

I'm using this function in my smart contract. It returns an uint256[] array containing the tokens that the user owns. /** * @dev Returns all of the tokens that the user owns * @return An array ...
1
vote
1answer
42 views

No web3 instance injected following the dApp University Tutorials

I've been following Dapp University's videos on how to make IPFS uploads with Euthereum Smart contracts, and after I manage to 'npm run start' in the command line it opens up the HTML, but it always ...
1
vote
1answer
216 views

Web3 - Cannot read property 'clearSubscriptions' of undefined

While creating a web3 instance, and attempting to call setProvider with a valid provider (Ganache), I get a TypeError. TypeError: Cannot read property 'clearSubscriptions' of undefined Steps to ...
3
votes
2answers
31 views

Auction contract problem regarding highest bid display

I have an Auction contract which has a function like this: function bid() payable{ //calculate and store highest bid value } But because each transaction takes time to mine, so when a user bids ...
1
vote
1answer
68 views

truffle unbox react - front end is unable to read / set state of the contract

I am experiencing problems with the Truffle React boilerplate code that the front end is unable to read / set state of the contract. Here are the details: I unboxed the React boilerplate using ...
0
votes
1answer
50 views

How do I deposit Ether to Smart Contract using Web3.js

So I am creating a web application that interacts with a smart contract that I deployed on the Ropsten TestNet. I am able to withdraw ether from the contract to my Metamask account using a withdraw ...
0
votes
1answer
66 views

Unable to deploy the smart contract using solc compiler in mac

I am trying to deploy the Lottery contract using solc compiler of verison 0.4.17 but it's showing me nothing. But the same contract is working good in the remix ide. I providing you the the Solidiy ...
0
votes
1answer
98 views

The method eth_sendTransaction does not exist/is not available on infura

Im trying to send transaction to simple greeter contract with web3.js on infura node.while doing soo, Im getting this error. throw errors.InvalidResponse(result); ^ Error: The method ...
2
votes
2answers
63 views

Metamask injects one account in web3, but calls contracts using another account

Building a React app, MetaMask injects web3, I get accounts[0] from getAccounts(), then pass it to my contract functions together with other parameters. I want my modifiers to lock incoming function ...
0
votes
1answer
40 views

signing transactions with web3.js

Im trying to create a node.js based dapp that interacts with ropsten ethereum network via infura node.here we need sign transaction with web3.js. but the code showing error from the contract side. ...
0
votes
0answers
25 views

Is latest block returned by eth.getBlockNumber fully processed

According to web3 docs, web3.eth.getBlockNumber returns the number of the most recent block. My question is simple. Is it safe to assume block's transactions and events are already in the node or ...
0
votes
1answer
67 views

Sending transaction with web3.js

I'm trying to use web3.js with infura.io to interact with my smartcontract. here is my simple greeter contract code pragma solidity ^0.5.7; contract greeter{ string greeting; function greet(...
0
votes
0answers
46 views

Contract has no network id set, cannot lookup artifact data

I am using web3 v1.0.0-beta.37 and truffle contract for server.js configuration. I have defined two contracts FlightSuretyData.sol and FlightSuretyApp.sol FlightSuretyApp contract access functions ...
1
vote
1answer
75 views

How to open metamask erc20 transfer window using web3 apis?

In my frontend I have 'withdraw' and 'deposit' buttons. I want to display the metamask screen that comes after clicking on the deposit and send buttons (of metamask) when the user clicks on the ...
0
votes
1answer
21 views

How to compare an address with an address using web3js?

I've been reading and trying but to no avail. I'm trying to compare the current wallet address in MetaMask with the wallet address which owns a certain token via a smart contract method "ownerOf" ...
2
votes
2answers
415 views

How to connect with public Ethereum Blockchain on a backend/web server?

In the backend of a Web application I have to communicate with the public Ethereum Blockchain. On local development machine, I run ganache as testrpc and connect with such a line of code: web3 = new ...
0
votes
2answers
65 views

Stop listening to / watching a contract (Web3)

Here is what I am trying to do (Web3 1.0): Deploy a contract Wait until Nth confirmation. Then stop getting updates from the contract. My code: var myContract = new web3.eth.Contract(_abi, ...
0
votes
0answers
22 views

How can I store the hash of a set of data in the ethereum and make the chain validated always?

I am working on a University Management System and I want to develop the system using Centralized Database like Mysql and to keep the data safe I want to use blockchain to store the hash of the data ...
0
votes
2answers
34 views

Load accounts to truffle

I'm using truffle v5.0.14 to handle my contracts. All was well while developing with ganache, but when I wanted to deploy to the real network (a private one) I have problems with the account. The ...
0
votes
0answers
25 views

how to send a payment transaction using web3js… and fetch contract address dynamically using web3js without hardcoding in app.js

function sendPayment(uint orderNumber) public payable{ //restricting only buyer of partitcular order can make payments require(Orders[orderNumber].buyerAddress==msg.sender); //checking ...
0
votes
2answers
66 views

How to wait for balanceOf before I execute a transfer?

Ok, I'm new into JS and web3 and MetaMask. I'm still lost about Promise and async/await after reading them for 5 times! I want to call my smart contract balanceOf method to check if there's enough ...
0
votes
0answers
73 views

Store data on ethereum blockchain from a text file

I have a simple smart contract running over a local Ethereum node. It has two functions: one for sending data and another for retrieving it back. I have a text file and want to send data from it to ...
0
votes
1answer
60 views

Unhandled promise rejection (rejection id: 1): Error: Transaction has been reverted by the EVM:

I don't know where i'm doing mistake. I have deployed my contract through remix and truffle and it was deployed without any mistake but now i'm deploying it from web3 solc@0.4.24 version and EVM is ...
0
votes
0answers
47 views

how can I transfer ERC20 tokens from user address to other user address using web3.js and ethereumjs,

This is code I have used to send tokens to other account from token holder account. below code is working, transferring token from contract address. Tokens: 500000 A Account having : 1000 Tokens B ...
0
votes
2answers
85 views

Why web3.version.api shows undefined for web3 1.0 and not undefined for web3 0.20.3?

I'm trying to use MetaMask and web3js to talk to my smart contract. Below are my test codes. This is without defining a web3 js file and I get the result "0.20.3" at console. <script> window....