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

Following Web3 tutorial,Can't understand this code [closed]

<script> // Previous code removed for brevity Coursetro.getInstructor(function(error, result){ if(!error) { $("#instructor&...
0
votes
0answers
22 views

Migrate dapp from Tron to Ethereum [closed]

I have a dapp that was developed on Tron a while ago. I would like to move the dapp to the Ethereum network, so I modified and deployed the new smart contract. Now I need to modify the UI in the way ...
0
votes
0answers
14 views

Use Web3js library

I am new to the use of blockchain we are building an application where I have the following problem to solve: Users when registering in our system will create a wallet of an ethereum token Be able to ...
0
votes
0answers
13 views

Simple Web3 installation and calling contracts

I have been trying to inject metamask into my site using web3. I have called web3 in my site as below and started the site using local server(VS Code extension which gives me port:5500) window....
0
votes
1answer
27 views

Sign a message in javascript

I want to sign a message with my ethereum account in a javascript application. I do not want to work in a web-browser or with metamask. I want to build a stand alone javascript program. Is there a way ...
1
vote
1answer
39 views

Generating an Ethereum wallet with an existing private key

I want to understand how Ethereum works and i want to calculate the public key and wallet address from private key. I have read this tutorial: https://piyopiyo.medium.com/generating-an-ethereum-wallet-...
1
vote
1answer
29 views

ERC20 token transfer attempt resulting in underpriced (price change attempted)

It's almost an exact copy of this but when I ran it, I get the following error message. (node:5189) UnhandledPromiseRejectionWarning: Error: Returned error: transaction underpriced Below is the code ...
0
votes
1answer
29 views

Uniswap 'PairCreated' Event Listener Temperamental

Can anyone deduce why this doesn't show me all the PairCreated on Uniswap? It seems odd as I have seen it work once or twice during the day and ouput a log for a 'PairCreated', but I know there are ...
0
votes
0answers
8 views

How can I access the methods of an object in a contract using web3?

