Questions tagged [typescript]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
34 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
21 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
99 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
19 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 ...
1
vote
1answer
27 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.
2
votes
1answer
156 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
496 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
291 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?
1
vote
0answers
121 views

What is the easiest way to write truffle tests in typescript?

I read about Typechain, but the configuration is rather verbose and generally feels like a very custom solution: Everytime you change contracts you need to run yarn generate.
4
votes
2answers
2k views

TypeError: web3_1.default is not a constructor

I'm trying to convert a DApp that uses web3.js from JavaScript to TypeScript, but I have encountered a bunch of runtime errors. I'm using Visual Studio Code IDE, and I'm compiling to ES6. I've reduced ...
1
vote
1answer
70 views

Calling transfer returns true but doesn't perform the transfer

I have the following simple transfer method in my contract to transfer my erc20 token to another account: function transfer(address to, uint tokens) public returns (bool success) { balances[msg....
9
votes
4answers
4k views

How to use web3.js@1.0.0-beta34 with TypeScript?

Here is a minimal code for testing: import * as Web3 from "web3" const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545")) const main = async () => { const blockNumber = ...
1
vote
0answers
317 views

Problem with web3.eth.personal.ecRecover

I'm using web3 v1.0 beta33 ethereum packages to do some signing and address recovery in a javascript/Angular5 app. I picked this version because I didn't see this function in 0.2x web3 versions' ...
3
votes
2answers
5k views

Getting Metamask account's balance using fromWei

Using web3 javascript code to get selected account's balance in Metamask and show it in html, web3.eth.getCoinbase(function(err, account) { if (err === null) { App.account = account; $("#...
3
votes
2answers
4k views

How can I use web3.js with Angular 2

I'm trying to import Web3 to my component files which is written in Typescript but I couldn't make it. I used npm install --save web3-typescript-typings and added "include": [ "../node_modules/...