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

i want to show data from fetch() to web page in Javascript [closed]

i have use fetch() to collect some data, now i want to show it on web pages. the data are now in the console in the format of arrays. here is the code i use async function api(){ let res = await ...
0
votes
0answers
12 views

Get Block Number (without web3)

I'm hoping to have some client side javascript run that will do some simple timing estimates based on the current block number. Is there a simple way to do this that doesn't require web3? I don't ...
0
votes
0answers
16 views

Hardhat JsonRpcProvider with Polygon node url

The Problem I am unsure when setting a provider for polygon contract interaction (mint script). I have also triple checked my maticUrl environment variable with my node dashboard and I was successful ...
1
vote
0answers
12 views

How do I check if an IPFS-Hash is valid or not, as an input?

I wanna store Ipfs-hashes (Content Identifier) on the blockchain in the code below. And because it's public and anybody can use it, I want to make sure the function only accepts valid Cids (i.e., the ...
0
votes
1answer
18 views

How do I use a Solidity Library in NodeJs

Can I interact with the Solidity library in nodejs with the ethers library if I have the "my_specific_library.json" file generated by truffle in the compilation of the the ...
0
votes
0answers
18 views

Uncaught TypeError: Cannot read property 'contract' of undefined

I'm getting this error. Can someone please help me Uncaught TypeError: Cannot read property 'contract' of undefined at add_details ((index):140) line:140--> var myContract = new Web3.eth.Contract(...
0
votes
1answer
35 views

TypeError: Member “gas” not found or not visible after argument-dependent lookup in tuple(bool,bytes memory)

How do I fix this? abstract contract AionClient is Aion, Context, Ownable{ using SafeMath for uint256; using Address for address; address private AionAddress; constructor(address addraion) public{ ...
0
votes
1answer
12 views

How to get events from a contract deployed on different network? - Web3

I have contract A in Avalanche FUJI C-chain. When I'm on C-chain testnet, I can get events from A using getPastEvents() in web3.js, but when I change the testnet (for example, to Goerli), I receive an ...
1
vote
0answers
23 views

Ethers - get historical block.timestamp in batch mode

I am trying to build a simple database table containing block.number and block.timestamp starting at a given block number. This could be easily done with the following JS code using ethers.js library: ...
1
vote
1answer
20 views

How do I send ETH from an account to another in Hardhat?

I tried both signer.sendTransaction({ to, value }); and provider.send("eth_sendTransaction", [{ from, to, value }]);, and neither worked for me. Would be great if your answer could also ...
0
votes
0answers
9 views

How do I query specific transaction data using Covalent API?

I'm using the following Covalent API endpoint: https://api.covalenthq.com/v1/137/address/<walletaddress>/transactions_v2/?&key=<apikey> It returns tons of data. I'd like to query ...
1
vote
0answers
8 views

export variables in truffle console

I learned from https://stackoverflow.com/questions/54556720/cannot-exec-simple-javascript-file-into-truffle that external scripts must be in the module.exports pattern. I wrote console.js with the ...
1
vote
1answer
48 views

Ethers js estimateGas() without needing ETH in account

I am trying to estimate the gas used for a uniswap transaction. I am able to perform this on the Kovan testnet however when I try and run the same script on the mainnet it raises an error, "Error:...
0
votes
0answers
15 views

How do I log a NFT transaction that just arrived on my wallet?

Hey I am currently trying to listen for a NFT token transfer on an account. So if someone sends a NFT to a walletAdress this gets triggered and logs the event ? I have tried it like that any ideas ? ...
0
votes
0answers
29 views

Calculating Gas of A Uniswap Exchange With Web3js

I am trying to calculate the gas that a contract will use prior to executing it. I realize that it is not possible to get a 100% exact value but I would still like to calculate an estimate. I am new ...
1
vote
0answers
19 views

Getting wrong value from solidity function

I have multiple functions in javascript document.addEventListener("DOMContentLoaded",function(event){ showData(); CheckIfVoted(); }) function ...
0
votes
1answer
20 views

Is it possible for web3 to listen to contract function call ? (For example mint() for a NFT)

Hey I have read about listening to events in web3js and it worked. I have my abi set up and looked through all available events in it and mint(), what I use to mint nfts is a function which makes ...
0
votes
2answers
36 views

How to convert bignumber to normal number using ethers.js?

I am using ethers.js I can't figure out how do you convert a bignumber like 1252500000000000000 to 125.25 -Mike
0
votes
1answer
18 views

Web3.eth.abi.encodeFunctionCall Is not working

I'm creating a dapp that charges users a specific amount of eth depending on their input. Whenever I attempt to create the transaction, I specify the amount of Eth in Wei. It throws an Error with no ...
0
votes
1answer
39 views

Set msg.sender in testing

I have a Solidity function that manipulates an object. The function only allows this manipulation of the caller msg.sender is owner of that object. Something like this: function Manipulate(uint i) { ...
0
votes
0answers
16 views

Error while compiling with nodejs

Im trying to set up the compiler for my project. sol: pragma solidity ^0.4.25; contract Inbox { string public message; function Inbox(string initialMessage) public{ message = ...
0
votes
1answer
128 views

How to get always the right price for all BSC tokens? Ethers.js

I'm coding my small app and I'm having trouble getting BSC token prices. The problem is: I'm getting weird values for some specific pairs (eg. SHARD/WBNB, SAFEMARS/WBNB) How can I get a basic and ...
0
votes
0answers
17 views

How to create multiple signatures without many dialogs (sign)

We use signatures for verifying certain functionalities in our smart contracts. However, we want to bulk create items in these smart contracts. Because the items all require a different signature, we ...
2
votes
1answer
53 views

web3 estimateGas() from fallback function

When I sign and send raw transactions with web3 in javascipt , to call a method from Smart Contract, I always pass the transaction gas variable after getting it with estimateGas function, from Smart ...
0
votes
0answers
11 views

How to sign tx with privatekey in etherjs(nodejs)

How can i sign a transaction with etehrejs with a privatekey only? The code i have requires mnemonic, which i dont want to use, i want to sign tx with privatekey //const mnemonic = 'Mnemonic goes here'...
0
votes
1answer
37 views

Whats exactly Ether unit return web3.eth.estimateGas, wei, gwei …?

I am testing with function web3.eth.estimateGas and is not clear what Ether unit is returning. Looks like it's gwei, but my final calculations don't match. In my code, the EGAS returned is 84753. I ...
0
votes
0answers
11 views

Web3 is not a constructor

I am making a to do list application using metamask,following this tutorial and my truffle-contract.js keeps giving this error "Uncaught TypeError: Web3 is not a constructor" and references ...
1
vote
1answer
18 views

Can two addresses ever have the same sorting value?

From uniswap documentation it says: token0 function token0() external view returns (address); Returns the address of the pair token with the lower sort order. token1 function token1() external view ...
0
votes
0answers
559 views

Noob Troubleshooting failed BSC transaction using ethers.js and Pancakeswap v2 router

How do i debug or troubleshoot this... I am going broke $0.07 at a time.. LOL The code approves WBNB on Pancakeswap and gives a transaction receipt. Then it fails the swapExactTokensForTokens when ...
0
votes
1answer
27 views

Code Example: Waiting for N blocks then running a method?

I'm new to Javascript and Etherjs. I'm trying to interact with a specific contract in the following way. The contract has two functions, hi and bye. I want to first run contract.hi();, wait N blocks ...
0
votes
1answer
20 views

What does this block of code do?

Can anyone explain or point me to a specific source where I can learn about .providers functions. In particular I am trying to understand what this block of code does: for (let i = 0; i < 257; i++) ...
1
vote
1answer
129 views

ethers gasLimit gasPrice

I am a noob.. I am trying to set gasPrice and gasLimit since I am getting a gas estimation error. I just don't understand where/how to insert it into the transaction. This is on the BSC network. ...
0
votes
0answers
10 views

Eth or USD values of token transfers/transactions

Is there any way to retrieve the eth or dollar amount of a Transaction Like etherscan shows on their Website when clicking on a Transaction? Are they pulling price data of the transferred tokens the ...
0
votes
0answers
24 views

TypeError: Cannot read property 'length' of undefined

When I want to call MyContract's function like: address payable owner = 0x12345.....; function addHouse(uint _lease,uint _totalRent,uint _tenantNum)public{ houseInfo[owner].push(House(...
2
votes
2answers
251 views

tx fee (2.11 ether) exceeds the configured cap (1.00 ether), how to bypass default cap?

I'm getting this error when trying to make a simple ETH(BNB) transaction with very high gas, I've tried using different scripts with both web3 and ethers.js and both throw the same error on the BSC ...
1
vote
0answers
27 views

Web3.js: Subscribe logs to get new contracts

I want to create a script that always notifies me if a new contract is created. My idea was to look for the "PairCreated" function. To validate if that is correct I have tested it with a ...
0
votes
0answers
28 views

Not able to understand migration file for Crowdsale in ERC20

I am trying to understand nuts and bolts of the simple CrowdSales in ERC20. In the simplest way, we have a smart contract that mint the fixed number of tokens (SimpleToken) and then we have the ...
2
votes
2answers
33 views

why do i get the error Contract Token“ and ”Ethswap" token contract is not deployed to detected network error

I deployed my contract sent my decentralized application to Github pages. (GH.pages) here is the link to see it, it will say error not deployed to the detected network if you want to see the ...
0
votes
0answers
11 views

Issue interfacing smart contract with the front end

I'm actually trying to write a simple smart contract with front end that takes a value from the user and saves that in the variable in the smart contract. The index.html part of my project is <!...
0
votes
1answer
15 views

format transfered value with contracts decimals

I have the amount of transfered tokens converted from a transactionreceipts log data. for example USDT the value I got is 500000000 , USDT has 6 decimals. The actual transfered value is only 500 USDT, ...
0
votes
0answers
9 views

Use ERC165Checker library function in web3

As I understand the ERC165Checker library provides the _supportsInterface function which takes a contract address and an interfaceId and returns whether that contract has the specific functions. How ...
0
votes
0answers
23 views

IPFS hash link keep loading without not responding

I'm trying to add many JSON files in IPFS using the following API from this liberary py-ipfs-http-client, after running locally ipfs daemon: client.add('item.json') And here is the output of the item....
1
vote
1answer
319 views

How to send uint256 and Address types to Smart contract in JavaScript web3/ethers?

Im trying to send a query to Pancakeswap's router function getAmoutsOut here the code for importing the contract using ethers ABI: const router = new ethers.Contract('...
1
vote
1answer
26 views

Incorrect Product of BigDecimals

My solidity function emits an event with a uint256 of: 5060584000000000000000000 The problem is on the truffle side in my javascript test. Here is the code: const { BN, expectEvent, constants } = ...
0
votes
1answer
229 views

insufficient funds for intrinsic transaction cost

i've codded a script using js to trigger a buy on uniswap. the way i achieved this is through importing uniswaps smart contracts using this line of code: const router = new ethers.Contract(addresses....
0
votes
1answer
16 views

How can I view with web3.js all the ETH transfers to an ethereum address? [duplicate]

How could I list with Web3.js all the ETH transactions to an address? Thank you
1
vote
1answer
25 views

OpenZeppelin test helper: expectEvent.inTransaction error

I'm trying to use OZ Test helpers to pass a test when a specific event is emitted. Here is the logic: I call function1 with a JS Promise. function1 calls function2 which emits an event. Parts of ...
1
vote
1answer
439 views

How to set a custom gwei / gas price on uniswap/sdk Javascript using ethers.js module?

Im building an app to do trades on uniswap using ethers module. ive created contracts and imported the router and the factory contracts using this code: const factory = new ethers.Contract( ...
0
votes
0answers
17 views

Get the value of the mapping and array from solidity to javascript

I have this dummy contract. How can I get the value of the whole Positions array and mapping positionIdsOf in plain javascript? contract DummyContract{ mapping(address => uint256[]) public ...
0
votes
0answers
8 views

Getting error on refreshing page react dapp using drizzle?

I am working on a dapp, it is working fine but one problem I am facing and it stuck my development. Please solve this if anyone knows how to do this and may be I am missing something?? PROBLEM when ...

1
2 3 4 5
16