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
23 views

Call approve function() doesn't work

myContractInstance.methods.approve('0x...', 300).call(function(error, approve){ if(error){console.log(error)}; if(approve){console.log("allowance for this address :"+ approve)}; ...
0
votes
2answers
33 views

Store/retrieve data doesn't work using node

i trying something simple, store and retrieve a data in a smart contract, but when i want to retrieve the data, nothing is returned. solc version is 0.4.24 web3 version is 1.2 Solidity code: pragma ...
0
votes
1answer
23 views

Is there a web3 api written in golang to interact with Eth nodes?

I'm looking for a library that can easily interact with Ethereum nodes that is similar to Web3.js. go-ethereum is written entirely in go so I would of thought I could write scripts pretty easily.
0
votes
1answer
35 views

How does .on work in Web3 1.0, and why do I get duplicate results?

I don't understand what .on event handler does in Web3. Take this example for signing a transaction: web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex')) .on('...
1
vote
1answer
32 views

How do I asynchronously wait for Contract.events.MyEvent data to be returned in Web3 1.0?

The documentation is sparse, and the examples all mix async, arrow callbacks, and promises. One problem I've run into is while subscribing to an event, I can't seem use asynchronous syntax within or ...
0
votes
1answer
28 views

Sending value to a solidity contract method from web3 results in `Invalid Tuple Value` error

I'm sending values to a solidity 0.5.1 method using web3 and keep getting an invalid Tuple value error. Here's the relevant contract code: struct mystruct { bytes32 id; string str; } ...
1
vote
0answers
127 views

Solidity and Web3js codes are not working inside the private Ethereum(geth) network but same codes are working in public ethereum

geth version : 1.9.0-stable-52f24617, node version : v10.16.3, npm version : 6.9.0, web3 version : -- web3@1.0.0-beta.36. genesis.json: { "config": { "chainId": 9663080, "homesteadBlock": 0, "...
0
votes
0answers
34 views

read error unexpected EOF

I'm working a evidence application with quorum.I want to store the entire contents of a file on my private blockchain. Although it's not recommended. At first I use a linux command 'split' cut a big ...
0
votes
1answer
27 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
26 views

Using vanilla javascript with web3 and metamask

I have searched severally on how to use web3 with metamask without nodejs without any success. I want to be able to get an instance of a user's metamask account through web3 and vanilla javascript ...
0
votes
0answers
15 views

Is there a way to broadcast/send transaction using web3js using token that is not ethereum?

My question is: I am trying to send a transaction using a cryptocurrency very similar to ethereum, in fact their code is almost copy pasted from ethereumjs: https://github.com/CSEPlatform/cse-tx/blob/...
2
votes
1answer
19 views

Uncaught (in promise) Error while opening and doing transaction on private ethereum blockchain using web3 and go-ethereum

I am trying to integrate a react app with go-ethereum using web3js. an event Onsubmit will do the following: 1. Create an account. 2. Open the account. 3. Approve a smart contract with the created ...
0
votes
1answer
35 views

Web3 0.20 contract deployment

environment: Web3 0.20.7,Infura,node.js(backend) Deploy contract with Web3 0.20.7 pragma solidity ^0.5.1; contract Bang{ address holder; address proxy; constructor (address _holder, ...
0
votes
1answer
17 views

Listen to transactions on EOA addresses

Haven't seen any documentation that shows that this is possible. Could someone direct me to something that would allow me to listen to transactions on non-contract addresses.
0
votes
0answers
35 views

call an api GET method in dapp - blocked by CORS policy

I am trying to create a dapp(web3js - truffle) where an API - GET method has to be implemented by setting 'x-api-key' on header.(OS - Linux) Here is the code : app.js //1st method var XMLHttpRequest ...
0
votes
0answers
22 views

invalid jump destination error in a contract execution

I am trying to swap dai to eth in Rinkeby testnet using the Uniswap smart contracts. I get the invalid jump destination error and the transaction fails. I do have enough ether in my account. Any ...
0
votes
1answer
40 views

Subscribe to wallet address

I'm stuck on how to subscribe to events to non-contract addresses. Is this possible? All I'm seeing is subscription to eth contracts only.
0
votes
1answer
32 views

Deploy contract didnt resolve the promise

im facing a problem deploying a simple smart contract. When i use ganacha-cli, the program enter in a loop of confimation event, counting from 1. Thats the first problem. Output: Account: ...
0
votes
1answer
22 views

Can Dapps set cookies

Is it possible for a Dapp that uses the metamask/chrome to set up a browser cookie? or can a cookie set by another website like facebook, read some information or at least know that a dapp has been ...
0
votes
0answers
11 views

How to integrate a serial port into web3 in order to deploy Transactions?

i use a virtual serial port that sends data from a python script to node js serialport. Everytime i send data from my python script i want to create a Transaction in web3. parser.on('data', function ...
0
votes
1answer
25 views

i'm creating new account and when i get the balance for that account it returns 0 and cant do any transaction saying dont have enough funds

How to load funds/ether into newly created account. I'm using Ganache and Web3js var web3 = new Web3("HTTP://localhost:7545"); var privateAccount = await web3.Personal....
0
votes
1answer
35 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 "...
2
votes
2answers
56 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
34 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
19 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
24 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
25 views

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

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
32 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
25 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
11 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
54 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
13 views

Error send token

let minABI = [ // transfer { "constant": false, "inputs": [ { "name": "_to", "type": "address" ...
0
votes
1answer
46 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
36 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
28 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
11 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
21 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
32 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
55 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
22 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
23 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
40 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
24 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
26 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
27 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
14 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
11 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 ...
0
votes
1answer
46 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 ...