question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type improvement : <contract>.functions could be ContractFunctions<ContractTransaction>

See original GitHub issue

this line https://github.com/ethers-io/ethers.js/blob/e0b1d0e1e0280af860aaa593744a1a177f828397/packages/contracts/src.ts/index.ts#L581

could be readonly functions: { [ name: string ]: ContractFunction<ContractTransaction> };

or am I missing something ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Nov 6, 2020

There is no read-only or write-only buckets. All buckets have all functions, including the root. The buckets just change how those methods operate. For any given method all these operations have cases that a given bucket is useful.

  • function: for constant, calls it, otherwise signs and sends a transaction
  • populateTransaction: for a constant, the TX w/ data required for eth_call, otherwise the transaction required to send
  • estimateGas: for constant, the gas consumed executing this on a node, otherwise the gas limit estimated for the network to accept it
  • callStatic: for constant functions, it does nothing different than the root, otherwise use eth_call instead of sending a transaction
  • root: same as function but with single argument functions reduced to their value

If you ever needed just the read-only, you could use contract.interface.functions.filter(f => f.constant) and if you wanted state-changing contract.interface.functions.filter(f => !f.constant). Or you could find only payable or only non-payable or only pure… Whatever category you wanted. But those cases are not common, so I don’t see a need for a short-cut. 😃

For a somewhat more complete explanation, see here although it could certainly use more examples…

0reactions
ricmoocommented, Nov 24, 2020

I think the OP has been answered, so I’m going to close this now. Please feel free to re-open if I’m mistaken though.

Thanks! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contracts — Web3.py 5.31.3 documentation - Read the Docs
This variation mirrors ConciseContract , but it invokes all methods as a transaction rather than a call, so if the classic contract had...
Read more >
Solidity Best Practices for Smart Contract Security - ConsenSys
From monitoring to timestamp considerations, here are some pro tips to ensure your Ethereum smart contracts are fortified.
Read more >
Contracts — Solidity 0.8.17 documentation
It is a compile-time type check, which can be circumvented doing invalid explicit conversions between contract types, because the compiler can verify that...
Read more >
Smart contract development: Common mistakes to avoid
Learn about common smart contract development mistakes to avoid to protect contracts from attacks and prevent monetary loss.
Read more >
Interact with your contracts - Truffle Suite
When you execute a contract function via a call you will receive the return value immediately. In summary, calls: Are free (do not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found