Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore API Contract Documentation to v5 #982

Closed
jeffprestes opened this issue Aug 1, 2020 · 4 comments
Closed

Restore API Contract Documentation to v5 #982

jeffprestes opened this issue Aug 1, 2020 · 4 comments
Labels
documentation Documentation related issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@jeffprestes
Copy link

As I give classes about DApp development ethers.js documentation is important to the students and to all new DApp developers. One of most useful sections is
https://docs.ethers.io/v4/api-contract.html?highlight=value#connecting-to-existing-contracts

This documentation, if I am not mistaken, is missing at v5 documentation.

Could you please include it? Or could you give instructions how to help you to include it in the new version documentation?

Thanks in advance

@ricmoo
Copy link
Member

ricmoo commented Aug 2, 2020

I should certainly add a lot more (especially providers vs signers), but here is what is currently in the v5 docs: https://docs.ethers.io/v5/api/contract/contract/#Contract-connect

Is there any specific wording of the v4 docs You want maintained or ported over?

@jeffprestes
Copy link
Author

Maybe bring back the code samples. Only the sentences in the actual documentations are very poor to understand. I know is hard to write all this alone. I would do my best to improve the documentation because the samples are very very important to the students

@ricmoo ricmoo added documentation Documentation related issue. on-deck This Enhancement or Bug is currently being worked on. labels Aug 23, 2020
@ricmoo
Copy link
Member

ricmoo commented Aug 10, 2021

I've finally got around to updating this page, which should hopefully cover everything you need. :)

During docs generation, the page deploys a simple ERC20-like contract to a local Geth instance and each code example interacts with it, so it should be quite true-to-life.

If there is anything missing, please let me know. :)

Thanks! :)

@ricmoo ricmoo closed this as completed Aug 10, 2021
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Aug 10, 2021
@jeffprestes
Copy link
Author

jeffprestes commented Aug 10, 2021

Wow. It was a huge improvement. Thank you very much!

However, I know it could sound silly but the comprehensive example showing how to connect to a provider and to a signer it is even more important to a new student to allowing them to be able to read/write in a Contract. These are few more lines but I assure you it is going to help a lot.

Would you please mind adding these lines too?

let provider = ethers.getDefaultProvider();

and

// A Signer from a private key
let privateKey = '0x0123456789012345678901234567890123456789012345678901234567890123';
let wallet = new ethers.Wallet(privateKey, provider);

//Or for Web DApps connects to a embedded wallet such as Metamask
// A Web3Provider wraps a standard Web3 provider, which is
// what Metamask injects as window.ethereum into each page
provider = new ethers.providers.Web3Provider(window.ethereum)

// The Metamask plugin also allows signing transactions to
// send ether and pay to change state within the blockchain.
// For this, you need the account signer...
wallet = provider.getSigner()

// Create a new instance of the Contract with a Signer, which allows
// update methods
let contractWithSigner = contract.connect(wallet);

//

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation related issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants