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
0 answers
3 views

How can I create the typechain directory in my hardhat project?

I have set up a hardhat project with typescript a while ago and want to write some tests. Now I only have a typechain-types directory and it doesn't give me the types I am used to. Where is the plain ...
user avatar
  • 177
0 votes
0 answers
3 views

Error indexing handleIncreaseLiquidity on a local graph-node on Token#get:decimals with message: "Value is not a BigInt"

Hi, I' m tring to deploy this subgraph to a local graph node that is connected to a local ethereum node on the goerli network. The OS is xubuntu v21.10 . The node is hyperledger besu v22.1.2. The ...
user avatar
0 votes
1 answer
14 views

How can I batch execute multiple Gnosis Safe transactions via js/ts?

I've been using the typescript npm libs gnosis.pm/safe-core-sdk and @gnosis.pm/safe-service-client to execute Gnosis Safe transactions one-by-one. Recently I've noticed in the web UI that one can ...
user avatar
0 votes
1 answer
78 views

Instantiate a contract using interface generated by TypeChain

in my solidity codebase I am using an interface and these are the types generated by TypeChain: import { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, PopulatedTransaction, Signer, ...
user avatar
0 votes
1 answer
74 views

Smart contract events are being emitted multiple times with exactly the same data using Ethers JS

Please someone help me here. I am trying to read events to update the state of the data to make my dapp but the problem I am facing is on a function call, the same event is emitted multiple times (16 ...
user avatar
0 votes
0 answers
57 views

How to get hardhat to give more detailed error messages?

I am trying to call some function from the smart contract and I am only recieving the error message Error: Transaction reverted without a reason string . This makes degubbing quite hard. Is there ...
user avatar
0 votes
1 answer
49 views

useContractCall in a loop from React

I have created a smart contract where users can mint several ERC721 tokens. I used the ERC721Enumerable extension from OpenZeppelin so I can easily retrieve which tokens have been minted by a specific ...
user avatar
  • 11
0 votes
2 answers
147 views

Accessing storage of a map of a map

I would like to access the storage of a specific contract using ethers.js and getStorageAt, but I can't get my head around how to do this for the mapping(address => mapping(address => address)) ...
user avatar
  • 101
0 votes
0 answers
8 views

go-ipfs v0 api address for ipfs-http-client

I have go-ipfs on linux machine. I am trying to use it as gateway to IPFS network. How can I connect to go-ipfs using ipfs-http-client? I tried pass my host IP as url like documentation said but it ...
user avatar
1 vote
0 answers
47 views

Argument of type '(address: any) => void' is not assignable to parameter of type '(this: Suite) => void'

I'm trying to implement the pancakeswap router functions. I've forked the mainnet with hardhat and then tried to receive the addresses with typescript. I'm using the typescript for the first time and ...
user avatar
0 votes
1 answer
99 views

Correct usage of expiry for NFT Swap SDK v4

Creating a NFT trade order where the maker is selling a single 721 NFT, and the taker (same address as maker) is offering to buy it for eth. No matter what I set the expiry value to, the transactions ...
user avatar
0 votes
1 answer
66 views

TypeChain says the struct array field does NOT exist in my Ballot struct, why?

I am trying to test my voting ballot contract using Hardhat/ethers/TypeChain, but for some reason, the Ballot struct's typescript interface is NOT showing the array of choices struct field I have ...
user avatar
  • 1
0 votes
0 answers
86 views

Integrate Metamask in Angular

I am trying to integrate metamask in the Angular app, but Typescript does not know the type of window.ethereum What libraries should be added to get the type of ethereum object. I tried @metamask/...
user avatar
5 votes
3 answers
582 views

How do you check if a contract has a function using Ethers.js?

I want to be able to check using JavaScript/TypeScript & Ethers.js if a contract has a certain function. I want to do this so that if the contract's function doesn't exist, I want to call another. ...
user avatar
  • 372
0 votes
0 answers
34 views

How can I use ts script from another project in truffle tests

I have a project which has 2 parts, onchain and offchain. Onchain - staking contract. Offchain - scheduled ts script for calculations. I want to write test which includes this ts script. This is how ...
user avatar
0 votes
2 answers
111 views

Hardhar test Error : missing argument

I am encounter missing argument error during run hardhat test .below is the script that trigger the error . My function MINT only have 1 argument to pass in and am passing number "1" into ...
user avatar
  • 17
0 votes
1 answer
30 views

how to subctract in type script big numbers?

I'm trying to to subctract in type script big numbers, but getting error... const supply1 = 100000; const _amount = 100; const supply = ethers.utils.parseEther(`${supply1}`); const diff = supply - ...
user avatar
  • 59
0 votes
1 answer
411 views

"before each hook for" during running hardhat test

ive just started learning solidity and I tried to make a contract and encounter error during running hardhat test . 1) FortuneTigersPunk "before each" hook for "should deploy ...
user avatar
  • 17
0 votes
1 answer
94 views

totalSupply() are Undeclared identified and Error when inherit from ERC721Enumerable

've just started learning solidity and I tried to make a contract . I getting error due to totalSupply() are Undeclared identified . contract BYYCC is ERC721, Ownable { using SafeMath for ...
user avatar
  • 17
0 votes
0 answers
42 views

How to get the owner from a smart contract on typescript?

I want to know how to get the owner from a smart contract in typescript! I already try with putting the abi of the view owner, like below: const abi2 = [ { inputs: [], name: 'owner', outputs: [{ ...
user avatar
1 vote
2 answers
739 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.
user avatar
  • 135
0 votes
0 answers
39 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: ...
user avatar
0 votes
0 answers
349 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 ...
user avatar
  • 72
0 votes
1 answer
143 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 ...
user avatar
  • 101
2 votes
1 answer
123 views

Fetching InternalType data from another contract

basically I have this ABI for a contract {"internalType":"bytes","name":"_DATA","type":"bytes"}],"name":"function","...
user avatar
1 vote
1 answer
570 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 '"...
user avatar
  • 501
1 vote
0 answers
1k 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: '...
user avatar
1 vote
2 answers
362 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"; ...
user avatar
  • 113
0 votes
2 answers
594 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 ...
user avatar
  • 1
0 votes
0 answers
619 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 } ...
user avatar
0 votes
0 answers
516 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 ...
user avatar
0 votes
1 answer
212 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 ...
user avatar
0 votes
0 answers
11 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....
user avatar
5 votes
2 answers
5k 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?
user avatar
4 votes
1 answer
3k 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 (...
user avatar
0 votes
0 answers
36 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: &...
user avatar
0 votes
0 answers
117 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 ...
user avatar
0 votes
0 answers
741 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 (...
user avatar
0 votes
1 answer
202 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. ...
user avatar
  • 45
0 votes
1 answer
508 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/...
user avatar
2 votes
1 answer
3k 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: ...
user avatar
  • 53
0 votes
2 answers
360 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 ...
user avatar
  • 53
0 votes
0 answers
264 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....
user avatar
2 votes
2 answers
3k 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 ...
user avatar
  • 53
0 votes
1 answer
797 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 ...
user avatar
  • 3
0 votes
1 answer
61 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 { ...
user avatar
0 votes
1 answer
272 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. ...
user avatar
1 vote
2 answers
6k 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 ...
user avatar
1 vote
2 answers
791 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, ...
user avatar
  • 11
1 vote
2 answers
1k 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 ...
user avatar
  • 331