GithubHelp home page GithubHelp logo

apeworx / ape-avalanche Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 8.0 38 KB

Avalanche ecosystem plugin for the Ape Framework

Home Page: https://www.apeworx.io/

License: Apache License 2.0

Python 100.00%
ape apeworx avalanche python3 smart-contracts web3

ape-avalanche's Introduction

Quick Start

Ecosystem Plugin for Avalanche (C-Chain) support in Ape

Dependencies

Installation

via ape

You can install this plugin using ape:

ape plugins install avalanche

or via config file:

# ape-config.yaml
plugins:
  - name: avalanche

via pip

You can install the latest release via pip:

pip install ape-avalanche

via setuptools

You can clone the repository and use setuptools for the most up-to-date version:

git clone https://github.com/ApeWorX/ape-avalanche.git
cd ape-avalanche
python3 setup.py install

Quick Usage

Installing this plugin adds support for the Avalanche ecosystem:

ape console --network avalanche:mainnet

Development

This project is in development and should be considered a beta. Things might not be in their final state and breaking changes may occur. Comments, questions, criticisms and pull requests are welcomed.

ape-avalanche's People

Contributors

antazoey avatar dtdang avatar mrsuttton avatar notpeopling2day avatar pock3t-spai avatar sabotagebeats avatar z80dev avatar

Watchers

 avatar  avatar

ape-avalanche's Issues

Cannot deploy smart contract to Fuji Testnet [APE-1167]

Environment information

$ ape --version

0.6.12

$ ape plugins list

Installed Plugins:
vyper 0.6.9
avalanche 0.6.3

  • Python Version: 3.8.12
  • OS: Mac Ventura 13.4.1

What went wrong?

ape-config.yaml
name: sc_learn

plugins:

  • name: avalanche
  • name: vyper

geth:
avalanche:
fuji:
uri: https://api.avax-test.network/ext/bc/C/rpc

  • what command you ran

I loaded an active account on the Avalanche fuji testnet with 1.9 avax. I had a contract that I was able to deploy locally. Here is the sequence of events:

ape console
a = accounts[0]
contract = a.deploy(project.erc721)

Locally this worked and the contract was successfully deployed. I then started ape trying to upload a contract to Fuji testnet.

ape console --network avalanche:fuji:geth --verbosity DEBUG
a = accounts[0]
contract = a.deploy(project.erc721)

