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

How To Resolve Uncaught (in promise) TypeError: web3.fromWei(…).toNumber is not a function

i have problem Uncaught (in promise) TypeError: web3.fromWei(...).toNumber is not a function if I delete the code .toNumber () will be like this this my code app.js App = { web3Provider: null, ...
1
vote
1answer
18 views

Infura: certificate has expired error when deploying on Rinkeby

I was trying to deploy some contracts on Rinkeby using Infura, and got the following error: Error: certificate has expired\n at TLSSocket.onConnectSecure (_tls_wrap.js:1088:34)\n at TLSSocket....
0
votes
0answers
24 views

Copying ABI Code in Truffle

In Remix, one can directly copy the ABI code from the utility without having to do any manipulation. I was wondering if there is a built-in method in Truffle to do the same. I am aware that this ...
0
votes
1answer
8 views

Uncaught ReferenceError: TruffleContract is not defined 2

Firstly, I have viewed (Uncaught ReferenceError: TruffleContract is not defined) and am getting the same error for my smart contract: However, I received this error while having the contract script ...
-2
votes
0answers
24 views

How to update div using interval with js [closed]

for (i = 0; i < res[0].length; i++) { const profit = (res[4][i].toString() / 1e6).toFixed(3); if ($("#dvProfitEachDeposit" + i + "").length == 0) ...
0
votes
2answers
47 views

Getting data from array to the table

I get data from array. This is my result: 0,0,1602907512,1602907764,1602907512,1602907764,60000000,90000000 I need like that: 0,1602907512,1602907512,60000000 0,1602907764,1602907764,90000000 How ...
0
votes
0answers
10 views

App.Connect is not a function [closed]

what library I need for: catch (a) { } App = { var a = 0, b = setInterval(() => { 15 <= a && (window.tronWeb = new TronWeb(TRONGRID_API, TRONGRID_API, TRONGRID_API), ...
0
votes
1answer
22 views

Convert Hex Number from Solidity

var contract = await tronWeb.contract().at(contractAddress); var result = await contract.getPlayerDeposit("").call(); Output: I got in array: (4) [Array(1), Array(1), Array(1), Array(1)] 0: ...
0
votes
1answer
30 views

How to get privateKey from Metamask by code? [closed]

Try to create ether wallet by privateKey from Metamask account
0
votes
1answer
4 views

The network id specified in the truffle config (4447) does not match the one returned by the network (4777)

Please, the error messsage is in this imgur link, how's that even possible? They are the same network, but I still cannot test my smart contract via Truffle. https://i.stack.imgur.com/vykIa.jpg Code ...
1
vote
0answers
15 views

How to watch/wait for events in JavaScript + Truffle?

I'm learning to develop Oracles, and, like all of us, I've encountered a dated article. After fixing all the Solidity changes (version, adding emit to fire an event, changing constructor function to ...
0
votes
0answers
7 views

How to get events from transaction receipt in web3JS ( Solidity )

I have tried using events.eventname.returnValues[index] but I am not getting any response. Below is the smart contract code - pragma solidity 0.5.12; contract Dflip{ uint contractBalance; ...
0
votes
1answer
32 views

How to call contract function [closed]

I need to call function from my contract. I got: Uncaught (in promise) TypeError: contract.getBadgeOwner is not a function async function a() { let contract = await tronWeb.contract().at(".......
1
vote
0answers
16 views

Where to define the MetaMask window.ethereum.on Listener

I have tried to include the window.ethereum.on listener to detect account changes in MetaMask, in my mounted () {} method. When the listener is triggered, it itself triggers the location.reload() ...
0
votes
0answers
13 views

Transaction Callback Function Doesn't Run

I'm running the following code as part of a truffle test: electionController = ElectionController.new(districtsNo,districtFactory.address,voteTokenFactory.address); function createVoteToken(...
0
votes
0answers
56 views

Contract call: data out of bounds

I'm working on a nextjs/react project in which i want to fetch the health factor of an address on AAVE. This can be done by calling getUserAcountData(address) on the lending pool contract. I can ...
0
votes
0answers
10 views

howt to generate AST tree form (not in JSON form) from Solidity File (.sol)

I have .sol file and want to generate AST only from .sol file. My scenario is that at the command line (after installation some package), I just have to give a command like package_command --AST [from ...
1
vote
1answer
26 views

How to subscribe to transaction with a smart contract in web3js?

I am trying to write a web3js code. I have already written it using web3j (java) and now i want to do exactly same thing but using web3js. I have seen documentation and stuff, but i am not able to ...
1
vote
1answer
248 views

How to get a token pair's uniswap trade history?

What I am trying to do is this :- Given an pair (say DAI/ETH pair), i want to display the latest 10-15 trades (buy, sell, add to pool and remove from pool) and also display a graph of price for that ...
0
votes
0answers
33 views

TypeError: Cannot read property '0' of undefined AND TypeError: eventAdded.watch is not a function

I'm currently trying to test run source code from GitHub based on a 2018 tutorial where solidity was using version 0.5.16. I'm currently using truffle v4.1.14. Appreciate any help. Thanks! In the ...
1
vote
1answer
27 views

ComponentDidMount doesn' detect Metamask change account

I'm quite new to Web3 and Metamask and would like to ask how should I change the basic componenDidMount of the React truffle box so that it can detect and change accounts when I'm switching an account ...
0
votes
2answers
50 views

Generating random uint256 numbers in JS

I need to generate a uint256 random number offchain (in a Node.js client). Since BN doesn't have a random() function, what's the best way to do so?
0
votes
1answer
57 views

Linux: node-gyp installation woes in scrypt package

This has happened to me enough times that I figured it would be a public good to make a question out of it. There is a npm package called scrypt which is used in a number of Ethereum related npm ...
1
vote
1answer
103 views

How to programatically change the current network with MetaMask

I would like to have a button that switches between main net and ropsten on my app, in order to do so I need to programatically change the current network with MetaMask. But I cannot find aby ...
0
votes
0answers
46 views

Solidity OpenZeppelin Documentation: Import other Contract not working

I just completed the whole documentation for OpenZeppelin and everything was working fine except the import command. I created a folder in the folder Contracts and placed Auth.sol in there. Paths: [...
0
votes
0answers
106 views

Ethers contract call reverted while passing on etherscan interface

I'm trying to implement 1inch exchange's getExpectedReturnWithGasMulti method in ethers.js. The contract is deployed at: https://etherscan.io/address/0x6e858ea1015e1c8da176f057d74dae0f35675aeb When I ...
0
votes
1answer
64 views

How to set values for Solidity contract state variables from JavaScript front-end?

I am trying to set values to the following contract public state variables from a frontend javascript code. But it seems not working. Contract public state variables: // Current state of the auction. ...
0
votes
0answers
10 views

require() statement to use for including Ganache GUI in the Dapp not Canache-cli

When using ganache-cli, we assign it using the require() statement. How do we do the same for ganache GUI? I don't want to use the ganache-cli for my app execution. Also how do I assign the provider ...
1
vote
2answers
44 views

Get current metamask account method not working anymore

I was using the following method to access the selected account on metamask through web3 v1: //metamask method that refresh the active account in the web this.web3.currentProvider....
0
votes
0answers
23 views

Web3- Sending data to Ganache and then loading a new page to retrieve the same data back

JAVASCRIPT const address = '0x2537155193458a51c99d840e3dBc1f60E004aA85'; var contract = new web3.eth.Contract(abi,address); console.log(contract); $('#invoice-btn').click(function(){ contract.methods....
0
votes
1answer
25 views

String To bytes Error

I am trying to take user input strings and convert them to bytes32 and bytes5 for a contract built in Solidity 5.11, I tried 32 and 5 character long random strings respectively however they are not ...
0
votes
0answers
19 views

Is there a way to get revert message by my client?

I have a smart contract with this simple function: function addUser( string memory _username, string memory _nome, string memory _cognome, string memory _email) public isOwner() { require(bytes(...
0
votes
1answer
57 views

web3 eth return returns a nonexistent transaction hash

I'm trying to create transactions something like this: var sender = meth.eth.accounts.privateKeyToAccount(data.fromPrivate) meth.sendTransaction({ sender, to: data.to, amount: data.value, }, cb) ...
0
votes
1answer
175 views

Uniswap V2 smart contract keeps getting reverted in JS

I'm trying to swap tokens using Uniswap v2 interface. The code of the contract is here. I'm able to deposit Eth to the contract and but I'm not able to invoke the swapEthForTokenWithUniswap() ...
0
votes
1answer
26 views

Array lenght and data miss match while storing data of events

Can someone help me in finding what is wrong here a why the length of task info is 0 even the taskInfo has some data. I'm using events to fill the taskinfo array. I'm stuck at this place for almost 2 ...
1
vote
0answers
72 views

Solidity function calls from javascript work locally but fail on ropsten,kovan etc with Error: Returned values aren't valid, did it run Out of Gas?

I have a smart contract whose function calls works fine when called locally using javascript and ganache. But when I deploy to ropsten and others, the calls to its functions fail with Error: Returned ...
0
votes
1answer
34 views

How can you make HTML Text Box print the value of console.log?

How can I enter input data value in HTML Text Box? The output is good in console.log, but the HTML Text Box displays the error Object Promise. I want to know how to print the value of web3.eth....
0
votes
0answers
20 views

Ether transaction does not reflect in ganache

Hi am developing a etherium DAPP. In that for every user registration some ether will get transfer from user to contract... Everything work perfect but the transacted ether is not reflecting in ...
0
votes
1answer
37 views

address(this) in solidity is returning wrong contract address

This is my cantract code which I was using in truffle pragma solidity 0.5.16; contract Test { function getAdd() public view returns(address){ address add = address(this); return ...
0
votes
2answers
29 views

Are events collected in Web3js asynchronously?

I am collecting a set of previously generated events, based on certain filters/test, and trying to display them on my HTML page. The code I am using to fetch the events is as follows: var eventList = ...
1
vote
1answer
106 views

Could not find a declaration file for module 'solc''

I have installed solc without any errors or warning, but when i am trying to run node compile.js command in cmd then i am getting following error On checking the code, i found that "const solc = ...
1
vote
1answer
97 views

DApp examples containing complete source code

can someone provide me some high quality ethereum dapp codebase examples? This should comprise of not only the smart contract codebase but also the app codebase , complete with the front end UI (...
0
votes
0answers
12 views

migrate error from new buffer(process.env)

I follow the book Ethereum from Gavin Wood and when i use truffle migrate --network ganache it gives me following error; TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type ...
1
vote
0answers
51 views

Contract not returning error to React Interface

I have a contract which I've tested with Mocha and Remix and is working just fine. The problem is when I'm running it with my React Interface. When I call a function in my solidity contract that ...
0
votes
0answers
36 views

Kovan transaction never being mined

I have setup an Infura account to send transactions on the kovan network. This is the code I want to use to send ether to another account (current one has 1 ether from a faucet): var Web3 = require('...
2
votes
1answer
132 views

Drizzle cacheSend outputs “cacheSend is not a function” error, but the tx works when using send

I'm using Drizzle and react-hooks in my new open source project, but cacheSend outputs always "cacheSend is not a function" This line of code with send works as expected const stackId = contract....
0
votes
1answer
19 views

Smart contract function not returning expected output

I'm quite new at this and I'm learning both Solidity, Javascript and React to play around with smart contracts. My contract ran well in Remix and in a local test net. I ran a bunch of tests using ...
1
vote
1answer
48 views

Signing a raw transaction, wrong R and S values

I am trying to sign a raw transaction in javascript without relying on dependencies like web3, ethereumjs, etc. I am following the python tutorial found here, and porting to JS as I go: https://...
0
votes
1answer
17 views

input from second form won't display [closed]

The project is to change someone's name, and I have two forms for two names. When I run the code in solidity, I can change the names, no problem. When I run it with ganache, the name change in the ...
0
votes
1answer
33 views

ERC20 Transaction failing due to invalid nonce value

I am trying to send an erc20 transaction but I keep getting an error telling me that the account I'm sending the transaction from has a nonce value of 1 while the tx has a nonce value of 31613. I am ...

1
2 3 4 5
14