Questions tagged [typescript]

Typescript is a superset of JavaScript and adds optional static typing to the language.

Filter by
Sorted by
Tagged with
0
votes
1answer
22 views

where to get typings for ethereum object on window

I was wondering where to get typings for the ethereum object on window that would be added through the metamask or some other wallet extension. thank you.
0
votes
0answers
9 views

Passing structs as an argument in typescript

//in solidity struct T { uint256 x; uint256 y; } //in typescript type T = ([BigNumber, BigNumber] & { x: BigNumber; y: BigNumber })[]; const arr: T = []; //error arr.push({ x: ...
0
votes
0answers
83 views

How to calculate price impact correctly like poocoin or pancakeswap?

I am trying to get price impact like poocoin and pancake swap and I got a formula for that also, formula -> Understand price impact and liquidity in pancakeswap But the problem is that the price ...
0
votes
0answers
22 views

Truffle's artifact is undefined when running truffle migrate

I'm trying to run truffle migrate on two js files: 1_initial_migration.js and 2_deploy_contracts.js. I can successfully compile my .sol files to .json ABIs but then when I try to migrate I get the ...
1
vote
1answer
14 views

Fetching InternalType data from another contract

basically I have this ABI for a contract {"internalType":"bytes","name":"_DATA","type":"bytes"}],"name":"function","...
0
votes
1answer
139 views

Debug hardhat project using intellij

I've created an hardhat project that uses typescript. As I'm trying to run the test from intellij I'm getting: TSError: ⨯ Unable to compile TypeScript: test/index.ts(2,10): error TS2305: Module '"...
0
votes
0answers
18 views

How To Perform web3.eth.sendSignedTransaction With Private Key [duplicate]

Hello Team How Can You Create A Signed Transaction with a Private Key using Binance Smart Chain And Determine Weather the Transaction Was Successful Or Not? Using Typescript
0
votes
0answers
270 views

error overflow pasing value to smart contract method

