Questions tagged [javascript]

JavaScript is a dynamic, weakly-typed language used for client-side as well as server-side scripting.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

Solidity Error: Cannot destructure property `interface` of 'undefined' or 'null'

I've got his error in Solidity when compiling my test file: TypeError: Cannot destructure property interface of 'undefined' or 'null'. I know it is related to my compile.js file, but what is ...
0
votes
1answer
19 views

Upload a full directory to IPFS using ipfs (js-ipfs-http-client)

I want to upload a directory to ipfs on my browser using (js-ipfs-http-client) module. I found this old issue. https://github.com/ipfs/js-ipfs/issues/277 So I decided to use recursive way to add files ...
0
votes
0answers
7 views

build contract interface from contract after offline transaction has been mined

I have created a transaction offline for a contract deploy, to be sent to my server to deploy. Here is my offline created transaction const contract = new ethers.ContractFactory(abi, bin, wallet); ...
0
votes
0answers
12 views

truffle - toUtf8 on Migrations not working

I'm deploying my contracts via migrations and would like to show some info on the console about them just by getting data from these contracts and displaying it. I'm sending a deployed contract to the ...
0
votes
0answers
25 views

Ethers js estimate gas offline?

Looking here in the docs it mentions I need to have the provider attached to estimate gas. But for formatting a transaction offline, I dont have access to the provider. Is there a way to estimate the ...
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
1answer
15 views

Is it possible to instantiate a deployed contract in js using contract address alone? without copying abi data?

Is it possible to instantiate a deployed contract in js(dapp) using contract address alone? without copying abi data?
0
votes
1answer
33 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 "...
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
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 ...
1
vote
1answer
53 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/...
2
votes
0answers
27 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
18 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
63 views

'types/values length mismatch',

Hey guys I had a problem with my return function here's my smart contract : pragma solidity >=0.4.0 <0.7.0; contract NewHello{ address owner; address newOwner; constructor()public{ ...
0
votes
0answers
22 views

Get the address of a contract without using Remix-ide

I'm studying Ethereum, I need to get the contract address for interact with web3, I can not use Remix-IDE for this since that I installed Kali as an operating system. How I get the contract address ...
0
votes
1answer
94 views

is not a function at HTMLInputElement.onclick error [closed]

I have this error > App.validate is not a function at HTMLInputElement.onclick The code is here : i get error in the last ( >) input type="submit" name="submit" onclick="App.validate()"
0
votes
1answer
25 views

What is the difference between web3 and window.web3

I'm very used to using web3 = new Web3(web3.currentProvider) and I saw here that MetaMask sample code is using window.web3 = new Web3(web3.currentProvider) What's the difference between using and not ...
1
vote
1answer
33 views

Am I hashing the data in the file itself, or just the reference?

I am attempting to create an app where I upload a file to a website and then I submit a hash of that file onto Ethereum. I am unsure whether I am hashing the actual file below or just the reference to ...
0
votes
1answer
32 views

Producing a Hash of a File [closed]

I would like to upload a file to my UI and then produce a hash of it so I could later store it on Ethereum. Here is the code I am using to upload the file: <div> <label for="file input"&...
0
votes
0answers
25 views

web3.eth.getBlock in order

I am a beginner for Javascript & web3(0.20). I am using Metamask for watching allevents, and I need to get timestamp. I use getBlock.timestamp. Due to Javascript, timestamps are not inorder. I ...
1
vote
1answer
109 views

Smart Contract is being deployed but call does not return contract address after deployment

So I have been trying to deploy a smart contract using nodejs, but when I call the function to deploy, I get no contract address on my console. It's like the send() function never completed its ...
1
vote
1answer
43 views

Why are integers returning as hex?

I am implementing a simple smart contract in Solidity 0.5.9. One of the functions is called getSummary() which basically returns a summarized version of a vote: function getSummary() public view ...
0
votes
2answers
64 views

how to get contract address after its been mined with web3.js

I have tried to deploy a SmartContract from web3.js node library, I am getting a transaction hash from it but how would I get the contract address after It's been mined by a miner? here is my code ...
1
vote
1answer
30 views

Lib to sign messages using the same version of ECDSA of Ethereum

I want to sign a message using the private key of my physical RSA digital certificate and I want to validate this signature onchain. Does anyone know a lib that can sign messages offchain using the ...
1
vote
0answers
25 views

Can I run a javascript file using geth attach?

