Skip to content

Don't encourage using ConciseContract or ImplicitContract as ContractFactoryClass #573

Closed
@carver

Description

@carver

What was wrong?

Documentation encourages using ConciseContract and ImplicitContract as a ContractFactoryClass. They are not proper subclasses of Contract, which causes confusion when the API changes (like deploy() is no longer available)

How can it be fixed?

  1. Remove references to using these classes as a factory in the documentation
  2. Show preferred implementation instead
  3. Show using methods on the core contract before wrapping up in these convenience classes
  4. Add a deprecation warning when using ConciseContract or ImplicitContract as a factory.

Preferred implementation of ConciseContract, with example core contract methods:

TokenContract = w3.eth.contract(abi=...)

deploy_hash = TokenContract.deploy() 
# wait for deployment transaction to be mined
while True:
    receipt = w3.eth.getTransactionReceipt(deploy_hash)
    if receipt:
        break
    time.sleep(1)

token_contract = TokenContract(receipt['contractAddress'])
token = ConciseContract(token_contract)

 # return my balance
token.balanceOf(MY_ADDR)

 # returns my balance with the core contract (exactly equivalent to previous line)
token_contract.functions.balanceOf(MY_ADDR).call()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions