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
13 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 "...
1
vote
1answer
26 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
24 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
15 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
20 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
14 views

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

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
25 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
6 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
20 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
9 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
17 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
8 views

Error send token

let minABI = [ // transfer { "constant": false, "inputs": [ { "name": "_to", "type": "address" ...
0
votes
1answer
36 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
32 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; ...
0
votes
0answers
24 views

How to deploying a contract address on the front-end?

So I'm using web3@0.26.0 to deploy my contract so I can get my contract address from it. And I used it from my backend too and it works. But when I want to implement it on my frontend, I've got an ...
0
votes
0answers
10 views

How to save contract address to database with web3js and mongoose when I deploying a contract?

I wanted to get my contract address after it deployed, and then save it into my mongoDB. But instead of that, my contract address is deployed after it. So my mongoDB won't save my contract address. ...
0
votes
0answers
15 views

Handling a promise in a return function

I am trying to console.log the blockNumber that my transaction was confirmed in with the following code: web3.eth.sendTransaction( {from:account3, to: account2, value: web3.utils.toWei('1','ether'...
0
votes
2answers
28 views

Deploy contract dynamically based on user request

Inspired by this blog: https://medium.com/coinmonks/escrow-service-as-a-smart-contract-the-business-logic-5b678ebe1955 I want to deploy contract once a buyer want to purchase a service. However, I ...
1
vote
1answer
15 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/...
1
vote
0answers
16 views

how can i translate the ethers.js “getSigner” utility to web3?

I have a web3 object but I'm working off an example that uses ethersProvider.getSigner(). Is there an equivalent (or mostly equivalent) in the web3 library? For reference, the ethersProvider is ...
1
vote
0answers
20 views

Pass hexadecimal literal to contract using web3js

I have a hex literal that I need to pass into a contract using web3, and I'm not sure how to go about formatting it. In solidity, its formatted like so: hex'...
1
vote
0answers
36 views

Error while installing web3@1.0.0-beta.26 on Windows 10

I am getting the following error while installing web3@1.0.0-beta.26 on Windows 10. npm ERR! code ETARGET npm ERR! notarget No matching version found for web3-core@1.0.0 npm ERR! notarget In most ...
0
votes
1answer
17 views

How do I load the `web3` module using the html `script` element?

How do I load the web3 module into the frontend of my application using the html script element? I have already installed the web3 module using npm. This is the path to the web3 module in my app ...
0
votes
0answers
16 views

which is a better method to use for signing messages between two parties in web3?

I have been searching for a while for the most secure and supported way for off-chain channel messaging.....so i was using web3.eth.sign(address, keccak256(msg)) for singing messages ....but then used ...
0
votes
1answer
23 views

How to get ethereum gasPrice from a transaction hash?

I need to get the gasUsed and gasPrice so that I can calculate the correct amount of gas required for a transaction. I can get the gasUsed using: var accountOneReceipt = await contractInstance....
0
votes
1answer
11 views

Map error status 403 for https://cdn.ethers.io/scripts/ethers-v4.min.js

My webpage is not rendering the a table with sample code below. I can see on the Browser Console the promised block objects but this message shows: Source map error: request failed with status 403 ...
0
votes
0answers
23 views

How to enable and use the accounting module?

I found the accounting module in this line and want to use them. i attached the accounting module to parameter --rpcapi accounting when run console node but could not found this module. run node: ....
0
votes
0answers
10 views

HyperLedger Mobile Application Development

For market reasons I am studying the HyperLedger platform. In the last year I studied the Ethereum platform where I developed web/mobile applications. My question regarding HyperLedger Fabric is: On ...
-2
votes
0answers
33 views

My vote Count is not updating (https://github.com/llSourcell/Your_First_Decentralized_Application) i'm trying this project

Total vote is not increamenting, code link web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); abi = JSON.parse('[{"constant":false,"inputs":[{"name":"candidate","type":"...
0
votes
1answer
36 views

How to use window function in controller (node.js)?

So this is my users controller to upload a file : exports.postUploadFile = (req, res, next) => { var ethereumURI = req.body.ethereumURI; var abi = JSON.parse(req.body.abi); var ...
0
votes
0answers
37 views

web3.eth.getAccounts() returns empty array

I'm trying to get accounts like that: window.web3.eth.getAccounts( (error, accounts) => { console.log(accounts, error) } ); but it keeps returning an empty array. I'm running Ganache and I can ...
1
vote
1answer
16 views

How to replace Metamask Pop-Up with my own UI

I was wondering if I can replace the Metamask pop-up with my own pop-up/user interface. Example: Currently on my dApp a user clicks "Buy Token" and a Metamask modal pops up and says the usual ...
0
votes
1answer
53 views

Failed to load events from Block 0 on page refresh in Vue app

I'm trying to get event data from the web3 API using events method. In my Vue app methods, I have a method, newDsoValue, that will watch for the events from the beginning and also for every newly ...
1
vote
0answers
11 views

All contract calls returning null

I'm building a browser extension that uses web3.js over websocket to Infura and for some reason all my contract calls are returning null in my production build. When testing the app as a web app in ...
0
votes
0answers
17 views

Contract cannot create new Contract in Quorum

My main contract called SurveyFactory creates new Survey forms: pragma solidity = 0.5.9; import './Survey.sol'; contract SurveyFactory { address[] public surveyList; address public Owner; ...
1
vote
0answers
25 views

Cannot read property 'type' of undefined - abi-coder

I'm creating a simple voting contract. It is deployed with truffle and infura. This is the contract code: pragma solidity >=0.4.21 <0.6.0; contract Voter { struct OptionPos { uint ...
2
votes
0answers
24 views

How shoud I properly initialize DApp and get account address?

I am writing DApp in react, and basically I want to initialize web3, unlock account, and display it. Having web3 in my package.json In the onload I've tried to go following: let Web3 = require('web3')...
0
votes
0answers
14 views

Getting TxnHash but not recipt web3j android

I dont know if question is asked before but I did not find any. I am facing this issue since yesterday. I am able to get balance and txnHash but it never shows on etherScan.io , nor it gives me txn. ...
1
vote
1answer
13 views

Scope Issue: Not successfully storing accounts after using web3.eth.getAccounts()

I am having trouble with the following code: var accounts = [] let accounts = await web3.eth.getAccounts((error, result) => { accounts = result; console.log(accounts); }); console.log(...
0
votes
1answer
11 views

What would web3.js respond with in this case?

I have a mapping to a struct in my contract mapping (uint=> Student) students; struct Student { bool passed; } Now I want to call a particular student with a particular ID to see if he has ...
0
votes
0answers
22 views

Alternative to Ethersweep

Im experimenting with the erc20 token. When trying to write contract on etherscan the Web3 connection just don't work, and I don't know why. But then I thought that perhaps Ethersweep could do ...
0
votes
0answers
54 views

How to send transactions to smart contract in batch?

I have this smart contract function: function addOneUser (User memory _user) public { bytes32 hash = keccak256(abi.encode(_user.name)); users[hash] = _user; } Using ...
1
vote
2answers
52 views

Analogue web3.eth.accounts.sign (from web3js) in web3py

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function ...
0
votes
1answer
20 views

How to send a transaction with large data ethereum?

I am trying to send an array of object (tuple) to smart contract. function addManyUsers (User [] memory _users) public { for (uint i = 0; i < _users.length; i++) { bytes32 ...
0
votes
1answer
16 views

Get return data from sendSignedTransaction

I need access to data returned by function that also changes state. Example: I have a contract live on testnet with a function that creates and then returns a new ERC20 token. contract MyContract { ...
0
votes
1answer
21 views

Uncaught TypeError: web3.eth.Contract is not a constructor

For whatever reason, when I attempt to set an instance of a contract in a javascript file, I get the following message in my console: Uncaught TypeError: web3.eth.Contract is not a constructor At ...
0
votes
0answers
16 views

Promise Function doesn't wait till transaction end

I am creating a session Contract then get it's public key using event on promise function 'loadSessionContract' but it run before 'creatSessionPromise' finish transaction so I got empty address what I ...
0
votes
1answer
18 views

Html interaction with smart contract via web3.js

I have a html code interacting with my smart contract via a local test rpc local host. I was just wondering if I deploy this contract to the main network instead of using test rpc, what should be the ...
0
votes
1answer
21 views

Do smart-contracts work as APIs?

Is it possible to put a smart contract "behind" a restful API, i.e. expose my contract functions and properties through restuful API where I can make RPC to it? Or does it work as an API already, but ...
0
votes
1answer
24 views

How to print “string” from Solidity in React?

My smart contract function is : function sNName(uint z)public view returns(string memory) { return abc[xyz[z].name]; } Where abc represents a mapping (bytes32 => string) In my .js file, I ...