I am creating a front end, and right now I am trying to appove the token for transfer. I have an object, say token, instantiated in my contract as follows: ERC20 private token = ERC20(...
2
votes
1answer
52 views

Where can i find a documentation of all `wallet_` RPC calls?

Looked everywhere, and all I can find are a bunch of EIPs. Is there a document/repo somewhere listing all available RPC calls that interact with the wallet (wallet_...)? Specifically, I'd like to ...
3
votes
2answers
152 views

Hardhat - How to interact with a deployed contract?

I can deploy a contract using ethers and Hardhat with the following: const myContract = await hre.ethers.getContractFactory("SomeContract"); const deployedContract = await myContract.deploy()...
1
vote
1answer
27 views

Is there any advantage or disadvantage of using javascript over solidity when building dapps on etherum?

I am aware that there are libraries that let you build dapps on ethereum. What are the pros and cons of using javascript over solidity for dapps. I know this might sound like a partly subjective ...
0
votes
1answer
47 views

How to unit test when a function depends on hardcoded deployed contract address?

I've been writing unit tests for a contract using Hardhat + Ethers + Typescript, let's call it ContractA. This ContractA has a hardcoded address of a deployed ERC20 token in it like this TokenA = '0x.....
0
votes
1answer
19 views

Create new account in ganache

I'm creating a Dapp which provide the user with individual account. while developing, when i create a account by const accounts = await web3.eth.personal.newAccount('test'); the account is created ...
1
vote
0answers
20 views

Transfer ethers from smart contract to an account in metamask

I want to transfer 10 ether from smart contract to an account in metamask. I used the following script inside my smart contract : function transferBalance(address payable Add) public{ ...
4
votes
1answer
32 views

How to convert public key (64 bytes) to compressed public key (33 bytes)

I currently have a generated 64-byte public key that has been recovered from an Ethereum transaction. How do I convert this key into a 33-byte compressed public-key? The problem I'm having seems ...
0
votes
0answers
21 views

Retrieved Uniswap token price from smart contract is inaccurate compared to the one displayed on Uniswap interface

I'm trying to create a bot using JavaScript that interacts with Uniswap's smart contracts. I have been using UniswapV1's factory and exchange contracts, and I was using the getEthToTokenInputPrice ...
0
votes
0answers
27 views

How do I manipulate data in multiple contracts and output them

I am trying to manipulate data I retrieve from my contract, and then display it. Currently, I am running into 2 problems: 1- I am unable to manipulate the data correctly. 2- I am unable to display ...
0
votes
1answer
51 views

Window.ethereum undefined on tab with local webpage

I have the metamask extension. When I do typeof(window.ethereum) in the console for a chrome tab, I get the type as object. However if I open mywebpage.html in a tab, which is just a heading around: &...
2
votes
1answer
435 views

Expected private key to be an Uint8Array with length 32

i am trying to send a transaction but it throws an error. still i am not sending any transaction just signing it... Error: Expected private key to be an Uint8Array with length 32 at assert (C:\web3\...
0
votes
1answer
17 views

Promise Pending on Etherscan API

I am trying to pull normal transactions done by a wallet by using etherscan API. However, I am getting Promise { <pending> }. Can someone please tell how to solve this? Here is my code: require('...
0
votes
1answer
31 views

Uncaught (in promise) TypeError: work.methods.workCount is not a function

Describe the bug I am trying to call the public variable "workCount" from a smart contract using web3 Steps to reproduce: const work = new web3.eth.Contract(ABI,Address) const workCount = ...
0
votes
1answer
63 views

How can my Ethereum node accept remote connections?

I need to use Web3 on some Python and Javascript applications i'm creating, so i decided to setup a light node on a VPS. The node seems to work, but i'm having troubles accessing it from outside the ...
0
votes
0answers
36 views

How to pass Multiple Values in a Solidity Event

I am emitting within a function the following in a solidity smart contract. emit Transfer(address(0), to, tokenId) In my front-end JavaScript code, I am reading the values as follows: let transfer = ...
0
votes
1answer
54 views

web3.js not able to interact with smart contract

web3.js and general ethereum noob here. I have a smart contract written in solidity with a bunch of getter methods, for example: contract mycontract { uint XYZ = 2; ... ... ... function ...
1
vote
1answer
394 views

Adjust slippage tolerance in Uniswap programatically

I've been able to do swaps through Uniswap's peripheral smart contract Router 02 by calling any of the functions such as: function swapTokensForExactTokens( uint amountOut, uint amountInMax, ...
0
votes
1answer
23 views

Unable to fetch getBalance of eth address

I am unable to get the balance of an eth address using web3.eth.getBalance, it returns error like "no suitable peers available". I connected the eth mainnet in light node. My source code: ...
0
votes
0answers
23 views

TypeError: web3.isConnected is not function

I coded the below program: var Web3 = require("web3"); var web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545')) console.log(web3.currentProvider); console.log('...
0
votes
0answers
32 views

Unhandled Rejection (TypeError): Cannot read property 'call' of undefined

I am working on a ethereum dapp and am struck with the following errors, concerned code pieces have been attached. App.js async loadBlockchainData() { const web3 = window.web3 const ...
1
vote
1answer
76 views

How to generate solidity encode function signature from Javascript?

What I am trying to achieve is like , i should be able to call a set of solidity functions dynamically based on some criteria. i'm using call() method to achieve the same. (bool success, bytes memory ...
0
votes
0answers
21 views

Oracle service and oracle smart contract

I read this article https://medium.com/@robinagist/building-an-ethereum-oracle-with-web3-js-1-0-1272b59cfc31 but there are some things I didn't understand. Does the oracle need a node (like geth or ...
-1
votes
1answer
15 views

sync function syntax [closed]

What is the difference between this syntax: beforeEach( async () => { ... }); and this one: beforeEach(async function() { ... }); Thanks
0
votes
2answers
197 views

Cannot find module react-bootstrap/lib/Breadcrumb

I'm trying to figure out an issue with this tutorial that i'm following, whenever I try to use truffle test within the CMD in the defi-tutorial folder, it comes up with the issue in the header, cannot ...
0
votes
0answers
26 views

Ganache does not update account balance after contract deploying

I work with Ganache and nodeJS. Whenever i effort to deploy my contract with JavaScript the related block is mined, that demonstrate the given contract is deployed, but the balance of the sender ...
4
votes
2answers
2k views

Is it possible to send transaction in Binance Smart Chain using web3 and ethereumjs-tx?

I want to send transaction in Binance Smart Chain and I got an error: new Error("Chain with name " + chain + " not supported"); const Tx = require('ethereumjs-tx').Transaction; ...
0
votes
1answer
20 views

Function does not execute sequentially [closed]

I'm trying to check in a JavaScript function if checkVehicleExists returns a true or false before proceeding with my if else statement which will depend on whether checkVehicleExists is true or false. ...
0
votes
1answer
109 views

Getting this error for TOKEN ABI: You must provide the json interface of the contract when instantiating a contract object [closed]

I am trying to get abi of a token with etherscan and pass the variable in to the web3 function. I am using etherscan's getabi built in function as it is shown in the API documentation but I am still ...
0
votes
1answer
16 views

error comparing numbers in smart contract (Big Number)

I am unable to understand when all do we need to convert numbers to bigNumbers for asserting to be equal. In some cases by mistake i missed to convert integer variables to bigNumber and they worked ...
0
votes
0answers
58 views

Web3 error: “value out of bounds” when passing in value for smart contract call

When calling a function on a smart contract that takes a tokenID, I pass in the tokenID into web3 - but web3 then parses that string into another value it seems, pads it to the left with a ton of ...
0
votes
0answers
16 views

Why does my web3 not execute this smart contract function?

Good day, I am busy with a small project trying to call a buy() function on an Ethereum Smart Contract. This Contract is found on the Ropsten Test Network here:https://ropsten.etherscan.io/address/...
0
votes
0answers
25 views

I cannot transfer the rights to use the smart contract to another wallet

I have a smart contract. I own, it belongs to my wallet. I am trying to implement a function to transfer the OWNERSHIP of this smart contract to another wallet. I have two solutions, but for some ...
0
votes
1answer
22 views

Keccak256 hash different in solidity and web3js

I am trying to sign a message in NodeJS and verify the signature with smart contract. Here is my code: async function prepareAndSignMessage(to, amount, referenceTransaction){ let contractInstance =...
0
votes
0answers
51 views

I have a problem with the transfer of ownership by a smart contract

I have a smart contract. I own, it belongs to my wallet. I am trying to implement a function to transfer the OWNERSHIP of this smart contract to another wallet. I have two solutions, but for some ...
0
votes
0answers
10 views

toNumber in test.js

I am creating a test.js for my smart contract. I forgot to use "toNumber" while testing some uint variables to be equal in some cases and it executed without any error. So in what all cases ...
0
votes
0answers
100 views

Trying to interact with ganache-cli fork through script

const {ChainId, Fetcher, WETH, Route, Trade, TokenAmount, TradeType, Percent} = require ('@uniswap/sdk'); const ethers = require('ethers'); const chainId = ChainId.MAINNET; how would I specify it to ...
0
votes
1answer
87 views

Hello. I have a problem with a smart contract transaction between users. Error: gas is missing

I have a problem with a smart contract transaction between users. Error: gas is missing. Here is my function: async function transactionContract() { let signerAddress = gettingOwnerByKey( &...
0
votes
0answers
123 views

how to send a transaction using sdk uniswap.org

i am trying to create and send a transaction to https://app.uniswap.org using SDK https://uniswap.org/docs/v2/smart-contracts/router02/ uniswap has two functions (swapExactTokensForETH and ...
-1
votes
1answer
223 views

web3.js: How to convert Wei to Ether? [closed]

Im trying to covnert wei to ether in my node.js script let myBalanceWei = web3.eth.getBalance('0xF33b5a2B692bE695d6FD6f3136eB8919f2666e3a').then(console.log) let balance = web3.utils.fromWei(...
0
votes
1answer
41 views

Hyperledger Besu: Unable to decode the hex string returned by solidity function containing multiple values

I have set up a Hyperledger Besu network for private transactions using Orion. I am using a javascript client to write to and read data from a smart contract written in Solidity. I am following the ...
0
votes
0answers
34 views

Why is my pair price value undefined?

I'm still pretty fresh to all this code life, please help me out. I am writing this price scanner to get the prices of pairs in Uniswap. Even though console.log(tradePrices) shows me an object with ...

1
2 3 4 5
15