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
1 answer
55 views

Sepolia Smart Contract - Withdrawal function

I've deployed a simple wallet solidity smart contract on the sepolia test network, and trying to test withdrawals. The first two attempts succeeded but I run into an 'insufficient funds' error despite ...
itsSlumpHoe's user avatar
0 votes
0 answers
20 views

Is it possible to make interfaces with BaseContract as a type in ethers.js?

Is it possible in ethers typescript to set a class variable to what object this functio would return? new ethers.Contract(V2_FACTORY_ADDRESSES[ChainId.MAINNET], CONTRACTABI.uniswap.factory, ...
Esko918's user avatar
  • 103
1 vote
1 answer
68 views

Listening to events in unit test using Viem

I want to be able to tell how many approval event were sent during my test as I cannot tell how many where sent since they are auto-approved by hardhat Running Environment.
codekoriko's user avatar
0 votes
1 answer
54 views

ethers js queryFilter for ERC20 list of addresses

Is there a way to get the list of transferred ERC20 tokens to a list of addresses in one call. Right now I am running const events = await contract.queryFilter(erc20Contract.filters.Transfer, ...
klugjo's user avatar
  • 113
1 vote
1 answer
47 views

Issue with Smart Contract Interaction using Web3.js 4.2.0: TransactionRevertedWithoutReasonError on MetaMask and Sepolia Testnet

Problem Overview I am facing an issue while interacting with a smart contract using Web3.js version 4.2.0. The specific method causing trouble is broadcastMessage(string), designed to store a string ...
Dawid's user avatar
  • 121
0 votes
0 answers
22 views

`web3-eth-contract` instance throws error on using `setProvider(RPC_URL)`

I created an instance of web3-eth-contract and then called the setProvider(..) function on it according to the official documentation of Web3.js, but I end up getting this error: Uncaught (in promise) ...
alfheimrShiven's user avatar
0 votes
1 answer
44 views

Solidity Smart Contract Behaving Weird on Goerli Testnet

I have a vite-project in typescript that I want to have eth deposit and withdrawal capability. I'm new to the crypto space and trying to implement a simple wallet contract using Truffle on the ETH ...
s_tanay's user avatar
0 votes
2 answers
190 views

How to pass blockNumber to viem call?

I'm trying to view the owner of a certain NFT at a specific blockNumber, when I make the viem call without the blockNumber parameter it works perfectly, however, once I try to pass a blockNumber with ...
Rohan Nero's user avatar
  • 1,577
0 votes
0 answers
32 views

Smart/Auto Slippage

Is there a typescript library which can automatically calculate your slippage for you or does someone know how to calculate it? I'm aware that we can manually fill in slippage but what I need is a ...
Arctic's user avatar
  • 1
1 vote
0 answers
180 views

How do you sell an ERC20 Token for ETH with Uniswap Universal Router?

I'm attempting to swap ERC20 tokens for ETH with the Uniswap Unviersal Router. When doing an ETH -> ERC20 swap everything works fine, but with the code below (Function where it is going wrong) ...
Bobby's user avatar
  • 11
0 votes
1 answer
13 views

How to Ensure TypeScript Type-Checking in a Hardhat Project Before Execution?

I'm working on a Hardhat project with TypeScript enabled. Currently, I can run my TypeScript scripts even if there are type errors, presumably due to the use of ts-node. I would like to enforce type ...
MShakeG's user avatar
  • 1,633
0 votes
0 answers
26 views

Swap Box and Token modal stopped rendering on the browser

Originally, it was a swap built on Ethereum fetching token quotes & prices via api. That version functions as intended Now, I am working implementing conditional logic to fect the token list and ...
Dorian_Gallo's user avatar
0 votes
1 answer
139 views

Need Help Generating LP Contract Addresses using Uniswap V3 SDK

I'm in a bit of a coding jam, and could use some help understanding how to utilize the Uniswap V3 SDK to generate accurate Liquidity Pool Addresses. I have already gone through the uniswap ...
armitus's user avatar
  • 111
2 votes
0 answers
161 views

"Property 'writeContract' does not exist on type" when using viem

Whenever I call writeContract on WalletClient, I get this error in typescript on vscode( image below): Property 'writeContract' does not exist on type '{ account: Account<`0x${string}`> | ...
Pranav Singhal's user avatar
1 vote
0 answers
67 views

How to turn-off NextJS hot module replacement warnings

I'm just starting out with the Next.js framework, and I can't find any information on how to turn off the repetitive warnings caused by hot reloading a modified page: This may have been caused by live ...
Lucky Degen's user avatar
1 vote
1 answer
75 views

Property 'zkUpgrades' does not exist on type 'HardhatRuntimeEnvironment'.ts(2339)

I have a test file for testing an upgradable smart contract on zkSync by looking at the docs here. I'm getting a typescript error on this line await hre.zkUpgrades.deployProxy(deployer.zkWallet, ...
pakoray's user avatar
  • 145
0 votes
1 answer
91 views

Cannot recover signer

I am facing a problem where recoveredAddress is not restored correctly. We assume that the address of the owner who originally deployed the smart contract is returned. Am I making some big mistake? ...
tgf8faf's user avatar
0 votes
0 answers
24 views

installing dependencies in ts

when installing dependencies in a ts project ( npm install ) i get this error : " Cannot read properties of null (reading 'pickAlgorithm') " the package : { "name": "flash-...
adam mr's user avatar
  • 101
1 vote
1 answer
54 views

What is the right way to import a contract type that uses an interface in hardhat?

I have a contract with an interface that I want to test with hardhat the contract looks like this interface IGame { function play(uint guess) external; } contract Test { address private owner;...
Eugene1111's user avatar
2 votes
1 answer
655 views

Argument of type 'HardhatEthersSigner' is not assignable to parameter of type 'string | Signer | undefined'

I'm writing unit tests for an ERC20 token in TypeScript. I'm getting this error from TypeScript: Argument of type 'HardhatEthersSigner' is not assignable to parameter of type 'string | Signer | ...
pakoray's user avatar
  • 145
0 votes
0 answers
86 views

Uniswap 'interface' cannot resolve 'fs' polyfill

I've just installed the uniswap interface project i've run the following: yarn yarn postinstall yarn graphql yarn contracts yarn ajv yarn i18n When I got to yarn start, I'm receiving the following ...
Ritzy Dev's user avatar
  • 271
1 vote
1 answer
57 views

Need help testing my smart contract

I am currently in the process of testing my solidity smart contract using hardhat and am a bit confused on how I should do it. This is the very first time I am testing a smart contract so I am bit ...
EGstacking's user avatar
1 vote
2 answers
76 views

Can we add network param to run function to verify contract on specific network?

I am trying to create a task for deploying and verifying any contract from my project.. task below successfully deployed contract but it is not able to verify.. How can i tell hre.run function to run ...
Rushikesh Jadhav's user avatar
0 votes
0 answers
31 views

Safe-aa-sdk getting error like execution reverted for tx with calldata like approve, transfer but works for send native gas(without data like "0x")

Hey team I am trying to execute tx like erc20 simple transaction by populate calldata and send or relayTransaction using safe-aa(4337). But it is getting error like execution reverted. But safe-aa ...
sunny radadiya's user avatar
0 votes
0 answers
64 views

TS1005 and 1109 errors

ERROR in src/environments/environment.ts(7,14): error TS1005: ',' expected. lafs-web | src/environments/environment.ts(8,1): error TS1109: Expression expected. export const environment = { production:...
Robert Pohl's user avatar
0 votes
0 answers
148 views

Problem in interacting with Smart Contract using Web3.js (sendSignedTransaction)

I am making a "CRON JOB" that can interact with my smart contract and call its function at a given interval. But I'm facing problem in interacting with my smart contract. I'm using Web3.js ...
PsychoPunk_Sage's user avatar
0 votes
0 answers
373 views

"TypeError: (0 , ethers_1.getAddress) is not a function" when writing tests in hardhat with typescript

i get this error when i run this test: typescript import { expect } from "chai"; import { ethers } from "hardhat"; import { Ballot } from "../typechain-types"; const ...
robberdom's user avatar
0 votes
2 answers
944 views

How to call useContractRead of wagmi in diferents places of React Component

I have created a handler to try to use the wagmi getter function call. const handleContractReadCurrentDuel = () => { const { data: duel } = useContractRead({ address: ...
Fernando López's user avatar
0 votes
0 answers
93 views

Seeking Help with React Typescript App and Ether.js - Trouble with Tuple Arguments

I'm currently working on a React Typescript app that involves interacting with contracts on the blockchain using Ether.js. While making progress, I've encountered a hurdle that has me scratching my ...
bero's user avatar
  • 1
0 votes
1 answer
423 views

Type error in wagmi's usePrepareContractWrite for value

I have next app with typescript and using wagmi (https://www.npmjs.com/package/wagmi) package to work with smart contracts. I am trying to prepare contract write using usePrepareContractWrite and need ...
user122142's user avatar
0 votes
0 answers
155 views

Using Web3 the value sent as payable (msg.value) is equal to 0

We have a smart contract that is supposed to receive payments in order to mint token; it follows the ERC1155 standards as it extends ERC1155URIStorage. Here is a sample of the contract we deploy: // ...
A.J Alhorr's user avatar
0 votes
1 answer
49 views

invalid BigNumber value for Date

I tried to update the current campaign based on Id, target value and a new date, but getting an error when executing the function function from contract function updateCampaign( uint _id, ...
0xhaz's user avatar
  • 3
0 votes
0 answers
318 views

polygon mumbai testnet doesn't revert error reason, instead confirm transaction with status:false

i use web3js to request to the polygon mumbai testnet using quicknode. when i use ganache, i get error revert reson easily but when i use mumbai testnet, it consume gas and return receipt with status ...
xmrrabbitx's user avatar
0 votes
0 answers
66 views

From web3/Javascript to zkSync-web3/Typescript

I am trying to port some javascript tests targeting the Ethereum mainnet to the new zkSync testnet. This was not a problem with my standard javascript hardhat testing. Moving to typescript/zkSync, I ...
Eric Falkenstein's user avatar
0 votes
1 answer
25 views

How to set owner wallet into useState from router.query?

I'm trying to set the address of a connected wallet into useState as string so that another function can use it to run it's function. const router = useRouter(); const { walletAddress } = ...
Miles Donald's user avatar
0 votes
1 answer
107 views

Using connected wallet to fetch all NFTs using alchemy sdk

I'm trying to pass the user's connected wallet into getNftsForOwner function but am not sure how to do it. If I type out the address into the function like this: const NFTs = await alchemy.nft....
Miles Donald's user avatar
0 votes
1 answer
106 views

How to use the connected wallet in getNftsForOwner for Alchemy SDK function?

I'm using a combination of Thirdweb and Alchemy SDK to fetch all nfts in a connected wallet. Every example I've come across for Alchemy's getNftsForOwner function has the wallet address placed in the ...
Miles Donald's user avatar
0 votes
1 answer
241 views

How to compile smart contract in react app with solc?

I used solc compiler in react app but browser is not compatible with it and gives an error after using that code; const createContract = async () => { const contract = erc1155.print(); ...
samet mollaoglu's user avatar
1 vote
1 answer
237 views

Error at build on Dockerfile image build in hardhat project

I have my hardhat project that builds and run fine using yarn. But when I try to execute "yarn build" from a Dockerfile during the image build process I have the following error: => ERROR ...
user3034457's user avatar
1 vote
2 answers
1k views

How to Build Raw Transaction Data

I only have the source address, the destination address and the amount of money to send. Can I create offline-signed raw transaction data from this information? Also, I want to do something like that ...
scooby's user avatar
  • 11
0 votes
1 answer
190 views

How to list Accounts in ethers.js 6.0^. it does not have the function listAccounts() like in version below 6.0

async () => { console.log("REVALIDATING!!!"); const accounts = (await provider!._detectNetwork()).toJSON(); if(!accounts){ throw "Cannot retreive ...
Syed Mashhud's user avatar
2 votes
0 answers
125 views

Support FACTORY_ADDRESS and INIT_CODE_HASH in different forks of UniswapV2

I'm trying to parse transactions of different UniswapV2 like DEXes and have problems adding new forks of UniswapV2 to my project, such as SushiSwap, etc. I'm using @uniswap/v2-sdk for transactions of ...
Vlad's user avatar
  • 21
0 votes
1 answer
340 views

Hardhat node doesn't work on typescript

Lets say I have a 00-mocks.ts file inside a deploy folder(hardhat project) and the code looks ok: const { ethers, newtwork } = require('hardhat') module.exports = async function () { try { ...
Alireza's user avatar
  • 350
1 vote
0 answers
103 views

How can I run a truly serverless function on web3 type infrastructure?

I want to run a serverless function that is actually serverless. Serverless functions platforms like AWS Lambda, Google Cloud Functions, etc... are not actually serverless. A centralized VM owned by ...
ChristianOConnor's user avatar
1 vote
0 answers
169 views

What is the right typescript type for an event?

Not sure if this the right place thus my question involves more contract testing than solidity but here we go: I implemented a contract factory and spent a couple of hours figuring out how to check if ...
onizukaek's user avatar
  • 111
3 votes
2 answers
3k views

How to get deployed contract address with ethers?

I using hardhat deploy (TypeScript) and am deploying two contracts: the first is a mock ERC20 token and a second is a crowdfunding contract that uses the mock when on a hardhat chain/localhost. I am ...
Kate Johnson's user avatar
1 vote
1 answer
2k views

TypeError: glob is not a function after updating typechain-hardhat to @typechain/hardhat

After updating project from typechain-hardhat to @typechain/hardhat package. Compilation of project throws TypeError: glob is not a function error. And I can not run scripts, tests, compile etc. An ...
r0uge's user avatar
  • 11
0 votes
1 answer
778 views

export 'utils' (imported as 'utils') was not found in 'ethers'

I'm trying to build a web app that can interact with blockchain, I'm using Brownie as Solidity framework and React.js. I installed useDapp to connect with my wallet, but in the first simple usage i ...
Ahmed Laggoun's user avatar
2 votes
1 answer
1k views

How can I assign my custom contract type to a contract instance from Ethers?

Using Ethers, I'm creating an instance of my deployed contract as follows: import MySwapV2FactoryABI from "src/abis/MySwapV2Factory.json"; const provider = new ethers.providers....
code_learner93's user avatar
0 votes
1 answer
852 views

Ethers - What is the use of the Interface class?

I'm just getting started with using the Ethers library, and I'd like to understand more about the Interface class. Why do we use it? And under what use cases will it be useful to use Interface? From ...
code_learner93's user avatar