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
1answer
12 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
10 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
14 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
10 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
18 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
12 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
24 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
17 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
0answers
20 views

The send transactions “from” field must be defined on etherum

I am trying to create an E-Voting/Auction system using Smart Contracts. As per the Youtube Tutorial video https://www.youtube.com/watch?v=3681ZYbDSSk&t=217s on 1:25:23. I'm not able to get the ...
0
votes
1answer
10 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
17 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
13 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
16 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
21 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
32 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
35 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
1answer
28 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
18 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 ...
0
votes
1answer
30 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 ...
1
vote
1answer
15 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
32 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
16 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
42 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
41 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
28 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
20 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
23 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
42 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
14 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
22 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
13 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
311 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
1answer
24 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
19 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
26 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
18 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
42 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
19 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
31 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
13 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
21 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....
1
vote
1answer
20 views

What is the difference between eth.contract and eth.Contract?

I don't get it. I've seeing two ways from tutorials on how to instantiate web3. One is.. eth = new Eth(web3.currentProvider) token = eth.contract(abi).at(contract_address); and another is.. web3 = ...
0
votes
1answer
45 views

problem of call() returns null

contract permission{ struct transaction { address payable sender; address receiver; string datatype; Status status; } function getTransactionCount() public view ...
1
vote
0answers
21 views

ERC20 Token support for metamask website payment

I have the following code working in my site to accept ethereum payments in my website via metamask.... <!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/...
0
votes
1answer
43 views

Transaction stuck in 'Pending' state when using 'sendSignedTransaction'

I am trying to execute a transaction by first signing it with my private key using ethereumjs-tx and then using sendSignedTransaction to send the transaction to the network. But somehow the ...
1
vote
1answer
38 views

Not accessing metamask address through web3.eth.getCoinbase

I'm trying to run following code: App = { web3Provider: null, contracts: {}, account: '0x0', init: function() { return App.initWeb3(); }, initWeb3: function() { // TODO: ...
0
votes
1answer
21 views

Async getAccounts doesn't see my account

first time using MetaMask web3 Async getAccounts does not return my Eth account which I see in MetaMask. My fiddle https://jsfiddle.net/ysz11/qcv78h9z/1/ <!DOCTYPE html> <html> <...
0
votes
2answers
28 views

metamask and web3: Invalid number of arguments to Solidity function

my function has only one input string description : function createProposal(string description) { Proposal memory p; p.description = description; proposals.push(p); } and ...
1
vote
1answer
27 views

Reading events of the inner Solidity contract with Web3

Let's say I've got contract A { event E(); function a() public { emit E(); } } contract B { A private a; function b() public { a(); } } Now my Dapp is ...
0
votes
1answer
27 views

How to connect Trust Wallet in Javascript?

I want to use TrustWallet for payments in my project for mobile users. I saw the documents related to TrustWallet web3 API but not getting how to use it in javascript. Can anybody help me with the ...