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
16 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
24 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
70 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
28 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
21 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
34 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
37 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 ...
0
votes
1answer
44 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
39 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
71 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
46 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
37 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
24 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
18 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
44 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
128 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
68 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
31 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
35 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
81 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
85 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
42 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
31 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
111 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
43 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
23 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 ...
0
votes
0answers
44 views

Web3.js Batch Request Limit?

I'm trying out Batch Request provided by web3.js. In the example below I want to test making 300 transactions but i get the error log displayed below. I'm trying to figure out the error log but it ...
0
votes
1answer
18 views

What does instance refer to in solidity/JavaScript

DToken.deployed().then(function(instance){ token = instance; }) This code I saw in truffle test. Can someone please tell what does this "instance" parameter refer to?
0
votes
1answer
24 views

web3.eth.defaultChain returns undefined

Hi I am trying to make a call to the Dai contract in the Kovan testnet using web3.js and have to set the value of web3.eth.defaultChain to 'kovan'. The docs state that the default value for web3.eth....
0
votes
1answer
21 views

How to send the RFID card no read using Raspberry Pi to smart contract so the details can be stored on Ethereum blockchain? [closed]

Raspberry Pi reads an RFID card and has to send the RFID number to the smart contract to check further details related to the RFID number. Based on the details the payment is done and stored on the ...
0
votes
2answers
51 views

Error sending transaction to smart contract [closed]

I have problem with this, I'm doing a tutorial about how to interact with blockchain through web3, I get some response from blockchain, but the problem is when I try to send transaction or try to ...
0
votes
0answers
22 views

web3 getTransactionReceipt instant response

How come the second time i call getTransactionReceipt with the same transactionhash i get an instant response? code: async function test() { prmoise1 = web3.eth.getTransactionReceipt( '...
0
votes
1answer
31 views

Unhandled promise rejection

The code below gives me the exceeds allowance or always failing transaction error but when i check my contract on remix i can see that the transaction goes through, makes the correct state changes ...
0
votes
0answers
27 views

Just not able to install Web3 through powershell

After reading a lot of articles about how to install Web3j in windows. I also tried following this article : https://kauri.io/generate-a-java-wrapper-from-your-smart-contract/...
0
votes
2answers
70 views

gas exceeds allowance

I'm testing my smart contract on ropsten and I have written an async function that lets me send TRANSACTION transactions from TRANSACTION different accounts. For some reason when TRANSACTION > 20 i ...
0
votes
1answer
87 views

How to import web3 utils in front end Javascript

I need to use a web3.utils.soliditySha3 function in my javascript but web3.utils gives: Cannot read property 'soliditySha3' of undefined My script can't use .require as well. I tried: <script ...
0
votes
1answer
39 views

How to Keccak 256 hash in front end JavaScript before passing it to my smart contract

I would like to build a simple JavaScript (JS) front end that checks if a field submitted is the pre-image of a keccak256 hash I already know in my smart contract. I currently use the following: ...
0
votes
1answer
15 views

How to large amounts of old block

I have to scan a large amounts of old block. I using subcribe newBlockHeaders so I have new_block.number (2s/block). Then I find in db the latest block number (db_block.number). I use for(i=db_block....
1
vote
1answer
22 views

Exit process after sending multiple tx asynchronously

I have written a function that allows me to send an arbitrary amount of transactions, asynchronously, to my smart contract. However the process stays open even after the last transaction has finished. ...
3
votes
2answers
250 views

Sending multiple transactions in the same block with incremented nonces

I need to send 0.1 ETH to 10 unique addresses from the same address at the same time. I am manually incrementing each transaction's nonce, and the transactions are sent successfully. However, each ...
1
vote
1answer
28 views

How to fix Data location must be “memory” for return parameter in function, but none was given.?

pragma solidity >= 0.5.0 < 0.7.0; contract Adoption { address[16] public adopters; function getAdopters() public view returns(address[16]) { return adopters; } function adopt(uint ...

1
2 3 4 5
14