I want to automatize one thing. Aftert installing the Quorum nodes, I have to run: docker exec -it quorum_node1_1 geth attach /qdata/dd/geth.ipc Then I am pasting the JS code But I want to ...
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
0answers
12 views

How to console.log the value in the React js for the Dapp + truffle project

I am beginner with the ReactJS and Dapp. In my js page I want to get the value after doing some operation on the input value and want to dispay that result. I got the Nan in the front-end screen. ...
0
votes
0answers
29 views

How to handle estimate gas cost error?

I am programming a button for a transaction which shall only appear if the transaction is possible. Therefore, I am using the following code contract.methods.function(parameters) .estimateGas({...},...
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 ...
1
vote
1answer
40 views

MetaMask ethereum.enable() not responding after logout. How to reactivate?

So I found out that after logging out of MetaMask. ethereum.enable() stop working and is not triggering the login prompt window. The only way to reactivate it, is by closing chrome, and start it once ...
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" ...
0
votes
2answers
64 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
106 views

truffle-assertions: TypeError: Cannot read property 'filter' of undefined

There is a part of my Solidity code: event elo(address pAddress); function test() external { emit elo(m_Registry); } And a chunk of my test: const truffleAssert = require('truffle-...
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
72 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
26 views

How to store and encrypt Keys?

I am developing chrome extension like metamask for the private Chain. I have generated the keys and using localStorage to store the Keys. But I am not sure whether I am going correct or not for ...
1
vote
0answers
19 views

Base58 javascript implementation [closed]

I am using IPFS-multihash method to store IPFS hash in smart contracts. For that I need to decode base58 format: QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4 to binary(as hex): ...
0
votes
1answer
105 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 ...
0
votes
1answer
17 views

How to redirect to Etherscan website when transaction completes?

In my project, I am doing a transaction by using ethereum.send({ }) method from web3 in javascript using metamask. After the transaction completes I want to display the link to the user in label ...
2
votes
1answer
25 views

How to retrieve transaction hash value from the Promise object using web3js?

I'm trying to retrieve the transaction hash value after I call my smart contract method. My Promise object looks like below. returnPromise: Promise { "pending" } ​ <state>: "...
0
votes
1answer
451 views

SyntaxError: await is only valid in async functions and async generators in web3js

Below is my code snippet. I wish to wait for the transaction hash value so that I can return my Javascript function with the hash value. But I get the error "SyntaxError: await is only valid in ...
1
vote
1answer
27 views

What is the difference between web3.js and ethjs?

I've seen people using both in their codes - https://github.com/ethereum/web3.js and https://github.com/ethjs. Do I need both? Does ethjs depend on web3?
0
votes
0answers
31 views

MetaMask Calling Child Contract Methods?

I had created a contract(Organisation.sol) that create other contracts(Session.sol). When I call any method from(Organisation.sol) using web3js it work well. But If I ever tried to call any method ...
0
votes
1answer
29 views

How to deploy A contract created by another contract in the browser?

Hey I am making a smart contract that create another smart contracts. Organization.sol create Session.sol . When I create a session using createdSession function I got it's address and I already had ...
0
votes
2answers
55 views

Solidity event isn't fired

I'm trying to listen for an event I've created on remix IDE , from NodeJS. I call a smart contract method from where the event is triggered and I'm waiting for it in my console...but I don't receive ...
0
votes
0answers
15 views

Help needed: MetaMask crash reason?

I am experiencing an issue of MetaMask but I do not know how to track down if this is due to MetaMask itself or due to my dapp. Following problem: I load my webpage in Chromium on Linux and log in to ...
0
votes
1answer
53 views

.transfer fails

Trying to call .transfer() within a function makes it fail. I am aware that the difference between .send() and .transfer() is that .send dont throw. The function works properly when using .send(), but ...
1
vote
1answer
46 views

BigNumber Error: new BigNumber() not a number: [object HTMLInputElement]

Getting this Big Number error when trying to update my token price.Seems like a Javascript issue with the number size being passed.Anyone know a fix for this? //Javascript priceChange:function(){ App....
0
votes
1answer
66 views

How to connect with Metamask and Smart contract?

I am ready with my frontend design. I have only 3 files HTML, CSS, and JAVASCRIPT. So, I didn't create any project or DAPP to have other files. Now next step is to connect with metamask and smart ...
0
votes
0answers
56 views

How to call A child Contract function in web3js?

Hey I am new at blockchain development and I need to make contract name organization that create sessions contracts. I had already implemented the solidity code but I have a problem in front-end ...