The previous command failed with the following traceback: (I'm including successful DEBUG lines too)

DEBUG: Making request. Method: eth_getTransactionCount
DEBUG: Making request HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_getTransactionCount
DEBUG: Getting response HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_getTransactionCount, Response: {'jsonrpc': '2.0', 'id': 7, 'result': '0x4'}
DEBUG: Making request. Method: eth_maxPriorityFeePerGas
DEBUG: Making request HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_maxPriorityFeePerGas
DEBUG: Getting response HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_maxPriorityFeePerGas, Response: {'jsonrpc': '2.0', 'id': 8, 'result': '0x0'}
DEBUG: Making request. Method: eth_getBlockByNumber
DEBUG: Making request HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_getBlockByNumber
DEBUG: Getting response HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_getBlockByNumber, Response: {'jsonrpc': '2.0', 'id': 9, 'result': {'baseFeePerGas': '0x5d21dba00', 'blockExtraData': '0x', 'blockGasCost': '0x0', 'difficulty': '0x1', 'extDataGasUsed': '0x0', 'extDataHash': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', 'extraData': '0x00000000000c8c400000000000000000000000000016dfca0000000000000000000000000000000000000000000000000000000000036a46000000000000000000000000000000000000000000000000', 'gasLimit': '0xe4e1c0', 'gasUsed': '0x164aa', 'hash': '0xc70b77b747f44729657d10fd79c65d7688b0972234140c643ecd8e1d738d6687', 'logsBloom': '0x00000000000000000000000002100000000100000000080000000000020000000000000000004000000000000000000000000000000000000000000000000000000000000000000000008000000000000020000000000000200200000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'miner': '0x0100000000000000000000000000000000000000', 'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000', 'nonce': '0x0000000000000000', 'number': '0x16c599d', 'parentHash': '0xa371025a9a666fd933149f8476d814b64778ad941259c37e9fce8b010edba2fe', 'receiptsRoot': '0x77dc911449e0a8288a573b30201b5a6fcbf6bd4551963d4f57b5a84ad25e4c7a', 'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', 'size': '0x5d4', 'stateRoot': '0xf964f2d921607f50ebdfefc15d2b61e7a51287500ac7d91910490c0326772ce4', 'timestamp': '0x64a706ad', 'totalDifficulty': '0x16c599d', 'transactions': ['0x1db44d5568278ae970183961696085aaeabe0ec2209161cb72dfa29483838e2f'], 'transactionsRoot': '0xb2d0563601d7d0a10d1938b378b1cc47f90fcb4daa90cdaf22c5811e5024b5e7', 'uncles': []}}
DEBUG: Making request. Method: eth_feeHistory
DEBUG: Making request HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_feeHistory
DEBUG: Getting response HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_feeHistory, Response: {'jsonrpc': '2.0', 'id': 10, 'result': {'oldestBlock': '0x16c599d', 'baseFeePerGas': ['0x5d21dba00'], 'gasUsedRatio': [0.006087066666666667]}}
DEBUG: Not enough fee_history. Defaulting less-accurate approach.
DEBUG: Making request. Method: eth_getBlockByNumber
DEBUG: Making request HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_getBlockByNumber
DEBUG: Getting response HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_getBlockByNumber, Response: {'jsonrpc': '2.0', 'id': 11, 'result': {'baseFeePerGas': '0x5d21dba00', 'blockExtraData': '0x', 'blockGasCost': '0x0', 'difficulty': '0x1', 'extDataGasUsed': '0x0', 'extDataHash': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', 'extraData': '0x00000000000c8c400000000000000000000000000016dfca0000000000000000000000000000000000000000000000000000000000036a46000000000000000000000000000000000000000000000000', 'gasLimit': '0xe4e1c0', 'gasUsed': '0x164aa', 'hash': '0xc70b77b747f44729657d10fd79c65d7688b0972234140c643ecd8e1d738d6687', 'logsBloom': '0x00000000000000000000000002100000000100000000080000000000020000000000000000004000000000000000000000000000000000000000000000000000000000000000000000008000000000000020000000000000200200000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'miner': '0x0100000000000000000000000000000000000000', 'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000', 'nonce': '0x0000000000000000', 'number': '0x16c599d', 'parentHash': '0xa371025a9a666fd933149f8476d814b64778ad941259c37e9fce8b010edba2fe', 'receiptsRoot': '0x77dc911449e0a8288a573b30201b5a6fcbf6bd4551963d4f57b5a84ad25e4c7a', 'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', 'size': '0x5d4', 'stateRoot': '0xf964f2d921607f50ebdfefc15d2b61e7a51287500ac7d91910490c0326772ce4', 'timestamp': '0x64a706ad', 'totalDifficulty': '0x16c599d', 'transactions': ['0x1db44d5568278ae970183961696085aaeabe0ec2209161cb72dfa29483838e2f'], 'transactionsRoot': '0xb2d0563601d7d0a10d1938b378b1cc47f90fcb4daa90cdaf22c5811e5024b5e7', 'uncles': []}}
DEBUG: Making request. Method: eth_estimateGas
DEBUG: Making request. Method: eth_chainId
DEBUG: Making request HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_chainId
DEBUG: Getting response HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_chainId, Response: {'result': '0xa869', 'id': 12, 'jsonrpc': '2.0'}
DEBUG: Making request HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_estimateGas
DEBUG: Getting response HTTP. URI: https://api.avax-test.network/ext/bc/C/rpc, Method: eth_estimateGas, Response: {'jsonrpc': '2.0', 'id': 13, 'error': {'code': -32000, 'message': 'invalid opcode: PUSH0'}}
ERROR: (TransactionError) Traceback (most recent call last):
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/api/providers.py", line 817, in estimate_gas_cost
    return self.web3.eth.estimate_gas(txn_params, block_identifier=block_id)
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/web3/eth/eth.py", line 292, in estimate_gas
    return self._estimate_gas(transaction, block_identifier)
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/web3/module.py", line 68, in caller
    result = w3.manager.request_blocking(
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/web3/manager.py", line 232, in request_blocking
    return self.formatted_response(
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/web3/manager.py", line 205, in formatted_response
    raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'invalid opcode: PUSH0'}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3508, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-e66b3a4103cc>", line 1, in <module>
    contract = a.deploy(project.erc721)
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/api/accounts.py", line 219, in deploy
    receipt = contract._cache_wrap(lambda: self.call(txn, **kwargs))
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/contracts/base.py", line 1325, in _cache_wrap
    return function()
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/api/accounts.py", line 219, in <lambda>
    receipt = contract._cache_wrap(lambda: self.call(txn, **kwargs))
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/api/accounts.py", line 112, in call
    txn = self.prepare_transaction(txn)
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/api/accounts.py", line 304, in prepare_transaction
    txn = self.provider.prepare_transaction(txn)
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/api/providers.py", line 1285, in prepare_transaction
    txn.gas_limit = self.estimate_gas_cost(txn)
  File "/Users/hankbirkdale/.local/share/virtualenvs/sc_learn-y1B6Fsfv/lib/python3.8/site-packages/ape/api/providers.py", line 827, in estimate_gas_cost
    raise TransactionError(
ape.exceptions.TransactionError: Gas estimation failed: '(-32000) invalid opcode: PUSH0'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

How can it be fixed?

Its hard to tell if the problem is in the plugin or https://github.com/ApeWorX/ape/blob/main/src/ape/api/accounts.py, specificallly the prepare transaction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.