I am having an error when I want to send values ​​to the method in my smart contract, an example of what I am sending is: { from: '0x285A3aF6cAF3483676Ef10416784636b109eE6a8', to: '...
1
vote
1answer
101 views

Solidity 0.8: delegatecall does not mutate contract's storage

I have this problem solving Ethernaut challenge Delegation: The following is the original contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "hardhat/console.sol"; ...
0
votes
1answer
94 views

'Invalid account name or access token' when deploying to Thegraph

I'm currently working on deploy a subgraph to the hosted service on thegraph. It's to track volume and liquidity of a new token on the bsc. The thing is, I'm using a v1 clone from PCS, and everything ...
0
votes
0answers
99 views

Why do I get "Cannot find name" errors in a TypeScript script that uses Uniswap?

I was following this tutorial and then I followed this tutorial to mint a position on a Uniswap pool. This is the final script I end up with: import { ethers } from "ethers"; import { Pool } ...
0
votes
0answers
202 views

Getting a could not detect network error when I try to connect to a Hardhat node which is connected to Alchemy

I have set up my project following these guides (in order): https://hardhat.org/getting-started/#overview (the installation part) https://docs.uniswap.org/sdk/guides/using-ethers (the first steps ...
0
votes
1answer
101 views

Forking a dApp for a school project

I'm trying to create a fork of Ohm to simply run in a local environment for now. I'm slowly teaching myself how to code in solidity and have a few basic web apps under my belt. I'm running into an ...
0
votes
0answers
9 views

3Box returns error rather than desired account info

3box returns {"status":"error","message":"Address link not found, address does not have a 3Box or is malformed"} when using this.profile = this.threebox....
3
votes
2answers
1k views

How to get chainId / network name / network id etc in hardhat?

I'm looking to get the ID of the chain/network I'm running a script on in hardhat. How can I get the names and IDs?
1
vote
1answer
494 views

Invalid value undefined for HardhatConfig.networks.mainnet_fork.url - Expected a value of type string

I have an ALCHEMY_MAINNET_RPC_URL environment that is of type string. I can verify it as such with: const ALCHEMY_MAINNET_RPC_URL = process.env.ALCHEMY_MAINNET_RPC_URL || '' console.log(typeof (...
0
votes
0answers
18 views

Querying conditionally with graphQL

I have this query which is working fine: const CHART_DATA = gql` query chart{ ethereum(network: bsc) { dexTrades( options: {limit: 10000, asc: "timeInterval.hour"} date: {since: &...
0
votes
0answers
49 views

how to cache responses of rpc api calls in DApps

Issue: JSON RPC Queries When interacting with an ethereum rpc interface for building DApps with JS or TS, the huge amount of communication round trips becomes a huge burden. The UI just takes a couple ...
0
votes
0answers
332 views

SyntaxError: Cannot use import statement outside a module occuring after restarting machine

I am attempting to create a simple react site using typescript hardhat. I can get the full stack created, compile contracts and view the site to interact with the greeter contract. After restarting (...
0
votes
1answer
81 views

Subgraph (Graph Protocol) not building out of schema correctly

Doing a quick start tutorial to get back in the subgraph mode and my mapping (even though very simple) is not building. The types will compile, but I cannot deploy it due to it being unable to build. ...
0
votes
1answer
292 views

How can I run uniswap app interface on my local?

For a few days, I have been trying to run uniswap v3 app interface(https://app.uniswap.org/#/swap) on my local. Reference url : https://github.com/ChainSafe/uniswap-frontend https://github.com/Uniswap/...
0
votes
0answers
1k views

Are the Hardhat provided accounts' public keys as accessible as their private keys?

I know that if I run Hardhat node, I will be provided with the addresses and private keys of the Hardhat provided accounts, like this: Hardhat Accounts ======== Account #0: ...
0
votes
1answer
100 views

How to change the scope of a variable in a Hardhat test written in TypeScript?

I am trying to write Hardhat tests with TypeScript and am struggling with the scope of (thus accessing) certain variables. I have provided a simplified snippet of what I am struggling with. Below, is ...
0
votes
0answers
166 views

How to send tether token in ether wallet using web3

I am gonna send tether token from my wallet address to other wallet address using web3. const Web3 = require('web3'); const web3 = new Web3('https://mainnet.infura.io/v3/projectId'); web3....
2
votes
2answers
1k views

How to get Hardhat to log a returned variable rather than the entire transaction receipt? (Test written in TypeScript)

I have a function, fn(), in a contract that returns a variable. I am then testing said function's returned variable value in a Hardhat unit test written in TypeScript. However, when I console.log the ...
0
votes
1answer
203 views

Get mapping value in hardhat

I have a mapping in my contract mapping (uint256 => uint256) totalBoostedPercent; I am using hardhat and typechain to generate type from my contract. In my test file.ts, I tried to access the ...
0
votes
1answer
28 views

How to use bn-chai in a typescript test script?

I would like to use bn-chai plugin for chai in a test script written in typescript. I imported (the official documentation uses require) the dependencies and set chai according documentation: import { ...
0
votes
1answer
204 views

What is the Polygon equivalent of `import { useWallet } from '@binance-chain/bsc-use-wallet'`

I'm following a private code tutorial for building a bsc dapp that calls import { useWallet } from '@binance-chain/bsc-use-wallet'. However my current project is going to be for the Polygon network. ...
1
vote
2answers
3k views

Calculate The Gas Fee Of A Smart Contract Function Call And Convert The Result to USD Value

How Does One Estimate The Gas Fee Of Particular Smart Contract Function Call? I Am Aware Of Using web3.eth.estimateGas How Can One Take This Estimated Gas Result and Depending on Network Connected ...
0
votes
1answer
365 views

Correct Typescript typing for web3 ethereum contract

I'm trying to understand the correct typing I should use for a web3 eth contract that is one of the parameters of my function: import * as express from "express"; import { check, oneOf, ...
1
vote
2answers
506 views

Can't get info with web3: web3.eth.getAccounts returns undefined

I'm trying to connect to the blockchain via web3 and metamask and the web3.eth.getAccounts() method is returning undefined, however window.ethereum.request({ method: 'eth_requestAccounts' }) returns ...
0
votes
1answer
175 views

Dapp with frontend

I made a login page with metamask for my Dapp, but now I need to link my login button to the profile page which will have student details like name, phonenumber, certificates (pdf) etc. where these ...
3
votes
0answers
744 views

Ethers and Web3-React: Cannot estimate gas when trying to connect with contracts deployed on testnet and using Alchemy as node provider

I'm trying to connect with contracts deployed on the Rinkeby testnet using a node provider. When I was testing using hardhat as a local node, the contracts are called with no problem, but when I ...
0
votes
0answers
74 views

How can I pass instance of provider and contract to all of my React components?

I have done the hardhat greeting tutorial found here and it was very helpful. To continue learning, I am building a slightly more advanced project that uses multiple react components. One thing that ...
1
vote
0answers
297 views

Decoding transaction data using abi-decoder

I'm trying to write a very simple script in typescript that finds uniswap transactions and decodes the transaction data so I can read the function being called and the parameters it is being called ...
0
votes
1answer
878 views

What is the equivilent to Solidity's abi.encode() function in Web3 JS?

I have a function in Solidity, that I would like to replicate using Typescript and Web3 function mint( address to, uint256[] memory ids, uint256 indexToMint ) public { ...
2
votes
3answers
1k views

String to Hex in Ethers.js

Only one question: How can I convert string to hex in ethers.js I need some alternative to: web3.utils.utf8ToHex() - but in ethers Any help is appreciated
5
votes
1answer
329 views

Test contract internal functions

I'd like to test a contract internal functions. I used to inherit the contract and test it with truffle but that involved Solidity test files. Can I do the same with my current stack (hardhat/mocha/...
2
votes
1answer
545 views

Truffle migration with TypeScript

I've been able to run truffle tests successfully using TypeScript, but when it comes to migration, I get stuck. 1) My current setup: tsconfig.json { "compilerOptions": { "...
4
votes
3answers
4k views

Trouble with web3.eth.Contract, ABI usage with Typescript

I am having a bit of trouble using web3.eth.Contract with Typescript.. import * as ERC721ABI from "../ABIs/ERC721.json"; import Web3 from "web3"; ... const contract = new web3....
1
vote
2answers
103 views

uint16 conversion issue

So I want to test this Solidity code using Typescript but faced with a type conversion issue. uint16 base; function addNumberToBase(uint16 number_) { // This number must be between 1 ~ 5 ...
8
votes
3answers
8k views

Trying to use window.ethereum.request in Typescript errors out with Property 'request' does not exist on type 'EthereumProvider'

Except for one unanswered question from last November, I cannot find anything . . . . I am revamping some typescript code (in Visual Studio) for the Metamask January change. Previously, I was using ...
1
vote
1answer
521 views

How to extract signature from web3.eth.sign or web3.personal.sign

In React Typescript (.tsx file), I'm trying to use web3.eth.sign to validate an account. The signature is being generated properly, but I can't seem to get the signature out of the callback function. ...
1
vote
1answer
40 views

Network configuration for Fortmatic on 'ropsten' -- typescript

So I am trying to configure the the ropsten network by injecting the fortmatic provider into web3, but am getting these errors. My code is exactly how they have it in their documentation, so idk why I ...
1
vote
0answers
1k views

window.ethereum.request does not exist on type "isMetaMask, on, removeListener"

It might be a pretty simple question for most, but how do I use the request method on window.ethereum if it does not exist? I see all sorts of properties and methods in the metamask docs, but when I ...
1
vote
0answers
134 views

Typechain and Batch Requests

I'm trying to send a batch request of transactions to my contract from web3. Using Typechain, my contract's methods are of type NonPayableTransactionObject<void>, which doesn't appear to support ...
2
votes
1answer
44 views

Library for Ethereum types?

Is there a library for Ethereum types, for tests written in TypeScript? For example, an address type would be better to use instead of a generic string for Ethereum accounts.
3
votes
1answer
1k views

How to import the Contract type from the web3.js library?

Here's how I can do that in ethers@4.0.47: import { Contract, ethers } from "ethers"; const contractInstance: Contract = new ethers.Contract(address, abi); But in web3.js@1.2.8 none of the ...
5
votes
1answer
1k views

Alternatives for Truffle for running and writing tests

Truffle offers many conveniences for writing tests for Ethereum smart contracts. The benefits include no need for a separate chain process like Ganache, complex automation of linking and deploying of ...
3
votes
1answer
1k views

How to mock an ethers provider while testing with jest?

In the real app, I'm using the web3-react hook to inject the provider, etc. How do I best mock that/replicate that in a Jest Typescript environment?