3

I have a web3 object but I'm working off an example that uses ethersProvider.getSigner(). Is there an equivalent (or mostly equivalent) in the web3 library?

For reference, the ethersProvider is instantiated with const ethersProvider = new ethers.providers.Web3Provider(window.web3.currentProvider);

and the signer is ethersProvider.getSigner()

1 Answer 1

0

web3 works a bit different than ether.js so when you deal with web3 you first establish a connection with the dapp and than when you call a function which change the state you use send() and pass from field with it.

// Do connect to the metamask and bring the account address.

Example:

const web3 = new Web3(window.ethereum);
         
const contract = web3.eth.Contract(abi,Contractaddress);          
         
const data = contract.methods.randomFunction.send({from: `${account[0]}`});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.