Questions tagged [typescript]
Typescript is a superset of JavaScript and adds optional static typing to the language.
139
questions
0
votes
2
answers
30
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 ...
0
votes
0
answers
21
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 ...
1
vote
0
answers
63
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) ...
0
votes
1
answer
5
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 ...
0
votes
0
answers
9
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 ...
1
vote
1
answer
56
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 ...
1
vote
0
answers
54
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}`> | ...
1
vote
0
answers
19
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 ...
1
vote
1
answer
21
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, ...
0
votes
1
answer
52
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? ...
0
votes
0
answers
16
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-...
1
vote
1
answer
22
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;...
2
votes
1
answer
220
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 | ...
0
votes
0
answers
21
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 ...
1
vote
1
answer
39
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 ...
1
vote
2
answers
33
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 ...
0
votes
0
answers
27
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 ...
0
votes
0
answers
39
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:...
0
votes
0
answers
93
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 ...
0
votes
0
answers
320
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 ...
0
votes
2
answers
486
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: ...
0
votes
0
answers
63
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 ...
0
votes
1
answer
294
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 ...
0
votes
0
answers
110
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:
// ...
0
votes
1
answer
38
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,
...
0
votes
0
answers
263
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 ...
0
votes
0
answers
65
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 ...
0
votes
1
answer
24
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 } = ...
0
votes
1
answer
85
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....
0
votes
1
answer
69
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 ...
0
votes
1
answer
206
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();
...
1
vote
1
answer
190
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 ...
1
vote
2
answers
803
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 ...
0
votes
1
answer
141
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 ...
1
vote
0
answers
63
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 ...
0
votes
1
answer
246
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 {
...
1
vote
0
answers
84
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 ...
1
vote
0
answers
119
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 ...
2
votes
2
answers
2k
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 ...
1
vote
1
answer
1k
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 ...
0
votes
1
answer
651
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 ...
0
votes
0
answers
52
views
Web3.js metamask android contract function fails
const value = web3.utils.toWei(userBalance.toString());
const dETH = new web3.eth.Contract(
dETH_ethAbi as any,
config.goerli.addresses.dEth
);
...
0
votes
0
answers
33
views
How to define gas Limit in typescript eth transaction?
I am currently working on my frist dApp with React and Typescript and come across the problem that MetaMask shows no value and gas limit when signing the transaction -> next step: transaction get ...
1
vote
1
answer
822
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....
0
votes
1
answer
630
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 ...
3
votes
1
answer
433
views
how to sign a batch of transaction with a private key in web3.js
I have created a batch of transactions with the help of web3.js.
Firstly I am batching transactions with the "approve" method of the erc20 contract to approve a smart contract of the tokens ...
0
votes
2
answers
481
views
Can I connect an address and sign a transaction from nodejs without a browser in Wagmi core
I'm building a nestjs backend and I want to execute a write transaction to the contract as the contract owner,
I couldn't find anyway to connect my address and sign the transaction programmatically to ...
0
votes
1
answer
217
views
InvalidInputError: Received invalid block tag 642829559307850963015472508762062935916233390536. Latest block number is 1
After compiling the below dead-simple contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
contract SendWei {
function sendWei(address payable recipient, uint256 amount) public ...
0
votes
2
answers
165
views
Can't load ethereum object from metamask-react in TypeScript
I am trying to add this code to handle the change of accounts in Metamask...
ethereum
.request({ method: 'eth_accounts' })
.then(handleAccountsChanged)
.catch((err: any) => {
// Some ...
1
vote
1
answer
399
views
Property 'revertedWithCustomError' does not exist on type 'Assertion'
Im updating my project from Javascript to Typescript. Up until now I had no issues using revertedWithCustomError. When trying to assert with revertedWithCustomError I get the following linter error ...